Skip to content

Commit 735f45d

Browse files
committed
style(scripts): apply Air formatter
1 parent 7902917 commit 735f45d

11 files changed

Lines changed: 906 additions & 479 deletions

02_Diff_analysis/RA_n_Diversity_journal.R

Lines changed: 335 additions & 157 deletions
Large diffs are not rendered by default.

02_Diff_analysis/Volcano_plots_journal.R

Lines changed: 277 additions & 136 deletions
Large diffs are not rendered by default.

02_Diff_analysis/scripts/Alpha_div_calculations.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#!/usr/bin/env Rscript
2-
args <- commandArgs(trailingOnly=TRUE)
2+
args <- commandArgs(trailingOnly = TRUE)
33

4-
if (!require("pacman")) install.packages("pacman")
4+
if (!require("pacman")) {
5+
install.packages("pacman")
6+
}
57

68
pacman::p_load(vegan)
79

810
data_cult <- read.csv(args[1])
911

10-
rownames(data_cult) <- data_cult[,1]
12+
rownames(data_cult) <- data_cult[, 1]
1113

1214
data_cult <- subset(data_cult, select = -Sample_id)
1315

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
#!/usr/bin/env Rscript
2-
args <- commandArgs(trailingOnly=TRUE)
2+
args <- commandArgs(trailingOnly = TRUE)
33

4-
if (!require("pacman")) install.packages("pacman")
4+
if (!require("pacman")) {
5+
install.packages("pacman")
6+
}
57

68
pacman::p_load(Maaslin2)
79

8-
metadata <- read.table(args[1],
9-
sep=',', comment='', head=T)
10+
metadata <- read.table(args[1], sep = ',', comment = '', head = T)
1011

11-
rownames(metadata) <- metadata[,1]
12+
rownames(metadata) <- metadata[, 1]
1213

1314
counts <- read.csv(args[2])
1415

15-
rownames(counts) <- counts[,1]
16+
rownames(counts) <- counts[, 1]
1617

1718
counts <- subset(counts, select = -Sample_id)
1819

19-
fit_data = Maaslin2(input_data = counts,
20-
input_metadata = metadata,
21-
min_prevalence = 0.01,
22-
min_abundance=50000,
23-
normalization = "TSS",
24-
output = args[3],
25-
analysis_method = "LM",
26-
max_significance = 0.05,
27-
correction = "BH",
28-
plot_heatmap = TRUE,
29-
plot_scatter = TRUE,
30-
fixed_effects = c("Group"))
31-
20+
fit_data = Maaslin2(
21+
input_data = counts,
22+
input_metadata = metadata,
23+
min_prevalence = 0.01,
24+
min_abundance = 50000,
25+
normalization = "TSS",
26+
output = args[3],
27+
analysis_method = "LM",
28+
max_significance = 0.05,
29+
correction = "BH",
30+
plot_heatmap = TRUE,
31+
plot_scatter = TRUE,
32+
fixed_effects = c("Group")
33+
)

03_Metagenomes/ABRicate_visualization_journal.R

Lines changed: 80 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
main_dir <- dirname(rstudioapi::getSourceEditorContext()$path)
22
setwd(main_dir)
33

4-
if (!require("pacman"))
4+
if (!require("pacman")) {
55
install.packages("pacman")
6+
}
67

78
pacman::p_load(tidyverse, reshape2, patchwork, ggtext, ggVennDiagram)
89

