From 831b88e4573320b809a3160de489c0586a775d6e Mon Sep 17 00:00:00 2001 From: Iara Souza Date: Wed, 8 May 2024 14:02:05 -0300 Subject: [PATCH] fix: changed the figure 1 and 3 --- scripts/metadata.R | 4 ++++ scripts/network.R | 11 ++++------- scripts/plots.rmd | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/scripts/metadata.R b/scripts/metadata.R index 3a672e1..7e85ed0 100644 --- a/scripts/metadata.R +++ b/scripts/metadata.R @@ -27,12 +27,16 @@ ann$rin <- scale(ann$rin)[,1] rownames(ann) <- ann$sample_id ann$sample_id <- NULL +# Keep the full dataframe +ann_full <- ann + # Remove samples "SRR5961961" and "SRR5961809" that appeared as outliers on robust pca analysis ann <- ann %>% filter(!(rownames(ann) %in% c("SRR5961961", "SRR5961809"))) # Save (this metadata will be used in all future models) save(ann, file = "results/important_variables/ann.rda") +save(ann_full, file = "results/important_variables/ann_full.rda") diff --git a/scripts/network.R b/scripts/network.R index 886be1b..34eefc4 100644 --- a/scripts/network.R +++ b/scripts/network.R @@ -82,9 +82,6 @@ addGraph(rdp, g) nodes <- read_tsv("results/networks/model_nodes.txt") edges <- read_delim("results/networks/model_edges.txt") -nodes <- read_tsv("~/model_nodes.txt") -edges <- read_delim("~/model_edges.txt") - # Import nodes coordinates determined by vivagraph layout <- read.csv("results/networks/layout.csv") @@ -109,16 +106,16 @@ ggraph(g, x = x, y = y) + data = as_data_frame(g, "vertices") %>% filter(gwas == "gwas"), colour = NA, n = 5, - pie_scale = 0.5, + pie_scale = 0.9, show.legend = F) + geom_scatterpie( cols = c("a", "b", "c"), data = as_data_frame(g, "vertices") %>% filter(gwas == "not_gwas"), colour = NA, - pie_scale = 0.2, + pie_scale = 0.3, show.legend = F ) + - geom_node_text(aes(label = alias), size = 0.9, nudge_x = 2, nudge_y = 4) + + #geom_node_text(aes(label = alias), size = 1.7, nudge_x = 2, nudge_y = 4) + #geom_node_label(aes(label = alias)) + scale_fill_manual(values = c("#0ac80aff", "#4f4affff", "#ff822fff")) + coord_fixed() + @@ -130,7 +127,7 @@ if(!dir.exists("results/plots_paper/")) { dir.create("results/plots_paper") } -svg(filename = "results/plots_paper/network.svg", height = 10, width = 10) +pdf(file = "~/Área de Trabalho/network.pdf", height = 15, width = 15) print(p) dev.off() diff --git a/scripts/plots.rmd b/scripts/plots.rmd index c79293d..5f81e80 100644 --- a/scripts/plots.rmd +++ b/scripts/plots.rmd @@ -355,9 +355,45 @@ ggsave("results/plots_paper/fig2C_2.png", height = 4, width = 5, dpi = 300) ``` -## Figure 3 +# Figure 3 -Figure 3 was produced on the biotype analysis, in the `summarise_biotypes.R` script. +```{r} +# Load enrichment data +load("results/tx_enrich/go_terms_tx_by_group.rda") + +# Create a dataframe with results from OFC (female) and CG25 (male) enrichment +df_enrich <- bind_rows(enriched_df_diff[["OFC_female"]], enriched_df_diff[["Cg25_male"]]) + +# Parse gene ratio column +df_enrich <- df_enrich %>% mutate( + n_tag = as.numeric(sapply(strsplit(GeneRatio, split = "\\/"), "[[", 2)), + GeneRatio = as.numeric(Count) / n_tag +) + +# Plot +df_enrich %>% + ggplot(aes(x = fct_reorder2(Description, -p.adjust, -Count), y = GeneRatio, size = Count, col = p.adjust)) + + geom_point() + + facet_grid(rows = vars(group), scales = "free_y", space = "free_y", + labeller = as_labeller(c( + "Cg25_male" = "Cg25 (male)", + "OFC_female" = "OFC (female)" + ))) + + force_panelsizes(rows = c(0.17, 1)) + + scale_color_continuous(limits = c(0, 0.05), breaks = seq(0, 0.05, 0.01)) + + labs(x = "", y = "Gene ratio", color = "FDR", size = "Intersection") + + coord_flip() + + theme_bw() + + theme(axis.text.y = element_text(size = 9), + strip.text.y = element_text(size = 9)) + +ggsave(filename = "results/plots_paper/fig3.pdf", width = 9, height = 6) +ggsave(filename = "results/plots_paper/fig3.png", width = 9, height = 6) +``` + +## Figure 4 + +Figure 4 was produced on the biotype analysis, in the `summarise_biotypes.R` script. # Supplementary Figures