@@ -116,17 +116,21 @@ library(vegan)
116116
117117** Load species abundance, taxonomical annotation and metadata file**
118118
119+ ``` {r}
120+ TRAINING_DIR <- "/workspaces/dsp_metagenomics_training/"
121+ ```
122+
119123``` {r}
120124# Abundance table
121- abundance <- readRDS(file = "../ data/MetaphlanAbundance_Species.rds")
125+ abundance <- readRDS(file = paste0(TRAINING_DIR, " data/MetaphlanAbundance_Species.rds") )
122126rownames(abundance) <- gsub("_SRR_db1.metaphlan", "", rownames(abundance))
123127
124128# Taxonomical annotation
125- annotation <- readRDS(file = "../ data/MetaphlanAnnotations_Species.rds")
129+ annotation <- readRDS(file = paste0(TRAINING_DIR, " data/MetaphlanAnnotations_Species.rds") )
126130
127131# Metadata
128- metadata <- read.table(file = "../ data/metadata.tsv",
129- header = TRUE, sep = "\t",
132+ metadata <- read.table(file = paste0(TRAINING_DIR, " data/metadata.tsv"), header = TRUE ,
133+ sep = "\t",
130134 quote = "",
131135 row.names = NULL)
132136rownames(metadata) <- metadata$Sample
@@ -137,7 +141,7 @@ abundance <- abundance[rownames(metadata), ]
137141
138142# Creating a directory for the PCoA related results
139143``` {r}
140- results_dir <- "../ results/report/02_Beta-diversity"
144+ results_dir <- paste0(TRAINING_DIR, " results/report/02_Beta-diversity/")
141145
142146dir.create(results_dir, recursive = TRUE, showWarnings = FALSE)
143147```
@@ -265,7 +269,7 @@ p <- ggplot(scores,
265269p
266270
267271# Save it as a png
268- ggsave("../results/report/02_Beta-diversity/ 01_PCoA_plot.png",
272+ ggsave(paste0(results_dir, " 01_PCoA_plot.png") ,
269273 width = 8, height = 6, dpi = 300)
270274```
271275
@@ -320,7 +324,7 @@ p <- ggplot(scores,
320324p
321325
322326# Save it as a png
323- ggsave("../results/report/02_Beta-diversity/ 02_PCoA_with_loadings.png",
327+ ggsave(paste0(results_dir, " 02_PCoA_with_loadings.png") ,
324328 width = 8, height = 6, dpi = 300)
325329```
326330
@@ -395,7 +399,7 @@ dispersion_box <- ggplot(dispersion_plot_data, aes(x = group,
395399dispersion_box
396400
397401# Save it as a png
398- ggsave("../results/report/02_Beta-diversity/ 03_dispersion_plot.png",
402+ ggsave(paste0(results_dir, " 03_dispersion_plot.png") ,
399403 width = 6, height = 4, dpi = 300)
400404```
401405
@@ -448,7 +452,7 @@ dispersion_box <- ggplot(dispersion_plot_data,
448452dispersion_box
449453
450454# Save it as a png
451- ggsave("../results/report/02_Beta-diversity/ 04_dispersion_plot_sampling.png",
455+ ggsave(paste0(results_dir, " 04_dispersion_plot_sampling.png") ,
452456 width = 5, height = 4, dpi = 300)
453457```
454458
@@ -481,7 +485,7 @@ adonis_table <- adonis2(form,
481485 by = "margin")
482486
483487write.csv(adonis_table,
484- file = "../results/report/02_Beta-diversity/ 05_Adonis_table.csv",
488+ file = paste0(results_dir, " 05_Adonis_table.csv") ,
485489 row.names = TRUE, quote = FALSE)
486490```
487491
0 commit comments