rarefy {rbiom} | R Documentation |
Subset counts so that all samples have the same number of observations.
Description
Subset counts so that all samples have the same number of observations.
Usage
rarefy(biom, depth = NULL, seed = 0)
Arguments
biom |
A |
depth |
The number of observations to keep, per sample. If set to
|
seed |
An integer to use for seeding the random number generator. If
you need to create different random rarefactions of the same |
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
library(rbiom)
infile <- system.file("extdata", "hmp50.bz2", package = "rbiom")
biom <- read.biom(infile)
range(slam::col_sums(biom$counts))
biom <- rarefy(biom, depth=1000)
range(slam::col_sums(biom$counts))