transform_sample_counts {phyloseq} | R Documentation

## Transform abundance data in an `otu_table`, sample-by-sample.

### Description

This function transforms the sample counts of a taxa abundance matrix according to a user-provided function. The counts of each sample will be transformed individually. No sample-sample interaction/comparison is possible by this method.

### Usage

    transform_sample_counts(physeq, fun, ...)

    transformSampleCounts(physeq, fun, ...)

### Arguments

`physeq` | (Required). `phyloseq-class` of `otu_table-class`.
`fun` | (Required). A single-argument function that will be applied to the abundance counts of each sample. Can be an anonymous `function`.
`...` | (Optional). Additional, optionally-named, arguments passed to `fun` during transformation of abundance data.

### Value

A transformed `otu_table` – or `phyloseq` object with its transformed `otu_table`. In general, trimming is not expected by this method, so it is suggested that the user provide only functions that return a full-length vector. Filtering/trimming can follow, for which the `genefilter_sample` and `prune_taxa` functions are suggested.

### See Also

`threshrankfun`, `rank`, `log`

### Examples

    #
    data(esophagus)
    x1 = transform_sample_counts(esophagus, threshrankfun(50))
    head(otu_table(x1), 10)
    x2 = transform_sample_counts(esophagus, rank)
    head(otu_table(x2), 10)
    identical(x1, x2)
    x3 = otu_table(esophagus) + 5
    x3 = transform_sample_counts(x3, log)
    head(otu_table(x3), 10)
    x4 = transform_sample_counts(esophagus, function(x) round(x^2.2, 0))
    head(otu_table(x4), 10)

[Package phyloseq version 1.28.0 Index]