-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
489 lines (489 loc) · 19.9 KB
/
.Rhistory
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
q()
library(DESeq2)
q()
5 + 2
## Load required libraries
library(DESeq2)
knitr::opts_chunk$set(echo = T)
knitr::opts_chunk$set(message=F)
knitr::opts_chunk$set(warning=F)
knitr::opts_chunk$set(comment = NA)
knitr::opts_chunk$set(fig.width=9, fig.height=9)
knitr::opts_chunk$set(error = TRUE)
## Load required libraries
library(DESeq2)
library(data.table)
library(tidyverse)
library(vegan)
library(lmPerm)
library(viridis)
library(grid)
library(gridExtra)
library(cowplot)
library(devtools)
install_github("eastmallingresearch/Metabarcoding_pipeline/scripts")
library(metafuncs)
TAXCONF = 0.6 # Sets the taxonomy confidence level to get "rank" in taxonomy files
TOPOTU = 10 # Number of Top OTUs for summary information
# Run constants
Factor1 = "trial"
Factor2 = "cultivar"
design = x ~ trial / block + planting_date * cultivar
# colour blind palette
cbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
## Custom functions
gfunc <- function(countData,colData,title) {
#### Rarefaction curve plotter ####
colData <- colData[names(countData),]
# descending order each sample
DT <- data.table(apply(countData,2,sort,decreasing=T))
# get cummulative sum of each sample
DT <- cumsum(DT)
# log the count values
DT <- log10(DT)
# set values larger than maximum for each column to NA
DT <- data.table(apply(DT,2,function(x) {x[(which.max(x)+1):length(x)]<- NA;x}))
# remove rows with all NA
DT <- DT[rowSums(is.na(DT)) != ncol(DT), ]
# add a count column to the data table
DT$x <- seq(1,nrow(DT))
# melt the data table for easy plotting
MDT <- melt(DT,id.vars="x")
# create an empty ggplot object from the data table
g <- ggplot(data=MDT,aes(x=x,y=value,colour=variable))
# remove plot background and etc.
g <- g + theme_classic_thin() %+replace%
theme(legend.position="none",axis.title=element_blank())
# plot cumulative reads
g <- g + geom_line(size=1.5) + scale_colour_viridis(discrete=T)
# add axis lables
g <- g + ggtitle(title)
#g <- g + ylab(expression("Log"[10]*" aligned sequenecs"))+xlab("OTU count")
# print the plot
g
}
metadata <- "sample_metadata.txt"
# Load
#ubiome_BAC <- loadData("data/BAC.otu_table.txt",metadata,"data/BAC.sintax.taxa",RHB="BAC")
#ubiome_FUN <- loadData("data/FUN.otu_table.txt",metadata,"data/FUN.sintax.taxa",RHB="FUN")
ubiome_BAC <- loadData("data/BAC.zotu_table.txt",metadata,"data/zBAC.sintax.taxa",RHB="BAC")
ubiome_FUN <- loadData("data/FUN.zotu_table.txt",metadata,"data/zFUN.sintax.taxa",RHB="FUN")
# Filter Plant, Chloroplast, and Eukaryote OTUs
# Fungi: Plantae OTUs
cat("Fungi:", length(grep("Plantae", ubiome_FUN$taxData$kingdom)), "Plantae OTUs\n")
# Bacteria: Chloroplast (Streptophyta) and Eukaryote OTUs
cat(
"Bacteria:", length(grep("Streptophyta",ubiome_BAC$taxData$genus)), "Chloroplast OTUs;",
length(grep("Eukaryota",ubiome_BAC$taxData$kingdom)), "Eukaryote OTUs\n"
)
# Filter Chloroplast and Eukaryote
filt <- rownames(
ubiome_BAC$taxData[
grepl("Streptophyta", ubiome_BAC$taxData$genus) &
as.numeric(ubiome_BAC$taxData$g_conf) >= TAXCONF,
]
)
filt <- c(filt, rownames(ubiome_BAC$taxData[grep("Eukaryota", ubiome_BAC$taxData$kingdom), ]))
cat("Bacteria: removing",length(filt),"OTUs")
ubiome_BAC$taxData <- ubiome_BAC$taxData[!rownames(ubiome_BAC$taxData) %in% filt,]
ubiome_BAC$countData <- ubiome_BAC$countData[!rownames(ubiome_BAC$countData) %in% filt,]
# filtered for minimum of 1000 reads
ubiome_FUN$dds <- ubiom_to_des(ubiome_FUN,filter=expression(colSums(countData)>=1000))
ubiome_BAC$dds <- ubiom_to_des(ubiome_BAC,filter=expression(colSums(countData)>=1000))
invisible(mapply(assign, names(ubiome_BAC), ubiome_BAC, MoreArgs = list(envir = globalenv())))
rare_bac <- gfunc(as.data.frame(counts(dds)), as.data.frame(colData(dds)), "Bacteria ZOTU")
invisible(mapply(assign, names(ubiome_FUN), ubiome_FUN, MoreArgs = list(envir = globalenv())))
rare_fun <- gfunc(as.data.frame(counts(dds)), as.data.frame(colData(dds)), "Fungi ZOTU")
rarefaction_plots <- grid.arrange(
rare_bac, rare_fun,
left = textGrob(label = expression("Log"[10] * " aligned sequenecs"), rot = 90),
bottom = "ZOTU count", nrow = 2
)
ggsave(filename = "rarefaction_plots.png", plot = rarefaction_plots, path = "figures/")
rarefaction_plots
View(rarefaction_plots)
globalenv()
# Fungi
invisible(mapply(assign,names(ubiome_FUN),ubiome_FUN,MoreArgs=list(envir=globalenv())))
print(
"Raw reads","\n\n",
"Total raw reads:\t\t", sum(countData),"\n",
"Mean raw reads per sample:\t", mean(colSums(countData)),"\n",
"Median raw reads per sample:", median(colSums(countData)),"\n",
"Max raw reads per sample:\t", max(colSums(countData)),"\n\n",
"Min raw reads per sample:\t", min(colSums(countData)),"\n"
)
cat(
"Raw reads","\n\n",
"Total raw reads:\t\t", sum(countData),"\n",
"Mean raw reads per sample:\t", mean(colSums(countData)),"\n",
"Median raw reads per sample:", median(colSums(countData)),"\n",
"Max raw reads per sample:\t", max(colSums(countData)),"\n\n",
"Min raw reads per sample:\t", min(colSums(countData)),"\n"
)
cat(
"Raw reads","\n\n",
"Total raw reads:\t\t", sum(countData),"\n",
"Mean raw reads per sample:\t", mean(colSums(countData)),"\n",
"Median raw reads per sample:\t", median(colSums(countData)),"\n",
"Max raw reads per sample:\t", max(colSums(countData)),"\n",
"Min raw reads per sample:\t", min(colSums(countData)),"\n"
)
#colSums(countData)
nct <- counts(dds,normalize=T)
cat("Normalised reads","\n\n",
"Total normalised reads:\t\t", sum(nct),"\n",
"Mean normalised reads per sample:\t", mean(colSums(nct)),"\n",
"Median normalised reads per sample:\t", median(colSums(nct)),"\n",
"Min normalised reads per sample:\t", min(colSums(nct)),"\n",
"Max normalised reads per sample:\t", max(colSums(nct)),"\n\n"
)
colSums(countData)
round(colSums(counts(dds,normalize=T)),0)
cat(
"Total OTUs:\t\t", nrow(taxData),"\n\n",
"Raw reads per OTU summary", "\n\n",
"Mean raw reads per OTU:\t", mean(rowSums(countData)),"\n",
"Median raw per OTU:\t", median(rowSums(countData)),"\n",
"OTU raw Min reads:\t\t", min(rowSums(countData)),"\n",
"OTU raw Max reads:\t\t", max(rowSums(countData)),"\n\n"
)
cat(
"Total OTUs:\t\t", nrow(taxData),"\n\n",
"Raw reads per OTU summary", "\n\n",
"Mean raw reads per OTU:\t", mean(rowSums(countData)),"\n",
"Median raw per OTU:\t\t", median(rowSums(countData)),"\n",
"OTU raw Min reads:\t\t", min(rowSums(countData)),"\n",
"OTU raw Max reads:\t\t", max(rowSums(countData)),"\n\n"
)
cat(
"Normalised reads per OTU summary","\n\n",
"Mean normalised reads per OTU:\t", mean(rowSums(nct)),"\n",
"Median normalised reads per OTU:\t", median(rowSums(nct)),"\n",
"OTU normalised Min reads:\t\t", min(rowSums(nct)),"\n",
"OTU normalised Max reads:\t\t", max(rowSums(nct)),"\n\n"
)
cat(
"Normalised reads per OTU summary","\n\n",
"Mean normalised reads per OTU:\t\t", mean(rowSums(nct)),"\n",
"Median normalised reads per OTU:\t", median(rowSums(nct)),"\n",
"OTU normalised Min reads:\t\t", min(rowSums(nct)),"\n",
"OTU normalised Max reads:\t\t", max(rowSums(nct)),"\n\n"
)
cat(
"Total OTUs:\t\t", nrow(taxData),"\n\n",
"Raw reads per OTU summary", "\n\n",
"Mean raw reads per OTU:\t", mean(rowSums(countData)),"\n",
"Median raw per OTU:\t\t", median(rowSums(countData)),"\n",
"OTU raw Min reads:\t\t", min(rowSums(countData)),"\n",
"OTU raw Max reads:\t\t", max(rowSums(countData)),"\n\n"
)
cat(
"Normalised reads per OTU summary","\n\n",
"Mean normalised reads per OTU:\t\t", mean(rowSums(nct)),"\n",
"Median normalised reads per OTU:\t", median(rowSums(nct)),"\n",
"OTU normalised Min reads:\t\t", min(rowSums(nct)),"\n",
"OTU normalised Max reads:\t\t", max(rowSums(nct)),"\n\n"
)
y <- rowSums(nct)
y <- y[order(y,decreasing = T)]
# proportion
xy <- y/sum(y)
cat("Total " ,TOPOTU,"OTUs:\n")
data.frame(counts=y[1:TOPOTU],Prop=xy[1:TOPOTU],rank=taxData[names(y)[1:TOPOTU],]$rank)
cat(
"Total OTUs:\t\t", nrow(taxData),"\n\n",
"Raw reads per OTU summary", "\n\n",
"Mean raw reads per OTU:\t", mean(rowSums(countData)),"\n",
"Median raw per OTU:\t\t", median(rowSums(countData)),"\n",
"OTU raw Min reads:\t\t", min(rowSums(countData)),"\n",
"OTU raw Max reads:\t\t", max(rowSums(countData)),"\n\n"
)
cat(
"Normalised reads per OTU summary","\n\n",
"Mean normalised reads per OTU:\t\t", mean(rowSums(nct)),"\n",
"Median normalised reads per OTU:\t", median(rowSums(nct)),"\n",
"OTU normalised Min reads:\t\t", min(rowSums(nct)),"\n",
"OTU normalised Max reads:\t\t", max(rowSums(nct)),"\n\n"
)
y <- rowSums(nct)
y <- y[order(y,decreasing = T)]
# proportion
xy <- y/sum(y)
cat("Top " ,TOPOTU, "OTUs:\n")
data.frame(counts=y[1:TOPOTU],Prop=xy[1:TOPOTU],rank=taxData[names(y)[1:TOPOTU],]$rank)
# Proportion of OTUs which can be assigned (with the given confidence) at each taxonomic rank
tx <- copy(taxData)
setDT(tx)
cols <- names(tx)[9:15]
tx[,(cols):=lapply(.SD,as.factor),.SDcols=cols]
data.table(
rank=c("kingdom","phylum","class","order","family","genus","species"),
"0.8"=round(unlist(lapply(cols,function(col) sum(as.number(tx[[col]])>=0.8)/nrow(tx))),2),
"0.65"=round(unlist(lapply(cols,function(col) sum(as.number(tx[[col]])>=0.65)/nrow(tx))),2),
"0.5"=round(unlist(lapply(cols,function(col) sum(as.number(tx[[col]])>=0.5)/nrow(tx))),2)
)
tx <-taxData[rownames(dds),]
nc <- counts(dds,normalize=T)
ac <- sum(nc)
data.table(
rank=c("kingdom","phylum","class","order","family","genus","species"),
"0.8"=round(unlist(lapply(cols ,function(col)(sum(nc[which(as.numeric(tx[[col]])>=0.8),])/ac *100))),2),
"0.65"=round(unlist(lapply(cols,function(col)(sum(nc[which(as.numeric(tx[[col]])>=0.65),])/ac *100))),2),
"0.5"=round(unlist(lapply(cols,function(col)(sum(nc[which(as.numeric(tx[[col]])>=0.5),])/ac *100))),2)
)
design <- x ~ trial / block + planting_date * cultivar # + Error(Plot)
# get the diversity index data
all_alpha_ord <- plot_alpha(counts(dds,normalize=T),colData(dds),design="trial",returnData=T)
# join diversity indices and metadata
all_alpha_ord <- all_alpha_ord[
as.data.table(colData(dds), keep.rownames = "Samples"),
on = "Samples"
]
all_alpha_ord[, trial.block := as.factor(paste0(trial, block))]
design <- x ~ trial + trial.block + planting_date * cultivar
design <- x ~ trial / block + planting_date * cultivar # + Error(Plot)
setkey(all_alpha_ord, S.chao1)
all_alpha_ord[, measure := as.numeric(as.factor(S.chao1))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
all_alpha_ord[, trial.block := as.factor(paste0(trial, block))]
design <- x ~ trial + trial.block + planting_date * cultivar
setkey(all_alpha_ord, S.chao1)
all_alpha_ord[, measure := as.numeric(as.factor(S.chao1))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
design <- x ~ trial / trial.block + planting_date * cultivar
setkey(all_alpha_ord, S.chao1)
all_alpha_ord[, measure := as.numeric(as.factor(S.chao1))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
setkey(all_alpha_ord,shannon)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
design <- x ~ trial / trial.block + trial *planting_date * cultivar
setkey(all_alpha_ord,shannon)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
design <- x ~ trial / block + trial *planting_date * cultivar
setkey(all_alpha_ord,shannon)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
colData(dds)
View(colData(dds))
all_alpha_ord
# get the diversity index data
all_alpha_ord <- plot_alpha(counts(dds,normalize=T),colData(dds),design="trial",returnData=T)
# join diversity indices and metadata
all_alpha_ord <- all_alpha_ord[
as.data.table(colData(dds), keep.rownames = "Samples"),
on = "Samples"
]
all_alpha_ord[, trial.block := as.factor(paste0(trial, block))]
design <- x ~ trial / trial.block + trial *planting_date * cultivar
setkey(all_alpha_ord, S.chao1)
all_alpha_ord[, measure := as.numeric(as.factor(S.chao1))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
setkey(all_alpha_ord,shannon)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
design <- x ~ + trial * planting_date * cultivar + trial:trial.block
setkey(all_alpha_ord,shannon)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
# get the diversity index data
all_alpha_ord <- plot_alpha(counts(dds,normalize=T),colData(dds),design="trial",returnData=T)
# join diversity indices and metadata
all_alpha_ord <- all_alpha_ord[
as.data.table(colData(dds), keep.rownames = "Samples"),
on = "Samples"
]
all_alpha_ord[, trial.block := as.factor(paste0(trial, block))]
design <- x ~ + trial * planting_date * cultivar + trial / trial.block
setkey(all_alpha_ord, S.chao1)
all_alpha_ord[, measure := as.numeric(as.factor(S.chao1))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
setkey(all_alpha_ord,shannon)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
setkey(all_alpha_ord,simpson)
all_alpha_ord[,measure:=as.numeric(as.factor(shannon))]
summary(aovp(update(design,measure~.),all_alpha_ord,seqs=T))
dds <- dds[rowSums(counts(dds, normalize=T))>5,]
### PCA ###
# perform PC decomposition of DES object
mypca <- des_to_pca(dds)
# to get pca plot axis into the same scale create a dataframe of PC scores multiplied by their variance
d <-t(data.frame(t(mypca$x)*mypca$percentVar))
round(mypca$percentVar[1:4],3)
apply(mypca$x[,1:4],2,function(x){
summary(aov(update(design,x~.),data=as.data.frame(cbind(x,colData(dds)))))
})
q()
.vsc.attach()
## Load required libraries
library(DESeq2)
library(data.table)
library(tidyverse)
library(vegan)
library(lmPerm)
library(viridis)
library(grid)
library(gridExtra)
library(cowplot)
library(devtools)
install_github("eastmallingresearch/Metabarcoding_pipeline/scripts")
library(metafuncs)
q()
# library(car)
library(cowplot)
library(data.table)
library(DESeq2)
library(DHARMa)
library(ggpubr)
library(grid)
library(gridExtra)
library(iNEXT)
library(kableExtra)
library(knitr)
library(lmPerm)
library(MASS)
library(pscl)
# library(rcompanion)
library(seqinr)
library(tidyverse)
library(vegan)
library(viridis)
# devtools::install_github("eastmallingresearch/Metabarcoding_pipeline/scripts")
library(metafuncs)
load("FUN.RData")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-word;") %>%
kable_save("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-word;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-word; width: 20%;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-word; width: 200%;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-all; width: 200%;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-all; width: 10cm;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = T) %>%
column_spec(3, extra_css = "word-wrap: break-all; white-space: normal; width: 10cm;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs[, c("Site", "ASV", "Taxonomy", "Abundance", "coef", "var", "p_adjusted")] %>%
kbl("html", digits = 3) %>%
kable_styling("striped", full_width = F) %>%
column_spec(3, extra_css = "word-wrap: break-all; white-space: normal; width: 10cm;") %>%
save_kable("tables/FUN_canker_site_asvs.html")
significant_asvs$Taxonomy
significant_asvs$Taxonomy %>% unlist
load("BAC.RData")
alpha_box <- ggboxplot(
data = alpha_combined, x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = c("measure", "kingdom"),
palette = cbPalette, scales = "free_y", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
) #+ guides(color = guide_legend(position = "right"))
alpha_combined <- rbind(fun_alpha, bac_alpha) %>%
subset(select = c("Site", "Storage", "Scion", "Target", "S.chao1", "shannon", "simpson")) %>%
mutate(kingdom = ifelse(Target == "ITS", "Fungi", "Bacteria")) %>%
mutate(kingdom = factor(kingdom, levels = c("Fungi", "Bacteria"))) %>%
mutate(Storage = factor(Storage, levels = c("no", "yes"))) %>%
rename(Chao1 = S.chao1, Shannon = shannon, Simpson = simpson) %>%
pivot_longer(
cols = c("Chao1", "Shannon", "Simpson"), names_to = "measure", values_to = "value"
)
alpha_box <- ggboxplot(
data = alpha_combined, x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = c("measure", "kingdom"),
palette = cbPalette, scales = "free_y", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
) #+ guides(color = guide_legend(position = "right"))
ggsave(
filename = "alpha_box.png", plot = alpha_box, path = "figures/",
height = 24, width = 24, units = "cm"
)
alpha_box_fungi <- ggboxplot(
data = alpha_combined[alpha_combined$kingdom == "Fungi", ], x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = "measure",
palette = cbPalette, scales = "free_y", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
)
ggsave(
filename = "alpha_box_fungi.png", plot = alpha_box_fungi, path = "figures/",
height = 12, width = 24, units = "cm"
)
alpha_box_bacteria <- ggboxplot(
data = alpha_combined[alpha_combined$kingdom == "Bacteria", ], x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = "measure",
palette = cbPalette, scales = "free_y", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
)
ggsave(
filename = "alpha_box_bacteria.png", plot = alpha_box_bacteria, path = "figures/",
height = 12, width = 24, units = "cm"
)
alpha_box_combined <- ggarrange(
alpha_box_fungi, alpha_box_bacteria,
ncol = 1, nrow = 2, labels = c("A", "B"),
common.legend = T, legend = "bottom"
)
ggsave(
filename = "alpha_box_combined.png", plot = alpha_box_combined, path = "figures/",
height = 24, width = 24, units = "cm"
)
ggsave(
filename = "alpha_box_combined.png", plot = alpha_box_combined, path = "figures/",
height = 20, width = 24, units = "cm"
)
alpha_box <- ggboxplot(
data = alpha_combined, x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = c("kingdom", "measure"),
palette = cbPalette, scales = "free_y", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
) #+ guides(color = guide_legend(position = "right"))
ggsave(
filename = "alpha_box.png", plot = alpha_box, path = "figures/",
height = 24, width = 24, units = "cm"
)
alpha_box <- ggboxplot(
data = alpha_combined, x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = c("kingdom", "measure"),
palette = cbPalette, scales = "free", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
) #+ guides(color = guide_legend(position = "right"))
ggsave(
filename = "alpha_box.png", plot = alpha_box, path = "figures/",
height = 24, width = 24, units = "cm"
)
alpha_box <- ggboxplot(
data = alpha_combined, x = "Site", y = "value",
color = "Storage", add = "jitter", facet.by = c("measure", "kingdom"),
palette = cbPalette, scales = "free_y", legend = "bottom",
ylab = "Mean diversity index", xlab = "Site"
) #+ guides(color = guide_legend(position = "right"))
ggsave(
filename = "alpha_box.png", plot = alpha_box, path = "figures/",
height = 24, width = 24, units = "cm"
)
q()