dadded v2 of barplot layput

This commit is contained in:
Tanushree Tunstall 2022-08-14 22:56:08 +01:00
parent da8f8d90d4
commit 7c40e13771
7 changed files with 800 additions and 79 deletions

View file

@ -39,12 +39,12 @@ class(merged_df3)
merged_df3 = as.data.frame(merged_df3)
class(df3)
head(df3$pos_count)
head(merged_df3$pos_count)
nc_pc_CHANGE = which(colnames(merged_df3)== "pos_count")
colnames(merged_df3)[nc_pc_CHANGE] = "df2_pos_count_all"
head(merged_df3$pos_count)
head(merged_df3$pos_count_all)
head(merged_df3$df2_pos_count_all)
# DROP pos_count column
# merged_df3$pos_count <-NULL
@ -247,11 +247,6 @@ snap2P = stability_count_bp(plotdf = df3
#
# dev.off()
###########################################################
#=========================
# Affinity outcome
@ -285,7 +280,7 @@ mLigP = stability_count_bp(plotdf = df3_lig
, bar_fill_values = c("#F8766D", "#00BFC4")
, sts = sts
, subtitle_colour= subtitle_colour
, bp_plot_title = paste(common_bp_title, "ligand")
#, bp_plot_title = paste(common_bp_title, "ligand")
)
#------------------------------
@ -304,7 +299,7 @@ mmLigP = stability_count_bp(plotdf = df3_lig
, bar_fill_values = c("#F8766D", "#00BFC4")
, sts = sts
, subtitle_colour= subtitle_colour
, bp_plot_title = paste(common_bp_title, "ligand")
#, bp_plot_title = paste(common_bp_title, "ligand")
)
#------------------------------
@ -485,46 +480,43 @@ dev.off()
#####################################################################
# test
setDT(df3)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
foo = df3[, c("mutationinformation", "position")]
df4 = foo[, c("mutationinformation", "position")]
var_pos = "position"
df4 =
df4 %>%
dplyr::add_count(eval(parse(text = var_pos)))
class(df4)
df4 = as.data.frame(df4)
class(df4)
nc_change = which(colnames(df4) == "n")
colnames(df4)[nc_change] <- "pos_count"
class(df4)
setDT(df4)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
class(df4)
all(df4$pos_count==df4$pos_count2)
# %>%
#group_by(pos_count = position)
#
# setDT(df3)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
# foo = df3[, c("mutationinformation", "position")]
# df4 = foo[, c("mutationinformation", "position")]
#
#
# var_pos = "position"
# df4 =
# df4 %>%
# dplyr::group_by(position) %>%
# count(position)
foo2 = df4[, c("mutationinformation", "position", "pos_count")]
# dplyr::add_count(eval(parse(text = var_pos)))
#
# class(df4)
# df4 = as.data.frame(df4)
# class(df4)
# nc_change = which(colnames(df4) == "n")
# colnames(df4)[nc_change] <- "pos_count"
# class(df4)
#
# setDT(df4)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
# class(df4)
#
# all(df4$pos_count==df4$pos_count2)
#
# # %>%
# #group_by(pos_count = position)
#
# # df4 =
# # df4 %>%
# # dplyr::group_by(position) %>%
# # count(position)
#foo2 = df4[, c("mutationinformation", "position", "pos_count")]
#####################################################################
# ------------------------------
# bp site site count: ALL
# <10 Ang ligand
# ------------------------------
posC_all = site_snp_count_bp(plotdf = df3
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
@ -541,9 +533,10 @@ posC_lig = site_snp_count_bp(plotdf = df3_lig
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
, yaxis_title = "Number of Sites"#+ annotate("text", x = 1.5, y = 2.2, label = "Text No. 1")
, subtitle_text = paste0(common_bp_title, " ligand")
, subtitle_size = 20
#, subtitle_text = paste0(common_bp_title, " ligand")
, subtitle_size = 8
, subtitle_colour = subtitle_colour)
posC_lig
# ------------------------------
# bp site site count: ppi2
# < 10 Ang interface
@ -556,7 +549,7 @@ posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
, subtitle_text = paste0(common_bp_title, " interface")
, subtitle_size = 20
, subtitle_colour = subtitle_colour)
posC_ppi2
# ------------------------------
#FIXME: bp site site count: na
# < 10 Ang TBC
@ -571,23 +564,23 @@ posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
# output: SITE SNP count:
# all + affinity
#==========================
my_label_size = 25
pos_count_combined_CLP = paste0(outdir_images
,tolower(gene)
,"_pos_count_PS_AFF.svg")
svg(pos_count_combined_CLP, width = 20, height = 5.5)
print(paste0("plot filename:", pos_count_combined_CLP))
cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
#, posC_na
, nrow = 1
, ncol = 3
, labels = "AUTO"
, label_size = my_label_size)
dev.off()
# my_label_size = 25
# pos_count_combined_CLP = paste0(outdir_images
# ,tolower(gene)
# ,"_pos_count_PS_AFF.svg")
#
#
# svg(pos_count_combined_CLP, width = 20, height = 5.5)
# print(paste0("plot filename:", pos_count_combined_CLP))
#
# cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
# #, posC_na
# , nrow = 1
# , ncol = 3
# , labels = "AUTO"
# , label_size = my_label_size)
#
# dev.off()
#===============================================================