From b4caf00230c158966e511e20b058a2301551c301 Mon Sep 17 00:00:00 2001 From: Fabian Springer Date: Fri, 15 Mar 2024 21:54:10 +0100 Subject: [PATCH] minor fixes in the appearance of the plots --- src/plotting/ExtendedDataFigure2.R | 15 ++++++++------- src/plotting/ExtendedDataFigure4.R | 2 +- src/plotting/ExtendedDataFigure6.R | 2 +- src/plotting/Figure2.R | 2 +- src/plotting/Figure3.R | 10 ++++++++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/plotting/ExtendedDataFigure2.R b/src/plotting/ExtendedDataFigure2.R index 0d0276f..75c908c 100644 --- a/src/plotting/ExtendedDataFigure2.R +++ b/src/plotting/ExtendedDataFigure2.R @@ -114,7 +114,7 @@ f_helper_plot_diversity <- function(c_comparison, c_name) { # Just use the ggsignif function for plotting the p-value symbols ggsignif::geom_signif( comparisons = c_comparison_list, - #annotations = p_to_symbol(p_adj_vec_shannon), + annotations = p_to_symbol(p_adj_vec_shannon), vjust = -0, step_increase = 0.075, textsize = 3 ) @@ -136,6 +136,7 @@ f_helper_plot_diversity <- function(c_comparison, c_name) { return(list(richness = pt_richness, shannon = pt_shannon, pcoa = pt_pcoa)) } + i <- 1 comparison_list figure_indices <- c("A","B","C","E","F","G","I","J","K") @@ -145,7 +146,7 @@ h <- 4.5 for(i in seq(1,length(comparison_list))){ # loop through the comparisons and generate the plots res <- f_helper_plot_diversity(c_comparison = comparison_list[[i]], c_name = comparison_name[i]) - + # save the plots ggsave(paste0(save_fig_folder,"/",figure_indices[id],"_SpeciesRichness.pdf"), res$richness, width = w, height = h) id <- id + 1 @@ -178,7 +179,7 @@ pt_D <- f_plot_volcano( plot_df = plot_df, xBreaks = xBreaks, xLims = xLims, man_y_breaks = man_y_breaks ) + - scale_fill_manual(values = group_colors)+ + scale_fill_manual(values = group_colors, drop = F)+ size_definition # CRLM vs non-TUmor CRLM @@ -190,7 +191,7 @@ pt_H <- f_plot_volcano( plot_df = plot_df, xBreaks = xBreaks, xLims = xLims, man_y_breaks = man_y_breaks ) + - scale_fill_manual(values = group_colors)+ + scale_fill_manual(values = group_colors, drop = F)+ size_definition @@ -207,7 +208,7 @@ pt_L <- f_plot_volcano( plot_df = plot_df, xBreaks = xBreaks, xLims = xLims, man_y_breaks = man_y_breaks ) + - scale_fill_manual(values = group_colors)+ + scale_fill_manual(values = group_colors, drop = F)+ size_definition # iCCA vs GBC #! Note: Labels are swapped compard to the manuscript figure (iCCA is on the left in the manuscript). Values are all the same with swapped sign. @@ -219,7 +220,7 @@ pt_M <- f_plot_volcano( plot_df = plot_df, xBreaks = xBreaks, xLims = xLims, man_y_breaks = man_y_breaks ) + - scale_fill_manual(values = group_colors)+ + scale_fill_manual(values = group_colors, drop = F)+ size_definition # GBC vs phCCA/dCCA #! Note: Labels are swapped compard to the manuscript figure (iCCA is on the left in the manuscript). Values are all the same with swapped sign. @@ -230,7 +231,7 @@ xLims <- c(-0.51,1.1) pt_N <- f_plot_volcano( plot_df = plot_df, xBreaks = xBreaks, xLims = xLims, man_y_breaks = man_y_breaks) + - scale_fill_manual(values = group_colors)+ + scale_fill_manual(values = group_colors, drop = F)+ size_definition diff --git a/src/plotting/ExtendedDataFigure4.R b/src/plotting/ExtendedDataFigure4.R index a1621fc..3c8a704 100644 --- a/src/plotting/ExtendedDataFigure4.R +++ b/src/plotting/ExtendedDataFigure4.R @@ -275,7 +275,7 @@ pt_box_RNAseq <- # Combine the two boxplots pt_box_combined <- (pt_box_16S+theme(axis.text.x = element_blank(),axis.ticks.x = element_blank())) / pt_box_RNAseq -ggsave(pt_box_combined ,filename = file.path(save_fig_folder,"C_Boxplot_5R16SvsBulkRNAseq_DKFZ.pdf"), width = 5, height = 5) +ggsave(pt_box_combined ,filename = file.path(save_fig_folder,"C_Boxplot_5R16SvsBulkRNAseq_DKFZ.pdf"), width = 12, height = 8) #* Panel D: Pairsplot of genus level relative abundances for all datasets against each other ---- diff --git a/src/plotting/ExtendedDataFigure6.R b/src/plotting/ExtendedDataFigure6.R index 5d3b2ce..371ad53 100644 --- a/src/plotting/ExtendedDataFigure6.R +++ b/src/plotting/ExtendedDataFigure6.R @@ -273,7 +273,7 @@ plot_df <- all_test_results_df %>% filter(comparison == "Fibrosis_late_vs_HCC") plot_df$Group1 <- str_replace(plot_df$Group1,"LateFib","Fibrosis late stage") plot_df$Group2 <- str_replace(plot_df$Group2,"LateFib","Fibrosis late stage") range(plot_df$effect.size) -xBreaks <- round(seq(-0.8,0.3,0.1),1) +xBreaks <- round(seq(-0.8,0.4,0.2),1) xLims <- range(xBreaks) pt_E <- f_plot_volcano( plot_df = plot_df, xBreaks = xBreaks, xLims = xLims, diff --git a/src/plotting/Figure2.R b/src/plotting/Figure2.R index b4fd455..c11ca51 100644 --- a/src/plotting/Figure2.R +++ b/src/plotting/Figure2.R @@ -108,7 +108,7 @@ pt_B <- meanAB_df %>% geom_abline(slope = 1, intercept = 0) + tune::coord_obs_pred() + theme_paper + - scale_fill_manual(values = phylum_colors_vec)+ + scale_fill_manual(values = phylum_colors_df %>% dplyr::select(phylum,HEX) %>% deframe())+ annotate("text", x = -5, y = 0, hjust = 0, vjust = 0.75, size = 3, # annotate("text", x = -2, y = -3.7, hjust = 0, vjust = 0.75,size = 3, diff --git a/src/plotting/Figure3.R b/src/plotting/Figure3.R index b199eee..084e495 100644 --- a/src/plotting/Figure3.R +++ b/src/plotting/Figure3.R @@ -167,7 +167,7 @@ pt_B <- plot_df %>% scale_fill_manual(values = col_vec, labels = col_labs) + geom_hline(yintercept = -log10(0.05)) + # label highly significant genes of other pathways - ggrepel::geom_text_repel(data = plot_df %>% filter(pathway_association == "other", -log10(p.val_adj) > 8 | (effect.size > 0 & -log10(p.val_adj) > 6) | effect.size > 0.4), aes(label = gene), color = "darkgrey", size = 3)+ + ggrepel::geom_text_repel(data = plot_df %>% filter(pathway_association == "other", -log10(p.val_adj) > 8 | (effect.size > 0 & -log10(p.val_adj) > 6) | effect.size > 0.4), aes(label = gene), color = "darkgrey", size = 3) + # label highly significant genes of inflammatory pathways and metabolic pathways ggrepel::geom_label_repel(data = plot_df %>% filter(pathway_association != "other", -log10(p.val_adj) > 2), aes(label = gene, fill = pathway_association), color = "black", alpha = 0.85, show.legend = F, size = 3) + @@ -177,7 +177,13 @@ pt_B <- plot_df %>% ggtitle("Gene expression differnces depending on total bacterial load") + labs(fill = "") + ylab("-log10 q-value") + - xlab("Enrichment effect size") + xlab("Enrichment effect size") + + theme( + legend.title = element_blank(), + legend.position = c(1, 1), + legend.justification = c(1, 1), + legend.margin = margin(6, 6, 6, 6) + ) ggsave(pt_B, filename = file.path(save_fig_folder, "B_Volcano_TotalBacteriaVSgeneExpression.pdf"), width = 7, height = 8)