Skip to content

Commit

Permalink
minor fixes in the appearance of the plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Springer committed Mar 15, 2024
1 parent 002149b commit b4caf00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
15 changes: 8 additions & 7 deletions src/plotting/ExtendedDataFigure2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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


Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/plotting/ExtendedDataFigure4.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----
Expand Down
2 changes: 1 addition & 1 deletion src/plotting/ExtendedDataFigure6.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/plotting/Figure2.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions src/plotting/Figure3.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand All @@ -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)

Expand Down

0 comments on commit b4caf00

Please sign in to comment.