### Data preparation ####
data(testotu)
require(tidyr); require(magrittr) ## Or use pipe command in "dplyr"
testotu.pct <- data.frame(
OTU.ID = testotu[, 1],
sweep(testotu[, -c(1, 22)], 2, colSums(testotu[, -c(1, 22)]), "/"),
taxonomy = testotu[, 22]
)
sep_testotu <- Filter_function(
input = testotu,
threshold = 0.0001,
format = 1
) %>%
separate(
., col = taxonomy,
into = c("Domain", "Phylum", "Order", "Family", "Class", "Genus", "Species"),
sep = ";"
)
phylum <- aggregate(
sep_testotu[, 2:21], by = list(sep_testotu$Phylum), FUN = sum
)
phylum1 <- data.frame(row.names = phylum[, 1], phylum[, -1])
##### Input format 1, top 100 OTU #####
top100otu <- Top_taxa(
input = testotu.pct,
n = 100,
inputformat = 1,
outformat = 1
)
##### Input format 2, top 15 phylum #####
head(phylum)
top15phylum <- Top_taxa(
input = phylum,
n = 15,
inputformat = 2,
outformat = 1
)
##### Input format 3, top 15 phylum #####
head(phylum1)
top15phylum <- Top_taxa(
input = phylum1,
n = 15,
inputformat = 3,
outformat = 1
)
Run the code above in your browser using DataLab