saving other_plots.R
This commit is contained in:
parent
5102bbea1b
commit
6934faca10
5 changed files with 227 additions and 241 deletions
|
@ -18,19 +18,29 @@ source("other_plots_data.R")
|
|||
#=======
|
||||
# output
|
||||
#=======
|
||||
dr_other_plots_combined = "dr_other_muts.svg"
|
||||
plot_dr_other_plots_combined = paste0(plotdir,"/", dr_other_plots_combined)
|
||||
dr_other_combined = "dr_other_muts.svg"
|
||||
plot_dr_other_combined = paste0(plotdir,"/", dr_other_combined)
|
||||
|
||||
dr_other_foldx = "dr_other_muts_foldx.svg"
|
||||
plot_dr_other_foldx = paste0(plotdir,"/", dr_other_foldx)
|
||||
|
||||
point_legend = "point_legend.svg"
|
||||
plot_point_legend = paste0(plotdir,"/", point_legend)
|
||||
########################################################################
|
||||
# end of data extraction and cleaning for plots #
|
||||
########################################################################
|
||||
#my_comparisons <- list( c(dr_muts_col, other_muts_col) )
|
||||
my_comparisons <- list( c("DM", "OM") )
|
||||
|
||||
|
||||
my_ats = 15# axis text size
|
||||
my_als = 20 # axis label size
|
||||
my_fls = 20 # facet label size
|
||||
my_pts = 22 # plot title size
|
||||
|
||||
#===========
|
||||
# Plot1: PS
|
||||
#===========
|
||||
|
||||
my_stat_ps = compare_means(param_value~mutation_info, group.by = "param_type"
|
||||
, data = df_lf_ps, paired = FALSE, p.adjust.method = "BH")
|
||||
|
||||
|
@ -42,22 +52,23 @@ p1 = ggplot(df_lf_ps, aes(x = mutation_info
|
|||
, nrow = 1
|
||||
, scales = "free_y") +
|
||||
geom_boxplot(fill = "white", outlier.colour = NA
|
||||
# position = position_dodge(width = 0.9)
|
||||
, width = 0.5) +
|
||||
#, position = position_dodge(width = 0.9)
|
||||
, width = 0.2) +
|
||||
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
||||
, alpha = 0.5
|
||||
, show.legend = FALSE
|
||||
, aes(colour = factor(duet_outcome))) +
|
||||
theme(axis.text.x = element_text(size = 15)
|
||||
, axis.text.y = element_text(size = 15
|
||||
theme(axis.text.x = element_text(size = my_ats)
|
||||
, axis.text.y = element_text(size = my_ats
|
||||
, angle = 0
|
||||
, hjust = 1
|
||||
, vjust = 0)
|
||||
, axis.title.x = element_text(size = 15)
|
||||
, axis.title.y = element_text(size = 15)
|
||||
, plot.title = element_text(size = 20, hjust = 0.5)
|
||||
, strip.text.x = element_text(size = 15, colour = "black")
|
||||
, legend.title = element_text(color = "black", size = 20)
|
||||
, legend.text = element_text(size = 15)
|
||||
, axis.title.x = element_text(size = my_ats)
|
||||
, axis.title.y = element_text(size = my_ats)
|
||||
, plot.title = element_text(size = my_pts , hjust = 0.5)
|
||||
, strip.text.x = element_text(size = my_fls, colour = "black")
|
||||
, legend.title = element_text(color = "black", size = my_als)
|
||||
, legend.text = element_text(size = my_ats)
|
||||
, legend.direction = "vertical") +
|
||||
labs(title = "DUET"
|
||||
, x = ""
|
||||
|
@ -68,51 +79,9 @@ p1 = ggplot(df_lf_ps, aes(x = mutation_info
|
|||
#, label = "p.format")
|
||||
, label = "p.signif")
|
||||
p1
|
||||
|
||||
#===============================================================
|
||||
#===========
|
||||
# Plot 2: Foldx
|
||||
#===========
|
||||
my_stat_foldx = compare_means(param_value~mutation_info, group.by = "param_type"
|
||||
, data = df_lf_foldx, paired = FALSE, p.adjust.method = "BH")
|
||||
|
||||
y_value = "param_value"
|
||||
|
||||
p2 = ggplot(df_lf_foldx, aes(x = mutation_info
|
||||
, y = eval(parse(text=y_value)) )) +
|
||||
facet_wrap(~ param_type
|
||||
, nrow = 1
|
||||
, scales = "free_y") +
|
||||
geom_boxplot(fill = "white", outlier.colour = NA
|
||||
# position = position_dodge(width = 0.9)
|
||||
, width = 0.5) +
|
||||
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
||||
, show.legend = FALSE
|
||||
, aes(colour = factor(foldx_outcome))) +
|
||||
theme(axis.text.x = element_text(size = 15)
|
||||
, axis.text.y = element_text(size = 15
|
||||
, angle = 0
|
||||
, hjust = 1
|
||||
, vjust = 0)
|
||||
, axis.title.x = element_text(size = 15)
|
||||
, axis.title.y = element_text(size = 15)
|
||||
, plot.title = element_text(size = 20, hjust = 0.5)
|
||||
, strip.text.x = element_text(size = 15, colour = "black")
|
||||
, legend.title = element_text(color = "black", size = 20)
|
||||
, legend.text = element_text(size = 15)
|
||||
, legend.direction = "vertical") +
|
||||
labs(title = "Foldx"
|
||||
, x = ""
|
||||
, y = "")+
|
||||
stat_compare_means(comparisons = my_comparisons
|
||||
, method = "wilcox.test"
|
||||
, paired = FALSE
|
||||
#, label = "p.format")
|
||||
, label = "p.signif")
|
||||
p2
|
||||
|
||||
|
||||
#===========
|
||||
# Plot 3: LIG
|
||||
# Plot 2: LIG
|
||||
#===========
|
||||
|
||||
my_stat_lig = compare_means(param_value~mutation_info, group.by = "param_type"
|
||||
|
@ -120,28 +89,29 @@ my_stat_lig = compare_means(param_value~mutation_info, group.by = "param_type"
|
|||
|
||||
y_value = "param_value"
|
||||
|
||||
p3 = ggplot(df_lf_lig, aes(x = mutation_info
|
||||
p2 = ggplot(df_lf_lig, aes(x = mutation_info
|
||||
, y = eval(parse(text=y_value)) )) +
|
||||
facet_wrap(~ param_type
|
||||
, nrow = 1
|
||||
, scales = "free_y") +
|
||||
geom_boxplot(fill = "white", outlier.colour = NA
|
||||
# position = position_dodge(width = 0.9)
|
||||
, width = 0.5) +
|
||||
#, position = position_dodge(width = 0.9)
|
||||
, width = 0.2) +
|
||||
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
||||
, alpha = 0.5
|
||||
, show.legend = FALSE
|
||||
, aes(colour = factor(ligand_outcome))) +
|
||||
theme(axis.text.x = element_text(size = 15)
|
||||
, axis.text.y = element_text(size = 15
|
||||
theme(axis.text.x = element_text(size = my_ats)
|
||||
, axis.text.y = element_text(size = my_ats
|
||||
, angle = 0
|
||||
, hjust = 1
|
||||
, vjust = 0)
|
||||
, axis.title.x = element_text(size = 15)
|
||||
, axis.title.y = element_text(size = 15)
|
||||
, plot.title = element_text(size = 20, hjust = 0.5)
|
||||
, strip.text.x = element_text(size = 15, colour = "black")
|
||||
, legend.title = element_text(color = "black", size = 20)
|
||||
, legend.text = element_text(size = 15)
|
||||
, axis.title.x = element_text(size = my_ats)
|
||||
, axis.title.y = element_text(size = my_ats)
|
||||
, plot.title = element_text(size = my_pts , hjust = 0.5)
|
||||
, strip.text.x = element_text(size = my_fls, colour = "black")
|
||||
, legend.title = element_text(color = "black", size = my_als)
|
||||
, legend.text = element_text(size = my_ats)
|
||||
, legend.direction = "vertical") +
|
||||
labs(title = "Ligand Affinity"
|
||||
, x = ""
|
||||
|
@ -152,20 +122,108 @@ p3 = ggplot(df_lf_lig, aes(x = mutation_info
|
|||
#, label = "p.format")
|
||||
, label = "p.signif")
|
||||
|
||||
p3
|
||||
p2
|
||||
|
||||
#====================================================================
|
||||
#===========
|
||||
# Plot 3: Foldx
|
||||
#===========
|
||||
my_stat_foldx = compare_means(param_value~mutation_info, group.by = "param_type"
|
||||
, data = df_lf_foldx, paired = FALSE, p.adjust.method = "BH")
|
||||
|
||||
y_value = "param_value"
|
||||
|
||||
p3 = ggplot(df_lf_foldx, aes(x = mutation_info
|
||||
, y = eval(parse(text=y_value)) )) +
|
||||
facet_wrap(~ param_type
|
||||
, nrow = 1
|
||||
, scales = "free_y") +
|
||||
geom_boxplot(fill = "white", outlier.colour = NA
|
||||
#, position = position_dodge(width = 0.2)
|
||||
, width = 0.5) +
|
||||
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
||||
, alpha = 0.5
|
||||
, show.legend = FALSE
|
||||
, aes(colour = factor(foldx_outcome))) +
|
||||
theme(axis.text.x = element_text(size = my_ats)
|
||||
, axis.text.y = element_text(size = my_ats
|
||||
, angle = 0
|
||||
, hjust = 1
|
||||
, vjust = 0)
|
||||
, axis.title.x = element_text(size = my_ats)
|
||||
, axis.title.y = element_text(size = my_ats)
|
||||
, plot.title = element_text(size = my_pts , hjust = 0.5)
|
||||
, strip.text.x = element_text(size = my_fls, colour = "black")
|
||||
#, legend.title = element_text(color = "black", size = my_als)
|
||||
, legend.text = element_text(size = my_ats)
|
||||
, legend.direction = "vertical"
|
||||
, legend.title = element_blank()) +
|
||||
labs(title = ""
|
||||
, x = ""
|
||||
, y = "") +
|
||||
stat_compare_means(comparisons = my_comparisons
|
||||
, method = "wilcox.test"
|
||||
, paired = FALSE
|
||||
#, label = "p.format")
|
||||
, label = "p.signif")
|
||||
|
||||
p3
|
||||
|
||||
#====================================================================
|
||||
#===========
|
||||
# legend
|
||||
#===========
|
||||
|
||||
legend = ggplot(df_lf_foldx, aes(x = mutation_info
|
||||
, y = eval(parse(text=y_value)) )) +
|
||||
facet_wrap(~ param_type
|
||||
, nrow = 1
|
||||
, scales = "free_y") +
|
||||
geom_boxplot(fill = "white", outlier.colour = NA
|
||||
#, position = position_dodge(width = 0.2)
|
||||
, width = 0.5) +
|
||||
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
||||
, aes(colour = factor(foldx_outcome))) +
|
||||
theme(legend.text = element_text(size = 25)
|
||||
, legend.direction = "vertical"
|
||||
, legend.title = element_blank())+
|
||||
|
||||
guides(color = guide_legend(override.aes = list(size = 6)))
|
||||
|
||||
legend
|
||||
|
||||
#===========================
|
||||
# combine
|
||||
#===========================
|
||||
#svg(plot_or_combined, width = 32, height = 12)
|
||||
svg("test.svg", width = 25, height = 12)
|
||||
#theme_set(theme_gray()) # to preserve default theme
|
||||
#---------
|
||||
# plot 1
|
||||
#---------
|
||||
cat("Output plot:",plot_dr_other_combined)
|
||||
svg(plot_dr_other_combined, width = 24, height = 12)
|
||||
|
||||
printFile = cowplot::plot_grid(plot_grid(p1, p2, p3
|
||||
, nrow = 3
|
||||
, align = 'h'
|
||||
, labels = c("", "", "")
|
||||
, label_size = 20))
|
||||
print(printFile)
|
||||
#theme_set(theme_gray()) # to preserve default theme
|
||||
OutPlot = cowplot::plot_grid(p1, p2
|
||||
, nrow = 2
|
||||
, align = "hv"
|
||||
, axis = "b"
|
||||
, labels = c("", "", "")
|
||||
, label_size = my_als)
|
||||
print(OutPlot)
|
||||
dev.off()
|
||||
|
||||
|
||||
#---------
|
||||
# plot 2
|
||||
#---------
|
||||
svg(plot_dr_other_foldx , width = 6, height = 7)
|
||||
OutPlot2 = p3
|
||||
print(OutPlot2)
|
||||
dev.off()
|
||||
|
||||
#---------
|
||||
# plot 3: legend
|
||||
#---------
|
||||
svg(plot_point_legend, width = 6, height = 7)
|
||||
OutPlot3 = legend
|
||||
print(OutPlot3)
|
||||
dev.off()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue