### Data preparation ####
data(testotu)
groupinformation <- data.frame(
group = c(rep("a", 10), rep("b", 10)),
factor1 = rnorm(10),
factor2 = rnorm(mean = 100, 10),
subject = factor(c(1:10, 1:10))
)
# Summary OTU table into genus table and phylum table
testtax_summary <- tax_summary(
groupfile = groupinformation,
inputtable = testotu[, 2:21],
reads = TRUE,
taxonomytable = testotu[, c(1, 22)]
)
### Use taxsummary object as input ###
Alpha <- Alpha_diversity_calculator2(
taxobj = testtax_summary,
taxlevel = "Base"
)
head(Alpha)
# In genus level
Alpha <- Alpha_diversity_calculator2(
taxobj = testtax_summary,
taxlevel = "Genus",
prefix = "Genus"
)
head(Alpha)
### Input dataframe from reads table ###
Alpha <- Alpha_diversity_calculator2(
input = testotu,
prefix = "Bacterial",
inputformat = 1,
reads = TRUE
)
### Input dataframe from relative abundance table ###
if (!require(magrittr)) install.packages("magrittr")
library(magrittr)
Alpha <- Filter_function(
input = testotu,
threshold = 0,
format = 1
) %>%
Alpha_diversity_calculator2(
input = .,
prefix = "Bacterial",
inputformat = 1,
reads = FALSE
)
head(Alpha)
Run the code above in your browser using DataLab