transformAssay: Transform assay

transformAssayR Documentation

Transform assay

Description

Variety of transformations for abundance data, stored in assay. See details for options.

Usage

transformAssay(
  x,
  assay.type = "counts",
  assay_name = NULL,
  method = c("alr", "chi.square", "clr", "frequency", "hellinger", "log", "log10",
    "log2", "max", "normalize", "pa", "range", "rank", "rclr", "relabundance", "rrank",
    "standardize", "total", "z"),
  MARGIN = "samples",
  name = method,
  pseudocount = FALSE,
  ...
)

## S4 method for signature 'SummarizedExperiment'
transformAssay(
  x,
  assay.type = "counts",
  assay_name = NULL,
  method = c("alr", "chi.square", "clr", "frequency", "hellinger", "log", "log10",
    "log2", "max", "normalize", "pa", "range", "rank", "rclr", "relabundance", "rrank",
    "standardize", "total", "z"),
  MARGIN = "samples",
  name = method,
  pseudocount = FALSE,
  ...
)

Arguments

x

A SummarizedExperiment object.

assay.type

A single character value for selecting the assay to be transformed.

assay_name

a single character value for specifying which assay to use for calculation. (Please use assay.type instead. At some point assay_name will be disabled.)

method

A single character value for selecting the transformation method.

MARGIN

A single character value for specifying whether the transformation is applied sample (column) or feature (row) wise. (By default: MARGIN = "samples")

name

A single character value specifying the name of transformed abundance table.

pseudocount

TRUE, FALSE, or a numeric value. When TRUE, automatically adds the minimum positive value of assay.type. When FALSE, does not add any pseudocount (pseudocount = 0). Alternatively, a user-specified numeric value can be added as pseudocount.

...

additional arguments passed on to vegan:decostand:

  • reference: A single value which will be used to fill reference sample's column in returned assay when calculating alr. (default: reference = NA)

  • ref_vals Deprecated. Use reference instead.

Details

These transformCount function provides a variety of options for transforming abundance data. The transformed data is calculated and stored in a new assay. The previously available wrappers transformSamples, transformFeatures ZTransform, and relAbundanceCounts have been deprecated.

The transformAssay provides sample-wise (column-wise) or feature-wise (row-wise) transformation to the abundance table (assay) based on specified MARGIN.

The available transformation methods include:

  • 'alr', 'chi.square', 'clr', 'frequency', 'hellinger', 'log', 'normalize', 'pa', 'rank', 'rclr' 'relabundance', 'rrank', 'standardize', 'total': please refer to decostand for details.

  • 'log10': log10 transformation can be used for reducing the skewness of the data.

    log10 = \log_{10} x

    where x is a single value of data.

  • 'log2': log2 transformation can be used for reducing the skewness of the data.

    log2 = \log_{2} x

    where x is a single value of data.

Value

transformAssay returns the input object x, with a new transformed abundance table named name added in the assay.

Author(s)

Leo Lahti and Tuomas Borman. Contact: microbiome.github.io

Examples

data(esophagus, package="mia")
tse <- esophagus

# By specifying 'method', it is possible to apply different transformations, 
# e.g. compositional transformation.
tse <- transformAssay(tse, method = "relabundance")

# The target of transformation can be specified with "assay.type"
# Pseudocount can be added by specifying 'pseudocount'.

# Perform CLR with smallest positive value as pseudocount
tse <- transformAssay(tse, assay.type = "relabundance", method = "clr", 
                     pseudocount = TRUE
                     )
                      
head(assay(tse, "clr"))

# With MARGIN, you can specify the if transformation is done for samples or
# for features. Here Z-transformation is done feature-wise.
tse <- transformAssay(tse, method = "z", MARGIN = "features")
head(assay(tse, "z"))

# Name of the stored table can be specified.
tse <- transformAssay(tse, method="hellinger", name="test")
head(assay(tse, "test"))

# pa returns presence absence table.
tse <- transformAssay(tse, method = "pa")
head(assay(tse, "pa"))

# rank returns ranks of taxa.
tse <- transformAssay(tse, method = "rank")
head(assay(tse, "rank"))

# In order to use other ranking variants, modify the chosen assay directly:
assay(tse, "rank_average", withDimnames = FALSE) <- colRanks(assay(tse, "counts"), 
                                                           ties.method="average", 
                                                           preserveShape = TRUE)  


FelixErnst/mia documentation built on June 19, 2024, 3:51 a.m.