Public methods
Method new()
Usage
microtable$new(
otu_table,
sample_table = NULL,
tax_table = NULL,
phylo_tree = NULL,
rep_fasta = NULL
)
Arguments
otu_table
data.frame; 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; The phylogenetic tree; read with read.tree function in ape package.
rep_fasta
list; default NULL; The representative sequences; read with read.fasta function in seqinr package.
Returns
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.
rep_fasta
The representative sequence.
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.
Examples
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 print()
Print the microtable object.
Usage
microtable$print()
Method 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.
Usage
microtable$filter_pollution(taxa = c("mitochondria", "chloroplast"))
Arguments
taxa
default: c("mitochondria", "chloroplast"); filter mitochondria and chloroplast, or others as needed.
Returns
None
Examples
dataset$filter_pollution(taxa = c("mitochondria", "chloroplast"))
Method 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>.
Usage
microtable$rarefy_samples(sample.size = NULL, rngseed = 123, replace = TRUE)
Arguments
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.
Returns
None; rarefied dataset.
Examples
\donttest{
dataset$rarefy_samples(sample.size = min(dataset$sample_sums()), replace = TRUE)
}
Method tidy_dataset()
Tidy the object of microtable Class.
Trim the dataset to make OTUs and samples consistent across all files in the object.
Usage
microtable$tidy_dataset(main_data = TRUE)
Arguments
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.
Returns
None, Object of microtable itself cleaned up.
Examples
dataset$tidy_dataset(main_data = TRUE)
Method cal_abund()
Calculate the taxonomic abundance at each taxonomic ranks.
Usage
microtable$cal_abund(
select_cols = NULL,
rel = TRUE,
split_group = FALSE,
split_by = "&&",
split_column = NULL
)
Arguments
select_cols
default NULL; numeric vector or character vector of colnames of tax_table; used to select columns to merge and calculate abundances.
This is very useful if there are commented columns or some columns with multiple structure that cannot be used directly.
rel
default TRUE; if TRUE, relative abundance is used; if FALSE, absolute abundance will be summed.
split_group
default FALSE; if TRUE, split the rows to multiple rows according to one or more columns in tax_table. Very useful when multiple mapping info exist.
split_by
default "&&"; Separator delimiting collapsed values; only used when split_group == TRUE; see sep in separate_rows function.
split_column
default NULL; character vector or list; only used when split_group == TRUE; character vector:
fixed column or columns used for the splitting in tax_table in each abundance calculation;
list: containing more character vectors to assign the column names to each calculation, such as list(c("Phylum"), c("Phylum", "Class")).
Returns
taxa_abund in object.
Examples
\donttest{
dataset$cal_abund()
}
Method save_abund()
Save taxonomic abundance to the computer local place.
Usage
microtable$save_abund(dirpath = "taxa_abund")
Arguments
dirpath
default "taxa_abund"; directory name to save the taxonomic abundance files.
Method sample_sums()
Sum the species number for each sample.
Usage
microtable$sample_sums()
Returns
species number of samples.
Examples
\donttest{
dataset$sample_sums()
}
Method taxa_sums()
Sum the species number for each taxa.
Usage
microtable$taxa_sums()
Returns
species number of taxa.
Examples
\donttest{
dataset$taxa_sums()
}
Method sample_names()
Sample names.
Usage
microtable$sample_names()
Returns
sample names.
Examples
\donttest{
dataset$sample_names()
}
Method taxa_names()
Taxa names.
Usage
microtable$taxa_names()
Returns
taxa names.
Examples
\donttest{
dataset$taxa_names()
}
Method merge_samples()
Merge samples according to specific group to generate a new microtable.
Usage
microtable$merge_samples(use_group)
Arguments
use_group
the group column in sample_table.
Returns
a new created merged microtable object.
Examples
\donttest{
dataset$merge_samples(use_group = "Group")
}
Method merge_taxa()
Merge taxa according to specific taxonomic rank to generate a new microtable.
Usage
microtable$merge_taxa(taxa = "Genus")
Arguments
taxa
the specific rank in tax_table.
Returns
a new created merged microtable object.
Examples
\donttest{
dataset$merge_taxa(taxa = "Genus")
}
Method cal_alphadiv()
Calculate alpha diversity in microtable Class.
Usage
microtable$cal_alphadiv(measures = NULL, PD = FALSE)
Arguments
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.
Returns
alpha_diversity stored in object.
Examples
\donttest{
dataset$cal_alphadiv(measures = NULL, PD = FALSE)
class(dataset$alpha_diversity)
}
Method save_alphadiv()
Save alpha diversity table to the computer.
Usage
microtable$save_alphadiv(dirpath = "alpha_diversity")
Arguments
dirpath
default "alpha_diversity"; directory name to save the alpha_diversity.csv file.
Method 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>.
Usage
microtable$cal_betadiv(unifrac = FALSE)
Arguments
unifrac
TRUE or FALSE, whether unifrac index should be calculated, default FALSE.
Returns
beta_diversity stored in object.
Examples
\donttest{
dataset$cal_betadiv(unifrac = FALSE)
class(dataset$beta_diversity)
}
Method save_betadiv()
Save beta diversity matrix to the computer.
Usage
microtable$save_betadiv(dirpath = "beta_diversity")
Arguments
dirpath
default "beta_diversity"; directory name to save the beta diversity matrix files.
Method clone()
The objects of this class are cloneable with this method.
Usage
microtable$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.