This class is a wrapper for a series of operations on the original files and the basic manipulations, including the microtable object creation, data reduction, data rarefaction based on Paul et al. (2013) <doi:10.1371/journal.pone.0061217>, taxa abundance calculation, alpha and beta diversity calculation based on the An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035> and Lozupone et al. (2005) <doi:10.1128/AEM.71.12.8228<U+2013>8235.2005> and other basic operations.
microtable.
new()
microtable$new( otu_table = NULL, sample_table = NULL, tax_table = NULL, phylo_tree = NULL )
otu_table
data.frame; default NULL; necessary; The species or OTU table, rows are species, cols are samples.
sample_table
data.frame; default NULL; The sample information table, rows are samples, cols are sample metadata.
tax_table
data.frame; default NULL; The taxonomic information table, rows are species, cols are taxonomic classes.
phylo_tree
phylo; default NULL; If provided, the phylogenetic tree can be used for some analysis, for example, phylogenetic diversity.
an object of class "microtable" with the following components:
sample_table
The sample information table.
otu_table
The OTU table.
tax_table
The taxonomic table.
phylo_tree
The phylogenetic tree
taxa_abund
default NULL; use cal_abund function to calculate
alpha_diversity
default NULL; use cal_alphadiv function to calculate
beta_diversity
default NULL; use cal_betadiv function to calculate
data(otu_table_16S) data(taxonomy_table_16S) data(sample_info_16S) data(phylo_tree_16S) dataset <- microtable$new(sample_table = sample_info_16S, otu_table = otu_table_16S, tax_table = taxonomy_table_16S, phylo_tree = phylo_tree_16S) # trim the dataset dataset$tidy_dataset()
print()
Print the microtable object.
microtable$print()
filter_pollution()
Filter the taxa considered as pollution. This operation will remove any line of the tax_table containing any the word in taxa parameter regardless of word case.
microtable$filter_pollution(taxa = c("mitochondria", "chloroplast"))
taxa
default: c("mitochondria", "chloroplast"); filter mitochondria and chloroplast, or others as needed.
None
dataset$filter_pollution(taxa = c("mitochondria", "chloroplast"))
rarefy_samples()
Rarefy communities to make all samples have same species number, modified from the rarefy_even_depth() in phyloseq package, see Paul et al. (2013) <doi:10.1371/journal.pone.0061217>.
microtable$rarefy_samples(sample.size = NULL, rngseed = 123, replace = TRUE)
sample.size
default:NULL; the required species number, If not provided, use minimum number of all samples.
rngseed
random seed; default: 123.
replace
default: TRUE; see sample
for the random sampling.
None; rarefied dataset.
\donttest{ dataset$rarefy_samples(sample.size = min(dataset$sample_sums()), replace = TRUE) }
tidy_dataset()
Tidy the object of microtable Class. Trim the dataset to make OTUs and samples consistent across all files in the object.
microtable$tidy_dataset(main_data = TRUE)
main_data
TRUE or FALSE, if TRUE, only basic files in microtable object is tidied, otherwise, all files, including taxa_abund, alpha_diversity and beta_diversity, are all trimed.
None, Object of microtable itself cleaned up.
dataset$tidy_dataset(main_data = TRUE)
cal_abund()
Calculate the taxonomic abundance at each taxonomic ranks.
microtable$cal_abund()
taxa_abund in object.
\donttest{ dataset$cal_abund() }
save_abund()
Save taxonomic abundance to the computer local place.
microtable$save_abund(dirpath = "taxa_abund")
dirpath
default "taxa_abund"; directory name to save the taxonomic abundance files.
sample_sums()
Sum the species number for each sample.
microtable$sample_sums()
species number of samples.
\donttest{ dataset$sample_sums() }
taxa_sums()
Sum the species number for each taxa.
microtable$taxa_sums()
species number of taxa.
\donttest{ dataset$taxa_sums() }
sample_names()
Sample names.
microtable$sample_names()
sample names.
\donttest{ dataset$sample_names() }
taxa_names()
Taxa names.
microtable$taxa_names()
taxa names.
\donttest{ dataset$taxa_names() }
merge_samples()
Merge samples according to specific group to generate a new microtable.
microtable$merge_samples(use_group)
use_group
the group column in sample_table.
a new created merged microtable object.
\donttest{ dataset$merge_samples(use_group = "Group") }
merge_taxa()
Merge taxa according to specific taxonomic rank to generate a new microtable.
microtable$merge_taxa(taxa = "Genus")
taxa
the specific rank in tax_table.
a new created merged microtable object.
\donttest{ dataset$merge_taxa(taxa = "Genus") }
cal_alphadiv()
Calculate alpha diversity in microtable Class.
microtable$cal_alphadiv(measures = NULL, PD = FALSE)
measures
one or more indexes from "Observed", "Coverage", "Chao1", "ACE", "Shannon", "Simpson", "InvSimpson", "Fisher", "PD"; default NULL, using all those measures.
PD
TRUE or FALSE, whether phylogenetic tree should be calculated, default FALSE.
alpha_diversity stored in object.
\donttest{ dataset$cal_alphadiv(measures = NULL, PD = FALSE) class(dataset$alpha_diversity) }
save_alphadiv()
Save alpha diversity table to the computer.
microtable$save_alphadiv(dirpath = "alpha_diversity")
dirpath
default "alpha_diversity"; directory name to save the alpha_diversity.csv file.
cal_betadiv()
Calculate beta diversity in microtable object, including Bray-Curtis, Jaccard, and UniFrac, see An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035> and Lozupone et al. (2005) <doi:10.1128/AEM.71.12.8228<U+2013>8235.2005>.
microtable$cal_betadiv(unifrac = FALSE)
unifrac
TRUE or FALSE, whether unifrac index should be calculated, default FALSE.
beta_diversity stored in object.
\donttest{ dataset$cal_betadiv(unifrac = FALSE) class(dataset$beta_diversity) }
save_betadiv()
Save beta diversity matrix to the computer.
microtable$save_betadiv(dirpath = "beta_diversity")
dirpath
default "beta_diversity"; directory name to save the beta diversity matrix files.
clone()
The objects of this class are cloneable with this method.
microtable$clone(deep = FALSE)
deep
Whether to make a deep clone.
# NOT RUN {
## ------------------------------------------------
## Method `microtable$new`
## ------------------------------------------------
data(otu_table_16S)
data(taxonomy_table_16S)
data(sample_info_16S)
data(phylo_tree_16S)
dataset <- microtable$new(sample_table = sample_info_16S, otu_table = otu_table_16S,
tax_table = taxonomy_table_16S, phylo_tree = phylo_tree_16S)
# trim the dataset
dataset$tidy_dataset()
## ------------------------------------------------
## Method `microtable$filter_pollution`
## ------------------------------------------------
dataset$filter_pollution(taxa = c("mitochondria", "chloroplast"))
## ------------------------------------------------
## Method `microtable$rarefy_samples`
## ------------------------------------------------
# }
# NOT RUN {
dataset$rarefy_samples(sample.size = min(dataset$sample_sums()), replace = TRUE)
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$tidy_dataset`
## ------------------------------------------------
dataset$tidy_dataset(main_data = TRUE)
## ------------------------------------------------
## Method `microtable$cal_abund`
## ------------------------------------------------
# }
# NOT RUN {
dataset$cal_abund()
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$sample_sums`
## ------------------------------------------------
# }
# NOT RUN {
dataset$sample_sums()
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$taxa_sums`
## ------------------------------------------------
# }
# NOT RUN {
dataset$taxa_sums()
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$sample_names`
## ------------------------------------------------
# }
# NOT RUN {
dataset$sample_names()
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$taxa_names`
## ------------------------------------------------
# }
# NOT RUN {
dataset$taxa_names()
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$merge_samples`
## ------------------------------------------------
# }
# NOT RUN {
dataset$merge_samples(use_group = "Group")
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$merge_taxa`
## ------------------------------------------------
# }
# NOT RUN {
dataset$merge_taxa(taxa = "Genus")
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$cal_alphadiv`
## ------------------------------------------------
# }
# NOT RUN {
dataset$cal_alphadiv(measures = NULL, PD = FALSE)
class(dataset$alpha_diversity)
# }
# NOT RUN {
## ------------------------------------------------
## Method `microtable$cal_betadiv`
## ------------------------------------------------
# }
# NOT RUN {
dataset$cal_betadiv(unifrac = FALSE)
class(dataset$beta_diversity)
# }
Run the code above in your browser using DataLab