View source: R/Alpha_diversity_calculator2.R
Alpha_diversity_calculator2 | R Documentation |
Calculate alpha diversity of each sample
Alpha_diversity_calculator2(
taxobj = NULL,
taxlevel = NULL,
prefix = "",
input,
inputformat,
reads
)
taxobj |
tax summary objects computed by |
taxlevel |
taxonomy levels used for visualization.Must be one of c("Domain","Phylum","Class","Order","Family","Genus","Species","Base").Default:NULL. |
prefix |
A character string as prefix of diversity index. Default:"" |
input |
Reads or relative abundance of OTU/Taxa/gene data frame,see details in inputformat. (Useless when taxobj is set). |
inputformat |
(Useless when taxobj is set) 1:data frame with first column of OTUID and last column of taxonomy 2:data frame with first column of OTUID/taxonomy 3:data frame of all numeric |
reads |
If the input data frame were from reads table or not(relative abundance table).(Useless when taxobj is set). |
when tax taxobj is set, returns column table with group information combined with for alpha-diversity of each sample,else returns data frame for alpha-diversity of each sample
1.When input data frame is in relative abundance table,Chao and ACE are not available
Wang Ningqi 2434066068@qq.com
### 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.