updated lineage dist for LIG for consistency

This commit is contained in:
Tanushree Tunstall 2020-01-22 11:34:59 +00:00
parent f43878def2
commit dd7e48d7e2

View file

@ -75,6 +75,29 @@ if (max(my_df$Dis_lig_Ang) < 10){
######################################################################## ########################################################################
# end of data extraction and cleaning for plots # # 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 # Plot: Lineage Distribution
@ -117,10 +140,10 @@ if(sum(table(my_df$lineage)[r1]) == nrow(df_lin)) {
print("Error!: check your numbers") print("Error!: check your numbers")
} }
#<<<<<<<<<<<<<<<<<<<<<<<<< #!!!!!!!!!!!!!!!!!!!!!!!!!
# REASSIGNMENT # REASSIGNMENT
df <- df_lin df <- df_lin
#<<<<<<<<<<<<<<<<<<<<<<<<< #!!!!!!!!!!!!!!!!!!!!!!!!!
rm(df_lin) rm(df_lin)
@ -131,15 +154,15 @@ rm(df_lin)
library(plotly) library(plotly)
library(ggridges) library(ggridges)
fooNames = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4') my_labels = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4')
names(fooNames) = c('lineage1', 'lineage2', 'lineage3', 'lineage4') names(my_labels) = c('lineage1', 'lineage2', 'lineage3', 'lineage4')
g <- ggplot(df, aes(x = ratioPredAff)) + g <- ggplot(df, aes(x = ratioPredAff)) +
geom_density(aes(fill = Lig_outcome) geom_density(aes(fill = Lig_outcome)
, alpha = 0.5) + , alpha = 0.5) +
facet_wrap( ~ lineage facet_wrap( ~ lineage
, scales = "free" , scales = "free"
, labeller = labeller(lineage = fooNames) ) + , labeller = labeller(lineage = my_labels) ) +
coord_cartesian(xlim = c(-1, 1) coord_cartesian(xlim = c(-1, 1)
# , ylim = c(0, 6) # , ylim = c(0, 6)
# , clip = "off" # , clip = "off"
@ -153,15 +176,18 @@ ggplotly(g)
my_ats = 15 # axis text size my_ats = 15 # axis text size
my_als = 20 # axis label size my_als = 20 # axis label size
fooNames = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4') my_labels = c('Lineage 1', 'Lineage 2', 'Lineage 3', 'Lineage 4')
names(fooNames) = c('lineage1', 'lineage2', 'lineage3', 'lineage4') names(my_labels) = c('lineage1', 'lineage2', 'lineage3', 'lineage4')
# set output dir for plots # set output dir for plots
getwd() getwd()
setwd("~/git/Data/pyrazinamide/output/plots") setwd("~/git/Data/pyrazinamide/output/plots")
getwd() getwd()
svg('lineage_dist_LIG.svg') # check plot name
my_plot_name
svg(my_plot_name)
printFile = ggplot( df, aes(x = ratioPredAff printFile = ggplot( df, aes(x = ratioPredAff
, y = Lig_outcome) ) + , y = Lig_outcome) ) +
@ -172,7 +198,7 @@ printFile = ggplot( df, aes(x = ratioPredAff
facet_wrap( ~lineage facet_wrap( ~lineage
, scales = "free" , scales = "free"
# , switch = 'x' # , switch = 'x'
, labeller = labeller(lineage = fooNames) ) + , labeller = labeller(lineage = my_labels) ) +
coord_cartesian( xlim = c(-1, 1) coord_cartesian( xlim = c(-1, 1)
# , ylim = c(0, 6) # , ylim = c(0, 6)
# , clip = "off" # , clip = "off"
@ -202,12 +228,6 @@ printFile = ggplot( df, aes(x = ratioPredAff
print(printFile) print(printFile)
dev.off() 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 # COMPARING DISTRIBUTIONS