updated with two outputs: labelled and unlabelled
This commit is contained in:
parent
351e472e73
commit
a5b03e53e8
1 changed files with 26 additions and 69 deletions
|
@ -16,6 +16,7 @@ getwd()
|
||||||
|
|
||||||
source("Header_TT.R")
|
source("Header_TT.R")
|
||||||
library(ggridges)
|
library(ggridges)
|
||||||
|
library(plyr)
|
||||||
source("combining_dfs_plotting.R")
|
source("combining_dfs_plotting.R")
|
||||||
# PS combined:
|
# PS combined:
|
||||||
# 1) merged_df2
|
# 1) merged_df2
|
||||||
|
@ -61,6 +62,9 @@ cat("cols imported:"
|
||||||
#=======
|
#=======
|
||||||
lineage_dist_combined_dm_om = "lineage_dist_combined_dm_om_PS.svg"
|
lineage_dist_combined_dm_om = "lineage_dist_combined_dm_om_PS.svg"
|
||||||
plot_lineage_dist_combined_dm_om = paste0(plotdir,"/", lineage_dist_combined_dm_om)
|
plot_lineage_dist_combined_dm_om = paste0(plotdir,"/", lineage_dist_combined_dm_om)
|
||||||
|
|
||||||
|
lineage_dist_combined_dm_om_L = "lineage_dist_combined_dm_om_PS_labelled.svg"
|
||||||
|
plot_lineage_dist_combined_dm_om_L = paste0(plotdir,"/", lineage_dist_combined_dm_om_L)
|
||||||
#========================================================================
|
#========================================================================
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
|
@ -76,7 +80,8 @@ plot_lineage_dist_combined_dm_om = paste0(plotdir,"/", lineage_dist_combined_d
|
||||||
my_df = merged_df2
|
my_df = merged_df2
|
||||||
|
|
||||||
# delete variables not required
|
# delete variables not required
|
||||||
rm(my_df_u, merged_df2, merged_df2_comp, merged_df3, merged_df3_comp)
|
rm(my_df_u, merged_df2, merged_df2_comp, merged_df3, merged_df3_comp
|
||||||
|
, merged_df2_lig, merged_df2_comp_lig, merged_df3_lig, merged_df3_comp_lig)
|
||||||
|
|
||||||
# quick checks
|
# quick checks
|
||||||
colnames(my_df)
|
colnames(my_df)
|
||||||
|
@ -153,6 +158,7 @@ table(df_lin$lineage_labels) == table(df_lin$lineage)
|
||||||
#========================
|
#========================
|
||||||
# mutation_info: labels
|
# mutation_info: labels
|
||||||
#========================
|
#========================
|
||||||
|
#{Result:No of DM and OM muts in selected lineages}
|
||||||
table(df_lin$mutation_info)
|
table(df_lin$mutation_info)
|
||||||
|
|
||||||
df_lin$mutation_info_labels = ifelse(df_lin$mutation_info == dr_muts_col, "DM", "OM")
|
df_lin$mutation_info_labels = ifelse(df_lin$mutation_info == dr_muts_col, "DM", "OM")
|
||||||
|
@ -163,16 +169,16 @@ table(df_lin$mutation_info) == table(df_lin$mutation_info_labels)
|
||||||
#=======================
|
#=======================
|
||||||
# subset dr muts only
|
# subset dr muts only
|
||||||
#=======================
|
#=======================
|
||||||
my_df_dr = subset(df_lin, mutation_info == dr_muts_col)
|
#my_df_dr = subset(df_lin, mutation_info == dr_muts_col)
|
||||||
table(my_df_dr$mutation_info)
|
#table(my_df_dr$mutation_info)
|
||||||
table(my_df_dr$lineage)
|
#table(my_df_dr$lineage)
|
||||||
|
|
||||||
#=========================
|
#=========================
|
||||||
# subset other muts only
|
# subset other muts only
|
||||||
#=========================
|
#=========================
|
||||||
my_df_other = subset(df_lin, mutation_info == other_muts_col)
|
#my_df_other = subset(df_lin, mutation_info == other_muts_col)
|
||||||
table(my_df_other$mutation_info)
|
#table(my_df_other$mutation_info)
|
||||||
table(my_df_other$lineage)
|
#table(my_df_other$lineage)
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# end of data extraction and cleaning for plots #
|
# end of data extraction and cleaning for plots #
|
||||||
|
@ -283,78 +289,29 @@ p2
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#==============
|
#==============
|
||||||
# combine plot
|
# combine plots
|
||||||
#===============
|
#===============
|
||||||
|
# 1) without labels
|
||||||
plot_lineage_dist_combined_dm_om
|
plot_lineage_dist_combined_dm_om
|
||||||
svg(plot_lineage_dist_combined_dm_om, width = 12, height = 6)
|
svg(plot_lineage_dist_combined_dm_om, width = 12, height = 6)
|
||||||
|
|
||||||
printFile = cowplot::plot_grid(p1, p2
|
OutPlot1 = cowplot::plot_grid(p1, p2
|
||||||
, rel_widths = c(0.5/2, 0.5/2)
|
, rel_widths = c(0.5/2, 0.5/2))
|
||||||
, label_size = my_als+10)
|
|
||||||
|
|
||||||
print(printFile)
|
print(OutPlot1)
|
||||||
dev.off()
|
dev.off()
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
# 2) with labels
|
||||||
# alternate combination
|
plot_lineage_dist_combined_dm_om_L
|
||||||
########################################################################
|
svg(plot_lineage_dist_combined_dm_om_L, width = 12, height = 6)
|
||||||
#=======================
|
|
||||||
# Plot 3: lineage dist: geom_density_ridges_gradient (allows aesthetics to vary along ridgeline, no alpha setting!)
|
|
||||||
# else same as geom_density_ridges)
|
|
||||||
# x = duet_scaled
|
|
||||||
# y = duet_outcome
|
|
||||||
# FACET (f) = lineage
|
|
||||||
#=======================
|
|
||||||
|
|
||||||
# output individual svg
|
OutPlot2 = cowplot::plot_grid(p1, p2
|
||||||
#plot_lineage_dist_duet = paste0(plotdir,"/", "lineage_dist_duet_f.svg")
|
, labels = c("(a)", "(b)")
|
||||||
#plot_lineage_dist_duet
|
|
||||||
#svg(plot_lineage_dist_duet)
|
|
||||||
|
|
||||||
p3 = ggplot(df, aes(x = duet_scaled
|
|
||||||
, y = duet_outcome))+
|
|
||||||
|
|
||||||
geom_density_ridges_gradient(aes(fill = ..x..)
|
|
||||||
, scale = 3
|
|
||||||
, size = 0.3) +
|
|
||||||
|
|
||||||
facet_wrap( ~lineage_labels
|
|
||||||
, scales = "free"
|
|
||||||
#, labeller = labeller(lineage = my_labels) # sorted by lineage_labels
|
|
||||||
) +
|
|
||||||
coord_cartesian( xlim = c(-1, 1)) +
|
|
||||||
scale_fill_gradientn(colours = my_palette, name = "DUET") +
|
|
||||||
theme(axis.text.x = element_text(size = my_ats
|
|
||||||
, angle = 90
|
|
||||||
, hjust = 1
|
|
||||||
, vjust = 0.4)
|
|
||||||
|
|
||||||
, axis.text.y = element_blank()
|
|
||||||
, axis.title.x = element_text(size = my_ats)
|
|
||||||
, axis.title.y = element_blank()
|
|
||||||
, axis.ticks.y = element_blank()
|
|
||||||
, plot.title = element_blank()
|
|
||||||
, strip.text = element_text(size = my_als)
|
|
||||||
, legend.text = element_text(size = my_als-6)
|
|
||||||
, legend.title = element_text(size = my_als-3))+
|
|
||||||
labs(x = "DUET")
|
|
||||||
|
|
||||||
print(p3)
|
|
||||||
#dev.off()
|
|
||||||
|
|
||||||
#==============
|
|
||||||
# combine plot: alt version
|
|
||||||
#===============
|
|
||||||
plot_lineage_dist_duet_fandnf = paste0(plotdir,"/", "lineage_dist_duet_fandnf.svg")
|
|
||||||
plot_lineage_dist_duet_fandnf
|
|
||||||
svg(plot_lineage_dist_duet_fandnf, width = 12, height = 6)
|
|
||||||
|
|
||||||
printFile = cowplot::plot_grid(p3, p2
|
|
||||||
, rel_widths = c(0.5/2, 0.5/2)
|
, rel_widths = c(0.5/2, 0.5/2)
|
||||||
, label_size = my_als+10)
|
, label_size = my_als)
|
||||||
|
|
||||||
print(printFile)
|
print(OutPlot2)
|
||||||
dev.off()
|
dev.off()
|
||||||
|
|
||||||
|
##############################################################################
|
Loading…
Add table
Add a link
Reference in a new issue