From 5ebb4a2d2505c0ba074d65b22aa5f1ef8396eb28 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Wed, 22 Jan 2020 11:34:59 +0000 Subject: [PATCH] updated lineage dist for LIG for consistency --- .../scripts/plotting/lineage_dist_LIG.R | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/mcsm_analysis/pyrazinamide/scripts/plotting/lineage_dist_LIG.R b/mcsm_analysis/pyrazinamide/scripts/plotting/lineage_dist_LIG.R index ebbec76..e4e6972 100644 --- a/mcsm_analysis/pyrazinamide/scripts/plotting/lineage_dist_LIG.R +++ b/mcsm_analysis/pyrazinamide/scripts/plotting/lineage_dist_LIG.R @@ -75,6 +75,29 @@ if (max(my_df$Dis_lig_Ang) < 10){ ######################################################################## # end of data extraction and cleaning for plots # ######################################################################## +#========================== +# Data for plot: assign as +# necessary +#=========================== + +# uncomment as necessary +#!!!!!!!!!!!!!!!!!!!!!!! +# REASSIGNMENT + +#================== +# data for ALL muts +#================== +plot_df = my_df +my_plot_name = 'lineage_dist_PS.svg' +#my_plot_name = 'lineage_dist_PS_comp.svg' + +#======================= +# data for dr_muts ONLY +#======================= +#plot_df = my_df_dr +#my_plot_name = 'lineage_dist_dr_PS.svg' +#my_plot_name = 'lineage_dist_dr_PS_comp.svg' +#!!!!!!!!!!!!!!!!!!!!!!! #========================== # Plot: Lineage Distribution @@ -117,10 +140,10 @@ if(sum(table(my_df$lineage)[r1]) == nrow(df_lin)) { print("Error!: check your numbers") } -#<<<<<<<<<<<<<<<<<<<<<<<<< +#!!!!!!!!!!!!!!!!!!!!!!!!! # REASSIGNMENT df <- df_lin -#<<<<<<<<<<<<<<<<<<<<<<<<< +#!!!!!!!!!!!!!!!!!!!!!!!!! rm(df_lin) @@ -131,15 +154,15 @@ rm(df_lin) library(plotly) library(ggridges) -fooNames = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4') -names(fooNames) = c('lineage1', 'lineage2', 'lineage3', 'lineage4') +my_labels = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4') +names(my_labels) = c('lineage1', 'lineage2', 'lineage3', 'lineage4') g <- ggplot(df, aes(x = ratioPredAff)) + geom_density(aes(fill = Lig_outcome) , alpha = 0.5) + facet_wrap( ~ lineage , scales = "free" - , labeller = labeller(lineage = fooNames) ) + + , labeller = labeller(lineage = my_labels) ) + coord_cartesian(xlim = c(-1, 1) # , ylim = c(0, 6) # , clip = "off" @@ -153,15 +176,18 @@ ggplotly(g) my_ats = 15 # axis text size my_als = 20 # axis label size -fooNames = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4') -names(fooNames) = c('lineage1', 'lineage2', 'lineage3', 'lineage4') +my_labels = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4') +names(my_labels) = c('lineage1', 'lineage2', 'lineage3', 'lineage4') # set output dir for plots getwd() setwd("~/git/Data/pyrazinamide/output/plots") getwd() -svg('lineage_dist_LIG.svg') +# check plot name +my_plot_name + +svg(my_plot_name) printFile = ggplot( df, aes(x = ratioPredAff , y = Lig_outcome) ) + @@ -172,7 +198,7 @@ printFile = ggplot( df, aes(x = ratioPredAff facet_wrap( ~lineage , scales = "free" # , switch = 'x' - , labeller = labeller(lineage = fooNames) ) + + , labeller = labeller(lineage = my_labels) ) + coord_cartesian( xlim = c(-1, 1) # , ylim = c(0, 6) # , clip = "off" @@ -202,12 +228,6 @@ printFile = ggplot( df, aes(x = ratioPredAff print(printFile) dev.off() - -#=!=!=!=!=!=! -# COMMENT: When you look at all mutations, the lineage differences disappear... -# The pattern we are interested in is possibly only for dr_mutations -#=!=!=!=!=!=! - #=================================================== # COMPARING DISTRIBUTIONS