trans_norm {microeco} | R Documentation |
Feature abundance normalization/transformation.
Description
Feature abundance normalization/transformation for a microtable object or data.frame object.
Methods
Public methods
Method new()
Get a transposed abundance table if the input is microtable object. In the table, rows are samples, and columns are features. This can make the further operations same with the traditional ecological methods.
Usage
trans_norm$new(dataset = NULL)
Arguments
dataset
the
microtable
object ordata.frame
object. If it isdata.frame
object, please make sure that rows are samples, and columns are features.
Returns
data_table, stored in the object.
Examples
library(microeco) data(dataset) t1 <- trans_norm$new(dataset = dataset)
Method norm()
Normalization/transformation methods.
Usage
trans_norm$norm( method = "rarefy", sample.size = NULL, rngseed = 123, replace = TRUE, pseudocount = 1, intersect.no = 10, ct.min = 1, condition = NULL, MARGIN = NULL, logbase = 2, ... )
Arguments
method
default "rarefy"; See the following available options.
Methods for normalization:-
"rarefy"
: classic rarefaction based on R sample function. -
"SRS"
: scaling with ranked subsampling method based on the SRS package provided by Lukas Beule and Petr Karlovsky (2020) <doi:10.7717/peerj.9593>. -
"clr"
: Centered log-ratio normalization <ISBN:978-0-412-28060-3> <doi: 10.3389/fmicb.2017.02224>. It is defined:where
is the abundance of
th feature in sample
,
is the geometric mean of abundances for sample
. A pseudocount need to be added to deal with the zero. For more information, please see the 'clr' method in
decostand
function of vegan package. -
"rclr"
: Robust centered log-ratio normalization <doi: doi:10.1128/msystems.00016-19>. It is defined:where
is the abundance of
th feature in sample
,
is the geometric mean of abundances (> 0) for sample
. In rclr, zero values are kept as zeroes, and not taken into account.
-
"GMPR"
: Geometric mean of pairwise ratios <doi: 10.7717/peerj.4600>. For a given sample, the size factor
is defined:
where
denotes all the features, and
denotes all the samples. For sample
,
, where
is the feature abundances of sample
.
-
"CSS"
: Cumulative sum scaling normalization based on themetagenomeSeq
package <doi:10.1038/nmeth.2658>. For a given sample, the scaling factor
is defined:
where
is the
th quantile of sample
, that is, in sample
there are
features with counts smaller than
.
denotes the count (abundance) of feature i in sample
. For
= 0.95
(feature number),
corresponds to the 95th percentile of the count distribution for sample
. Normalized counts
, where
is an appropriately chosen normalization constant.
-
"TSS"
: Total sum scaling. Abundance is divided by the sequencing depth. For a given sample, normalized counts is defined:
where
is the counts of feature
in sample
, and
is the feature number of sample
.
-
"eBay"
: Empirical Bayes approach to normalization <10.1186/s12859-020-03552-z>. The implemented method is not tree-related. In the output, the sum of each sample is 1. -
"TMM"
: Trimmed mean of M-values method based on thenormLibSizes
function ofedgeR
package <doi: 10.1186/gb-2010-11-3-r25>. -
"DESeq2"
: Median ratio of gene counts relative to geometric mean per gene based on the DESeq function ofDESeq2
package <doi: 10.1186/s13059-014-0550-8>. This option can invoke thetrans_diff
class and extract the normalized data from the original result. Note that eithergroup
orformula
should be provided. The scaling factor is defined:where
is the counts of feature
in sample
, and
is the total sample number.
-
"Wrench"
: Group-wise and sample-wise compositional bias factor <doi: 10.1186/s12864-018-5160-5>. Note that condition parameter is necesary to be passed tocondition
parameter inwrench
function of Wrench package. As the input data must be microtable object, so the input condition parameter can be a column name ofsample_table
. The scaling factor is defined:where
represents the relative abundance (proportion) for feature
in sample
,
is the average proportion of feature
across the dataset,
represents a weight specific to each technique, and
is the feature number in sample.
-
"RLE"
: Relative log expression.
Methods based on
decostand
function of vegan package:-
"total"
: divide by margin total (default MARGIN = 1, i.e. rows - samples). -
"max"
: divide by margin maximum (default MARGIN = 2, i.e. columns - features). -
"normalize"
: make margin sum of squares equal to one (default MARGIN = 1). -
"range"
: standardize values into range 0...1 (default MARGIN = 2). If all values are constant, they will be transformed to 0. -
"standardize"
: scale x to zero mean and unit variance (default MARGIN = 2). -
"pa"
: scale x to presence/absence scale (0/1). -
"log"
: logarithmic transformation.
Other methods for transformation:
-
"AST"
: Arc sine square root transformation.
-
sample.size
default NULL; libray size for rarefaction when method = "rarefy" or "SRS". If not provided, use the minimum number across all samples. For "SRS" method, this parameter is passed to
Cmin
parameter ofSRS
function of SRS package.rngseed
default 123; random seed. Available when method = "rarefy" or "SRS".
replace
default TRUE; see
sample
for the random sampling; Available whenmethod = "rarefy"
.pseudocount
default 1; add pseudocount for those features with 0 abundance when
method = "clr"
.intersect.no
default 10; the intersecting taxa number between paired sample for
method = "GMPR"
.ct.min
default 1; the minimum number of counts required to calculate ratios for
method = "GMPR"
.condition
default NULL; Only available when
method = "Wrench"
. This parameter is passed to thecondition
parameter ofwrench
function in Wrench package It must be a column name ofsample_table
or a vector with same length of samples.MARGIN
default NULL; 1 = samples, and 2 = features of abundance table; only available when method comes from
decostand
function of vegan package. If MARGIN is NULL, use the default value in decostand function.logbase
default 2; The logarithm base.
...
parameters pass to
vegan::decostand
, ormetagenomeSeq::cumNorm
when method = "CSS", oredgeR::normLibSizes
when method = "TMM" or "RLE", ortrans_diff
class when method = "DESeq2", orwrench
function of Wrench package when method = "Wrench".
Returns
new microtable object or data.frame object.
Examples
newdataset <- t1$norm(method = "clr") newdataset <- t1$norm(method = "log")
Method clone()
The objects of this class are cloneable with this method.
Usage
trans_norm$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
## ------------------------------------------------
## Method `trans_norm$new`
## ------------------------------------------------
library(microeco)
data(dataset)
t1 <- trans_norm$new(dataset = dataset)
## ------------------------------------------------
## Method `trans_norm$norm`
## ------------------------------------------------
newdataset <- t1$norm(method = "clr")
newdataset <- t1$norm(method = "log")