9-
df_bar_plot <- read.csv("ABRicate_results/summary/tsv/merged_summary.tsv", sep = "\t") %>%
10+
df_bar_plot <- read.csv(
11+
"ABRicate_results/summary/tsv/merged_summary.tsv",
12+
sep = "\t"
13+
) %>%
1014
filter(SAMPLE != "D4") %>%
1115
mutate(
1216
SAMPLE = str_replace(SAMPLE, "D1", "VM1"),
@@ -35,9 +39,14 @@ barplot <- df_bar_plot_long %>%
3539
color = "gray"
3640
) +
3741
geom_vline(
38-
xintercept = seq(1.5, length(unique(
39-
df_bar_plot_long$SAMPLE
40-
)) - 0.5, by = 1),
42+
xintercept = seq(
43+
1.5,
44+
length(unique(
45+
df_bar_plot_long$SAMPLE
46+
)) -
47+
0.5,
48+
by = 1
49+
),
4150
linetype = "dashed",
4251
color = "black"
4352
) +
@@ -54,8 +63,10 @@ barplot <- df_bar_plot_long %>%
5463
labels = c("CARD", "ResFinder", "VFDB"),
5564
values = c("#8DA0CB", '#FC8D62', "#66C2A5")
5665
) +
57-
theme(legend.title = element_text(size = 14),
58-
legend.text = element_text(size = 14)) +
66+
theme(
67+
legend.title = element_text(size = 14),
68+
legend.text = element_text(size = 14)
69+
) +
5970
geom_text(
6071
aes(label = number),
6172
position = position_dodge(width = 0.9),
@@ -114,14 +125,17 @@ df_card_long <- melt(
114125
) %>%
115126
filter(ARG != "NUM FOUND")
116127

117-
heatmap_card <- ggplot(df_card_long, aes(x = SAMPLE, y = ARG, fill = presence)) +
118-
geom_tile(color = "black",
119-
linewidth = 0.25,
120-
show.legend = FALSE) +
121-
scale_fill_manual(#name = "ARG presence",
128+
heatmap_card <- ggplot(
129+
df_card_long,
130+
aes(x = SAMPLE, y = ARG, fill = presence)
131+
) +
132+
geom_tile(color = "black", linewidth = 0.25, show.legend = FALSE) +
133+
scale_fill_manual(
134+
#name = "ARG presence",
122135
breaks = c("plus", "minus"),
123136
#labels = c("Present", "Absent"),
124-
values = c("#8DA0CB", "white")) +
137+
values = c("#8DA0CB", "white")
138+
) +
125139
theme_classic() +
126140
labs(x = NULL, y = NULL) +
127141
theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -170,14 +184,17 @@ df_resfinder_long <- melt(
170184
df_resfinder_long <- df_resfinder_long %>%
171185
mutate(ARG = word(ARG, 1))
172186

173-
heatmap_resfinder <- ggplot(df_resfinder_long, aes(x = SAMPLE, y = ARG, fill = presence)) +
174-
geom_tile(color = "black",
175-
linewidth = 0.25,
176-
show.legend = FALSE) +
177-
scale_fill_manual(#name = "ARG presence",
187+
heatmap_resfinder <- ggplot(
188+
df_resfinder_long,
189+
aes(x = SAMPLE, y = ARG, fill = presence)
190+
) +
191+
geom_tile(color = "black", linewidth = 0.25, show.legend = FALSE) +
192+
scale_fill_manual(
193+
#name = "ARG presence",
178194
breaks = c("plus", "minus"),
179195
#labels = c("Present", "Absent"),
180-
values = c("#FC8D62", "white")) +
196+
values = c("#FC8D62", "white")
197+
) +
181198
theme_classic() +
182199
labs(x = NULL, y = NULL) +
183200
theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -232,8 +249,18 @@ n_col_part3 <- 104
232249

233250
# Split the dataframe into three parts
234251
df_vfdb_part1 <- cbind(SAMPLE, df_vfdb_no_sample[, 1:n_col_part1])
235-
df_vfdb_part2 <- cbind(SAMPLE, df_vfdb_no_sample[, (n_col_part1 + 1):(n_col_part1 + n_col_part2)])
236-
df_vfdb_part3 <- cbind(SAMPLE, df_vfdb_no_sample[, (n_col_part1 + n_col_part2 + 1):(n_col_part1 + n_col_part2 + n_col_part3)])
252+
253+
df_vfdb_part2 <- cbind(
254+
SAMPLE,
255+
df_vfdb_no_sample[, (n_col_part1 + 1):(n_col_part1 + n_col_part2)]
256+
)
257+
258+
df_vfdb_part3 <- cbind(
259+
SAMPLE,
260+
df_vfdb_no_sample[,
261+
(n_col_part1 + n_col_part2 + 1):(n_col_part1 + n_col_part2 + n_col_part3)
262+
]
263+
)
237264

238265
# VFDB: PART 1 #
239266

@@ -244,14 +271,17 @@ df_vfdb_part1_long <- melt(
244271
value.name = "presence"
245272
)
246273

247-
heatmap_vfdb_part1 <- ggplot(df_vfdb_part1_long, aes(x = SAMPLE, y = ARG, fill = presence)) +
248-
geom_tile(color = "black",
249-
linewidth = 0.25,
250-
show.legend = FALSE) +
251-
scale_fill_manual(#name = "ARG presence",
274+
heatmap_vfdb_part1 <- ggplot(
275+
df_vfdb_part1_long,
276+
aes(x = SAMPLE, y = ARG, fill = presence)
277+
) +
278+
geom_tile(color = "black", linewidth = 0.25, show.legend = FALSE) +
279+
scale_fill_manual(
280+
#name = "ARG presence",
252281
breaks = c("plus", "minus"),
253282
#labels = c("Present", "Absent"),
254-
values = c("#66C2A5", "white")) +
283+
values = c("#66C2A5", "white")
284+
) +
255285
theme_classic() +
256286
labs(x = NULL, y = NULL) +
257287
theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -266,14 +296,17 @@ df_vfdb_part2_long <- melt(
266296
value.name = "presence"
267297
)
268298

269-
heatmap_vfdb_part2 <- ggplot(df_vfdb_part2_long, aes(x = SAMPLE, y = ARG, fill = presence)) +
270-
geom_tile(color = "black",
271-
linewidth = 0.25,
272-
show.legend = FALSE) +
273-
scale_fill_manual(#name = "ARG presence",
299+
heatmap_vfdb_part2 <- ggplot(
300+
df_vfdb_part2_long,
301+
aes(x = SAMPLE, y = ARG, fill = presence)
302+
) +
303+
geom_tile(color = "black", linewidth = 0.25, show.legend = FALSE) +
304+
scale_fill_manual(
305+
#name = "ARG presence",
274306
breaks = c("plus", "minus"),
275307
#labels = c("Present", "Absent"),
276-
values = c("#66C2A5", "white")) +
308+
values = c("#66C2A5", "white")
309+
) +
277310
theme_classic() +
278311
labs(x = NULL, y = NULL) +
279312
theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -288,22 +321,27 @@ df_vfdb_part3_long <- melt(
288321
value.name = "presence"
289322
)
290323

291-
heatmap_vfdb_part3 <- ggplot(df_vfdb_part3_long, aes(x = SAMPLE, y = ARG, fill = presence)) +
292-
geom_tile(color = "black",
293-
linewidth = 0.25,
294-
show.legend = FALSE) +
295-
scale_fill_manual(#name = "ARG presence",
324+
heatmap_vfdb_part3 <- ggplot(
325+
df_vfdb_part3_long,
326+
aes(x = SAMPLE, y = ARG, fill = presence)
327+
) +
328+
geom_tile(color = "black", linewidth = 0.25, show.legend = FALSE) +
329+
scale_fill_manual(
330+
#name = "ARG presence",
296331
breaks = c("plus", "minus"),
297332
#labels = c("Present", "Absent"),
298-
values = c("#66C2A5", "white")) +
333+
values = c("#66C2A5", "white")
334+
) +
299335
theme_classic() +
300336
labs(x = NULL, y = NULL) +
301337
theme(axis.line = element_blank(), axis.text = element_markdown())
302338
#axis.text.x = element_text(size=18, angle=35, hjust=1)
303339

304340
# VFDB: ALLTOGETHER #
305341

306-
VFDB_combined <- heatmap_vfdb_part1 + heatmap_vfdb_part2 + heatmap_vfdb_part3 &
342+
VFDB_combined <- heatmap_vfdb_part1 +
343+
heatmap_vfdb_part2 +
344+
heatmap_vfdb_part3 &
307345
plot_annotation(tag_levels = list(c("A", "B", "C")))
308346

309347
ggsave(
@@ -388,7 +426,8 @@ ggsave(
388426
resfinder_venn <- (heatmap_resfinder / venn_diag) +
389427
plot_layout(heights = c(11, 3))
390428

391-
wombo_ultra <- (free(barplot, type = "label") / (heatmap_card + resfinder_venn)) +
429+
wombo_ultra <- (free(barplot, type = "label") /
430+
(heatmap_card + resfinder_venn)) +
392431
plot_layout(heights = c(3, 14))
393432

394433
wombo_ultra_combo <- (wombo_ultra | VFDB_combined) +

03_Metagenomes/HUMAnN3_heatmaps_journal.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
main_dir <- dirname(rstudioapi::getSourceEditorContext()$path)
22
setwd(main_dir)
33

4-
if (!require("pacman"))
4+
if (!require("pacman")) {
55
install.packages("pacman")
6+
}
67

78
pacman::p_load(tidyverse, reshape2, ggtext)
89

9-
df_heatmap <- read.csv("HUMAnN3_results/pathabundance_filtered_normalized.tsv",
10-
sep = "\t")
10+
df_heatmap <- read.csv(
11+
"HUMAnN3_results/pathabundance_filtered_normalized.tsv",
12+
sep = "\t"
13+
)
1114

1215
df_heatmap_long <- melt(
1316
df_heatmap,
@@ -28,14 +31,18 @@ df_heatmap_long <- melt(
2831
) %>%
2932
mutate(
3033
Pathway = case_when(
31-
Pathway == "PWY4LZ-257: superpathway of fermentation (Chlamydomonas reinhardtii)" ~
34+
Pathway ==
35+
"PWY4LZ-257: superpathway of fermentation (Chlamydomonas reinhardtii)" ~
3236
"PWY4LZ-257: superpathway of fermentation (*Chlamydomonas reinhardtii*)",
3337
TRUE ~ Pathway
3438
)
3539
) %>%
3640
filter(!Sample %in% c("NN3", "VM3"))
3741

38-
heatmap <- ggplot(df_heatmap_long, aes(x = Sample, y = Pathway, fill = Abundance)) +
42+
heatmap <- ggplot(
43+
df_heatmap_long,
44+
aes(x = Sample, y = Pathway, fill = Abundance)
45+
) +
3946
geom_tile(color = "black", linewidth = 0.25) +
4047
scale_fill_gradientn(
4148
colors = c(

0 commit comments

Comments
 (0)