rarefy | R Documentation |
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
.
rarefy(
counts,
depth = 0.1,
n_samples = NULL,
seed = 0,
times = NULL,
cpus = n_cpus()
)
counts |
An OTU abundance matrix where each column is a sample, and
each row is an OTU. Any object coercible with |
depth |
How many observations to keep per sample. When
|
n_samples |
The number of samples to keep. When |
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. |
times |
How many independent rarefactions to perform. If set,
|
cpus |
How many parallel processing threads should be used. The
default, |
An integer matrix.
# Create an OTU matrix with 4 samples (A-D) and 5 OTUs.
counts <- matrix(
data = c(4,0,3,2,6,0,8,0,0,5,0,9,0,0,7,0,10,0,0,1),
nrow = 5,
dimnames = list(paste0('OTU', 1:5), LETTERS[1:4]) )
counts
colSums(counts)
counts <- rarefy(counts, depth = 14)
counts
colSums(counts)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.