This function is part of the MicrobiomeStat package. It normalizes a data object based on the chosen method.
Usage
mStat_normalize_data(
data.obj,
method = c("Rarefy-TSS", "Rarefy", "TSS", "GMPR", "CSS", "DESeq", "TMM"),
depth = NULL
)
Arguments
- data.obj
A list object in a format specific to MicrobiomeStat, which can include components such as feature.tab (matrix), feature.ann (matrix), meta.dat (data.frame), tree, and feature.agg.list (list). The data.obj can be converted from other formats using several functions from the MicrobiomeStat package, including: 'mStat_convert_DGEList_to_data_obj', 'mStat_convert_DESeqDataSet_to_data_obj', 'mStat_convert_phyloseq_to_data_obj', 'mStat_convert_SummarizedExperiment_to_data_obj', 'mStat_import_qiime2_as_data_obj', 'mStat_import_mothur_as_data_obj', 'mStat_import_dada2_as_data_obj', and 'mStat_import_biom_as_data_obj'. Alternatively, users can construct their own data.obj. Note that not all components of data.obj may be required for all functions in the MicrobiomeStat package.
- method
A string. The normalization method to be applied. It must be one of the following: "Rarefy-TSS", "Rarefy", "TSS", "GMPR", "CSS", "DESeq", "TMM". The default is "Rarefy-TSS". - "Rarefy-TSS": Rarefaction followed by Total Sum Scaling normalization. - "Rarefy": Rarefaction normalization only. - "TSS": Total Sum Scaling normalization only. - "GMPR": Geometric Mean of Pairwise Ratios normalization method. - "CSS": Cumulative Sum Scaling normalization method. - "DESeq": Normalization using the DESeq method for RNA-seq data. - "TMM": Normalization using the Trimmed Mean of M-values (TMM) method from the edgeR package.
- depth
An integer. The sequencing depth to be used for the "Rarefy" and "Rarefy-TSS" methods. If NULL, the smallest total count dplyr::across samples is used as the rarefaction depth.
Details
The function first checks if 'data.obj' is a list. It then retrieves the OTU table and estimates the normalization/scale factor based on the chosen method. The data object is then updated with the normalized OTU table and the chosen method is added as 'norm.status'. The function returns the normalized data object and the scale factor.
Examples
if (FALSE) { # \dontrun{
# Load example data object
data(peerj32.obj)
# Applying Total Sum Scaling (TSS) normalization
norm_result_tss <- mStat_normalize_data(data.obj = peerj32.obj, method = "TSS")
print(norm_result_tss$data.obj.norm) # Display normalized data object
# Applying Rarefaction followed by Total Sum Scaling (Rarefy-TSS) with a specified depth
norm_result_rarefy_tss <- mStat_normalize_data(data.obj = peerj32.obj,
method = "Rarefy-TSS", depth = 5000)
print(norm_result_rarefy_tss$data.obj.norm) # Display normalized data object
# Normalization using Geometric Mean of Pairwise Ratios (GMPR)
norm_result_gmpr <- mStat_normalize_data(data.obj = peerj32.obj, method = "GMPR")
print(norm_result_gmpr$data.obj.norm) # Display normalized data object
# Utilizing the DESeq normalization method
# This is particularly useful for RNA-seq data from microbiome studies
norm_result_deseq <- mStat_normalize_data(data.obj = peerj32.obj, method = "DESeq")
print(norm_result_deseq$data.obj.norm) # Display normalized data object
# Example of error handling when an incorrect depth is specified for the "Rarefy" method
tryCatch({
norm_result_error <- mStat_normalize_data(data.obj = peerj32.obj,
method = "Rarefy", depth = 10000000)
print(norm_result_error$data.obj.norm)
}, error = function(e) {
print(e$message) # Print the error message if depth is not feasible
})
} # }