Learn R Programming

rbiom (version 2.2.0)

rarefy: Rarefy OTU counts.

Description

Sub-sample OTU observations such that all samples have an equal number. If called on data with non-integer abundances, values will be re-scaled to integers between 1 and depth such that they sum to depth.

Usage

rarefy(biom, depth = 0.1, n = NULL, seed = 0, clone = TRUE, cpus = NULL)

Value

An rbiom object.

Arguments

biom

An rbiom object, such as from as_rbiom(). Any value accepted by as_rbiom() can also be given here.

depth

How many observations to keep per sample. When 0 < depth < 1, it is taken as the minimum percentage of the dataset's observations to keep. Ignored when n is specified. Default: 0.1

n

The number of samples to keep. When 0 < n < 1, it is taken as the percentage of samples to keep. If negative, that number or percentage of samples is dropped. If 0, all samples are kept. If NULL, depth is used instead. Default: NULL

seed

An integer seed for randomizing which observations to keep or drop. If you need to create different random rarefactions of the same data, set the seed to a different number each time.

clone

Create a copy of biom before modifying. If FALSE, biom is modified in place as a side-effect. See speed ups for use cases. Default: TRUE

cpus

The number of CPUs to use. Set to NULL to use all available, or to 1 to disable parallel processing. Default: NULL

See Also

Other rarefaction: rare_corrplot(), rare_multiplot(), rare_stacked(), rarefy_cols(), sample_sums()

Other transformations: modify_metadata, rarefy_cols(), slice_metadata, subset(), with()

Examples

Run this code
    library(rbiom)
    
    sample_sums(hmp50) %>% head()
    
    biom <- rarefy(hmp50)
    sample_sums(biom) %>% head()

Run the code above in your browser using DataLab