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
|
if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")
library(devtools)
if (!requireNamespace("amplicon", quietly = TRUE)) install_github("liaochenlanruo/amplicon")
suppressWarnings(suppressMessages(library(amplicon)))
setwd("用户自己的工作目录")
metadata = read.table("sample-metadata.tsv", header=T, row.names=1, sep="\t", comment.char="", stringsAsFactors = F)
alpha_div <- read.delim("alpha.txt", quote="", stringsAsFactors=FALSE)
(p1 = alpha_boxplot(alpha_div, index = "Shannon", metadata, groupID = "Depth2"))
(p2 = alpha_boxplot(alpha_div, index = "Richness", metadata, groupID = "Depth2"))
(p3 = alpha_boxplot(alpha_div, index = "Simpson", metadata, groupID = "Depth2"))
(p4 = alpha_boxplot(alpha_div, index = "Chao1", metadata, groupID = "Depth2"))
(p5 = alpha_boxplot(alpha_div, index = "ACE", metadata, groupID = "Depth2"))
(p6 = alpha_boxplot(alpha_div, index = "Pielou", metadata, groupID = "Depth2"))
(p7 = alpha_boxplot(alpha_div, index = "PD_whole_tree", metadata, groupID = "Depth2"))
ggsave(paste0("alpha_boxplot_shannon.pdf"), p1, width=89, height=75, units="mm") ggsave(paste0("alpha_boxplot_Richness.pdf"), p2, width=89, height=75, units="mm") ggsave(paste0("alpha_boxplot_Simpson.pdf"), p3, width=89, height=75, units="mm") ggsave(paste0("alpha_boxplot_Chao1.pdf"), p4, width=89, height=75, units="mm") ggsave(paste0("alpha_boxplot_ACE.pdf"), p5, width=89, height=75, units="mm") ggsave(paste0("alpha_boxplot_Pielou.pdf"), p6, width=89, height=75, units="mm") ggsave(paste0("alpha_boxplot_PD_whole_tree.pdf"), p7, width=89, height=75, units="mm")
|