From da8a1069a8366464b7679f8a69b17b457858e97f Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Sat, 27 Aug 2022 23:11:44 +0100 Subject: [PATCH] saving work --- .../plotting_thesis/alr/gg_pairs_all_alr.R | 4 +- .../plotting/plotting_thesis/linage_bp_dist.R | 165 ------------------ .../plotting_thesis/linage_bp_dist_layout.R | 54 ------ 3 files changed, 2 insertions(+), 221 deletions(-) delete mode 100644 scripts/plotting/plotting_thesis/linage_bp_dist.R delete mode 100644 scripts/plotting/plotting_thesis/linage_bp_dist_layout.R diff --git a/scripts/plotting/plotting_thesis/alr/gg_pairs_all_alr.R b/scripts/plotting/plotting_thesis/alr/gg_pairs_all_alr.R index bf6de45..1b28902 100644 --- a/scripts/plotting/plotting_thesis/alr/gg_pairs_all_alr.R +++ b/scripts/plotting/plotting_thesis/alr/gg_pairs_all_alr.R @@ -5,7 +5,7 @@ #======= # output #======= -outdir_images = paste0("/home/pub/Work/LSHTM/Thesis_Plots/pairs/") +#outdir_images = paste0("/home/pub/Work/LSHTM/Thesis_Plots/pairs/") #cat("plots will output to:", outdir_images) custom_cor <- function(data, mapping, method, ...){ @@ -80,7 +80,7 @@ corr_plotdf = corr_data_extract(merged_df3 aff_dist_cols = colnames(corr_plotdf)[grep("Dist", colnames(corr_plotdf))] static_cols = c("Log10(MAF)" - , "Log10(OR)" + #, "Log10(OR)" ) ############################################################ #============================================= diff --git a/scripts/plotting/plotting_thesis/linage_bp_dist.R b/scripts/plotting/plotting_thesis/linage_bp_dist.R deleted file mode 100644 index d863e8f..0000000 --- a/scripts/plotting/plotting_thesis/linage_bp_dist.R +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env Rscript - -######################################################### -# TASK: Lineage plots [merged_df2] -# Count -# Diversity -# Average stability dist -# Avergae affinity dist: optional -######################################################### -#======= -# output -#======= -# outdir_images = paste0("~/git/Writing/thesis/images/results/" -# , tolower(gene), "/") -# cat("plots will output to:", outdir_images) -######################################################### - -#=============== -#Quick numbers checks -#=============== -nsample_lin = merged_df2[merged_df2$lineage%in%c("L1", "L2", "L3", "L4"),] - -if ( all(table(nsample_lin$sensitivity)== table(nsample_lin$mutation_info_labels)) ){ - cat("\nTotal no. of samples belonging to L1-l4 for", gene,":", nrow(nsample_lin) - , "\nCounting R and S samples") - if( sum(table(nsample_lin$sensitivity)) == nrow(nsample_lin) ){ - cat("\nPASSNumbers cross checked:") - print(table(nsample_lin$sensitivity)) - } -}else{ - stop("Abort: Numbers mismatch. Please check") -} -######################################################################## -################################################### -# Lineage barplots # -################################################### -my_xats = 8 # x axis text size # were 25 -my_yats = 8# y axis text sized_lab_size -my_xals = 8 # x axis label size -my_yals = 8 # y axis label size -my_lls = 8 # legend label size -d_lab_size = 2.3 -#=============================== -# lineage sample and SNP count -#=============================== -lin_countP = lin_count_bp(lf_data = lineage_dfL[['lin_lf']] - , all_lineages = F - , x_categ = "sel_lineages" - , y_count = "p_count" - , use_lineages = c("L1", "L2", "L3", "L4") - , bar_fill_categ = "count_categ" - , display_label_col = "p_count" - , bar_stat_stype = "identity" - , d_lab_size = d_lab_size - , d_lab_col = "black" - , my_xats = my_xats # x axis text size - , my_yats = my_yats # y axis text sized_lab_size - , my_xals = my_xals # x axis label size - , my_yals = my_yals # y axis label size - , my_lls = my_lls # legend label size - , bar_col_labels = c("nsSNPs", "Total Samples") - , bar_col_values = c("grey50", "gray75") - , bar_leg_name = "" - , leg_location = "top" - , y_log10 = F - , y_scale_percent = FALSE - , y_label = c("Count") - ) -lin_countP -#=============================== -# lineage SNP diversity count -#=============================== -lin_diversityP = lin_count_bp_diversity(lf_data = lineage_dfL[['lin_wf']] - , x_categ = "sel_lineages" - , y_count = "snp_diversity" - #, all_lineages = F - , use_lineages = c("L1", "L2", "L3", "L4") - , display_label_col = "snp_diversity_f" - , bar_stat_stype = "identity" - , x_lab_angle = 90 - , d_lab_size = d_lab_size - , my_xats = my_xats # x axis text size - , my_yats = my_yats # y axis text sized_lab_size - , my_xals = my_xals # x axis label size - , my_yals = my_yals # y axis label size - , my_lls = my_lls # legend label size - , y_log10 = F - , y_scale_percent = F - , leg_location = "top" - , y_label = "Percent" #"SNP diversity" - , bp_plot_title = "nsSNP diversity" - , title_colour = "black" #"chocolate4" - , subtitle_text = NULL - , sts = 10 - , subtitle_colour = "#350E20FF") -lin_diversityP - - -################################################### -# Stability dist # -################################################### -# scaled_cols_stability = c("duet_scaled" -# , "deepddg_scaled" -# , "ddg_dynamut2_scaled" -# , "foldx_scaled" -# , "avg_stability_scaled") - -my_ats = 8 # x axis text size # were 25 -my_als = 8# y axis text sized_lab_size -my_leg_ts = 8 # x axis label size -my_leg_title = 8 # y axis label size -my_strip_ts = 8 # - - -my_xlabel = paste0("Average stability ", "(", stability_suffix, ")"); my_xlabel -#plotdf = merged_df2[merged_df2$lineage%in%c("L1", "L2", "L3", "L4"),] - -linP_dm_om = lineage_distP(merged_df2 - , with_facet = F - , x_axis = "avg_stability_scaled" - , y_axis = "lineage_labels" - , x_lab = my_xlabel - , use_lineages = c("L1", "L2", "L3", "L4") - #, fill_categ = "mutation_info_orig", fill_categ_cols = c("#E69F00", "#999999") - , fill_categ = "sensitivity" - , fill_categ_cols = c("red", "blue") - , label_categories = c("Resistant", "Sensitive") - , leg_label = "Mutation group" - , my_ats = my_ats # axis text size - , my_als = my_als # axis label size - , my_leg_ts = my_leg_ts - , my_leg_title = my_leg_title - , my_strip_ts = my_strip_ts - , alpha = 0.56 -) - -linP_dm_om - -################################################### -# Affinity dist [OPTIONAL] # -################################################### -# scaled_cols_affinity = c("affinity_scaled" -# , "mmcsm_lig_scaled" -# , "mcsm_ppi2_scaled" -# , "mcsm_na_scaled" -# , "avg_lig_affinity_scaled") - -# lineage_distP(merged_df2 -# , with_facet = F -# , x_axis = "avg_lig_affinity_scaled" -# , y_axis = "lineage_labels" -# , x_lab = my_xlabel -# , use_lineages = c("L1", "L2", "L3", "L4") -# #, fill_categ = "mutation_info_orig", fill_categ_cols = c("#E69F00", "#999999") -# , fill_categ = "sensitivity" -# , fill_categ_cols = c("red", "blue") -# , label_categories = c("Resistant", "Sensitive") -# , leg_label = "Mutation group" -# , my_ats = 22 # axis text size -# , my_als = 22 # axis label size -# , my_leg_ts = 22 -# , my_leg_title = 22 -# , my_strip_ts = 22 -# , alpha = 0.56 -# ) diff --git a/scripts/plotting/plotting_thesis/linage_bp_dist_layout.R b/scripts/plotting/plotting_thesis/linage_bp_dist_layout.R deleted file mode 100644 index f19822e..0000000 --- a/scripts/plotting/plotting_thesis/linage_bp_dist_layout.R +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env Rscript -source("/home/tanu/git/LSHTM_analysis/scripts/plotting/plotting_thesis/linage_bp_dist.R") -########################################### -# TASK: generate plots for lineage -# Individual plots in -#lineage_bp_both.R -#linage_dist_ens_stability.R -########################################### -# svg -# linPlots_combined = paste0(outdir_images -# , tolower(gene) -# ,"_linP_combined.svg") -# -# cat("\nOutput plot:", linPlots_combined) -# svg(linPlots_combined, width = 18, height = 12) -# -# cowplot::plot_grid( -# cowplot::plot_grid(lin_countP, lin_diversityP -# , nrow = 2 -# , rel_heights = c(1.2,1) -# , labels = "AUTO" -# , label_size = my_label_size), -# NULL, -# linP_dm_om, -# nrow = 1, -# labels = c("", "", "C"), -# label_size = my_label_size, -# rel_widths = c(35, 3, 52) -# ) -# dev.off() - -# png -my_label_size = 12 -linPlots_combined = paste0(outdir_images - , tolower(gene) - ,"_linP_combined.png") - -cat("\nOutput plot:", linPlots_combined) -png(linPlots_combined, width = 9, height = 6, units = "in" ,res = 300) - -cowplot::plot_grid( - cowplot::plot_grid(lin_countP, lin_diversityP - , nrow = 2 - , rel_heights = c(1.2,1) - , labels = "AUTO" - , label_size = my_label_size), - NULL, - linP_dm_om, - nrow = 1, - labels = c("", "", "C"), - label_size = my_label_size, - rel_widths = c(35, 3, 52) -) -dev.off()