generated ggpairs plots finally

This commit is contained in:
Tanushree Tunstall 2022-08-15 19:05:22 +01:00
parent b68841b337
commit a3e5283a9b
11 changed files with 657 additions and 939 deletions

View file

@ -38,7 +38,7 @@ source("~/git/LSHTM_analysis/scripts/plotting/plotting_colnames.R")
class(merged_df3)
merged_df3 = as.data.frame(merged_df3)
class(df3)
class(merged_df3)
head(merged_df3$pos_count)
nc_pc_CHANGE = which(colnames(merged_df3)== "pos_count"); nc_pc_CHANGE
@ -198,10 +198,10 @@ rects <- data.frame(x = 1:6,
)
rects
rects$text = c("-ve Lig affinty"
, "+ve Lig affinity"
, "+ve PPI2 affinity"
, "-ve PPI2 affinity"
rects$text = c("-ve Lig"
, "+ve Lig"
, "+ve PPI2"
, "-ve PPI2"
, "+ve stability"
, "-ve stability")
@ -221,7 +221,7 @@ peP = ggplot(rects, aes(x, y = 0, fill = colors, label = paste0(text,"\n", num_l
coord_flip()+ scale_x_reverse() +
# theme_void() # remove any axis markings
theme_nothing() # remove any axis markings
peP
peP2 = ggplot(rects, aes(x, y = 0, fill = colors, label = paste0(text,"\n", num_labels))) +
geom_tile() + # make square tiles
@ -229,7 +229,7 @@ peP2 = ggplot(rects, aes(x, y = 0, fill = colors, label = paste0(text,"\n", num_
scale_fill_identity(guide = "none") + # color the tiles with the colors in the data frame
coord_fixed() + # make sure tiles are square
theme_nothing() # remove any axis markings
peP2
# ------------------------------
# bp site site count: ALL
@ -252,24 +252,24 @@ posC_all = site_snp_count_bp(plotdf = df3
#------------------------------
# barplot for sensitivity:
#------------------------------
sensP = stability_count_bp(plotdf = df3
, df_colname = "sensitivity"
#, leg_title = "mCSM-ppi2"
#, label_categories = labels_ppi2
#, bp_plot_title = paste(common_bp_title, "PP-interface")
, yaxis_title = "Number of nsSNPs"
, leg_position = "none"
, subtitle_text = "Sensitivity"
, bar_fill_values = c("red", "blue")
, subtitle_colour= "black"
, sts = 10
, lts = 8
, ats = 8
, als =8
, ltis = 11
, geom_ls =2
)
# sensP = stability_count_bp(plotdf = df3
# , df_colname = "sensitivity"
# #, leg_title = "mCSM-ppi2"
# #, label_categories = labels_ppi2
# #, bp_plot_title = paste(common_bp_title, "PP-interface")
#
# , yaxis_title = "Number of nsSNPs"
# , leg_position = "none"
# , subtitle_text = "Sensitivity"
# , bar_fill_values = c("red", "blue")
# , subtitle_colour= "black"
# , sts = 10
# , lts = 8
# , ats = 8
# , als =8
# , ltis = 11
# , geom_ls =2
# )
consurfP = stability_count_bp(plotdf = df3
@ -290,3 +290,95 @@ consurfP = stability_count_bp(plotdf = df3
consurfP
####################
# Sensitivity count
####################
table(df3$sensitivity)
rect_sens=data.frame(mutation_class=c("Resistant","Sensitive")
, tile_colour =c("red","blue")
, numbers = c(table(df3$sensitivity)[[1]], table(df3$sensitivity)[[2]]))
sensP = ggplot(rect_sens, aes(mutation_class, y = 0
, fill = tile_colour
, label = paste0("n=", numbers)
)) +
geom_tile(width = 1, height = 1) + # make square tiles
geom_label(color = "black", size = 1.7,fill = "white", alpha=0.7) + # add white text in the middle
scale_fill_identity(guide = "none") + # color the tiles with the colors in the data frame
coord_fixed() + # make sure tiles are square
#coord_flip()+ scale_x_reverse() +
# theme_void() # remove any axis markings
theme_nothing() # remove any axis markings
sensP
# sensP2 = sensP +
# coord_flip() + scale_x_reverse()
# sensP2
##############################
# FIXME for other genes: ATTEMPTED to derive numbers
##############################
#
# table(str_df_short$pe_effect_outcome)
# # extract the numbers
# DD_lig_n = table(str_df_short$pe_effect_outcome)[[1]]
# SS_lig_n = 0
# DD_ppi2_n = table(str_df_short$pe_effect_outcome)[[2]]
# SS_ppi2_n = table(str_df_short$pe_effect_outcome)[[4]]
# DD_stability_n = table(str_df_short$pe_effect_outcome)[[3]]
# SS_stability_n = table(str_df_short$pe_effect_outcome)[[5]]
#
# nums = c(DD_lig_n, SS_lig_n,DD_ppi2_n,SS_ppi2_n, DD_stability_n, SS_stability_n )
#
# rect_pe = data.frame(x = 1:6
# , pe_effect_type=c("-ve Lig aff"
# , "+ve Lig aff"
# , "-ve PPI2 aff"
# , " +ve PPI2 aff"
# , "-ve stability"
# , "+ve stability")
#
# , tile_colour =c("#ffd700" #gold
# ,"#f0e68c" # khaki
# , "#ff1493" #deeppink
# , "#da70d6" #orchid
# , "#F8766D" # Sred
# , "#00BFC4") #Sblue
# # , numbers = c(DD_lig_n
# # , SS_lig_n
# # , DD_ppi2_n
# # , SS_ppi2_n
# # , DD_stability_n
# # , SS_stability_n )
# , numbers = nums
# )
#
# rect_pe$num_labels = paste0("n=", rect_pe$numbers)
# rect_pe
#
# # create plot
# peP = ggplot(rect_pe, aes(x=pe_effect_type , y = 0, fill = tile_colour
# , label = paste0(pe_effect_type,"\n", num_labels))) +
# geom_tile(width = 1, height = 1) + # make square tiles
# geom_text(color = "black", size = 1.7) + # add white text in the middle
# scale_fill_identity(guide = "none") + # color the tiles with the colors in the data frame
# coord_fixed() + # make sure tiles are square
# coord_flip()+ scale_x_reverse() +
# # theme_void() # remove any axis markings
# theme_nothing() # remove any axis markings
# peP
#
# peP2 = ggplot(rect_pe, aes(x=pe_effect_type, y = 0, fill = tile_colour
# , label = paste0(pe_effect_type,"\n", num_labels))) +
# geom_tile() +
# geom_text(color = "black", size = 1.6) +
# scale_fill_identity(guide = "none") +
# coord_fixed() +
# theme_nothing()
# peP2