-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelative_abundance_plots_fungi.R
113 lines (96 loc) · 2.16 KB
/
relative_abundance_plots_fungi.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#### Setup ####
source("scripts/00_helperfunctions/alx_OutOfSight.R")
inputfolder <- "../data/processed"
figfolder <- "../results/output_figures/fungi"
dir.create(figfolder, showWarnings = FALSE)
if ( !require("phyloseq", quietly = TRUE) )
BiocManager::install("phyloseq")
# install additional color scales
if ( !require("RColorBrewer", quietly = TRUE) )
BiocManager::install("RColorBrewer")
# install more convenient color scales
if ( !require("pals", quietly = TRUE) )
BiocManager::install("pals")
#### Read data ####
fungi <- readRDS(
paste0(inputfolder,
"/fungi_keep.rds")
)
#### Phylum plot ####
ps_plot_bar(
fungi,
group = "Country",
taxrank = "Phylum",
top = 10,
title="Fungi: Top 10 Phyla per country (averaged)",
xlab.rel = 0.8
)
ggsave(
filename = paste0(figfolder,"/Phylum_relative_abundance_top10.png"),
width = 6,
height = 4,
dpi = 300
)
#### Class plot ####
ps_plot_bar(
fungi,
group = "Country",
taxrank = "Class",
top = 14,
title="Fungi: Top 14 Class per country (averaged)",
xlab.rel = 0.8
)
ggsave(
filename = paste0(figfolder,"/Class_relative_abundance_top14.png"),
width = 9,
height = 6,
dpi = 300
)
#### Order plot ####
ps_plot_bar(
fungi,
group = "Country",
taxrank = "Order",
top = 30,
title="Fungi: Top 30 Order per country (averaged)",
xlab.rel = 0.8
) +
theme(legend.key.size = unit(0.4, 'cm'))
ggsave(
filename = paste0(figfolder,"/Order_relative_abundance_top30.png"),
width = 9,
height = 6,
dpi = 300
)
#### Family plot ####
ps_plot_bar(
fungi,
group = "Country",
taxrank = "Family",
top = 30,
title="Fungi: Top 30 Family per country (averaged)",
xlab.rel = 0.8
) +
theme(legend.key.size = unit(0.4, 'cm'))
ggsave(
filename = paste0(figfolder,"/Family_relative_abundance_top30.png"),
width = 9,
height = 6,
dpi = 300
)
#### Genus plot ####
ps_plot_bar(
fungi,
group = "Country",
taxrank = "Genus",
top = 35,
title="Fungi: Top 35 Genus per country (averaged)",
xlab.rel = 0.8
) +
theme(legend.key.size = unit(0.4, 'cm'))
ggsave(
filename = paste0(figfolder,"/Genus_relative_abundance_top35.png"),
width = 9,
height = 7,
dpi = 300
)