rarefy: Subset counts so that all samples have the same number of...

Description Usage Arguments Value Examples

View source: R/rarefy.r

Description

Subset counts so that all samples have the same number of observations.

Usage

1
rarefy(biom, depth = NULL, seed = 0, progressbar = NULL)

Arguments

biom

A matrix, simple_triplet_matrix, or BIOM object, as returned from read.biom. For matrices, the rows and columns are assumed to be the taxa and samples, respectively.

depth

The number of observations to keep, per sample. If set to NULL, a depth will be automatically selected. Samples that have fewer than this number of observations will be dropped.

seed

An integer to use for seeding the random number generator. If you need to create different random rarefactions of the same BIOM object, set this seed value to a different number each time.

progressbar

An object of class Progress.

Value

A matrix, simple_triplet_matrix, or BIOM object, depending on the input object type. The type of object provided is the same type that is returned. The retained observations are randomly selected, based on a seed value derived from the BIOM object. Therefore, rarefying the same biom to the same depth will always produce the same resultant rarification.

Examples

1
2
3
4
5
6
7
8
    library(rbiom)

    infile <- system.file("extdata", "hmp50.biom", package = "rbiom")
    biom <- read.biom(infile)
    range(slam::col_sums(biom$counts))

    biom <- rarefy(biom, depth=1000)
    range(slam::col_sums(biom$counts))

cmmr/rbiom documentation built on Nov. 21, 2018, 10:04 a.m.