rarefy_cols {rbiom} | R Documentation |
Transform a counts matrix.
Description
Rarefaction subset counts so that all samples have the same number of observations. Rescaling rows or cols scales the matrix values so that row sums or column sums equal 1.
Usage
rarefy_cols(mtx, depth = 0.1, n = NULL, seed = 0L, cpus = NULL)
rescale_cols(mtx)
rescale_rows(mtx)
Arguments
mtx |
A matrix-like object. |
depth |
How many observations to keep per sample. When
|
n |
The number of samples to keep. When |
seed |
A positive integer to use for seeding the random number generator. If you need to create different random rarefactions of the same matrix, set this seed value to a different number each time. |
cpus |
The number of CPUs to use. Set to |
Value
The rarefied or rescaled matrix.
See Also
Other rarefaction:
rare_corrplot()
,
rare_multiplot()
,
rare_stacked()
,
rarefy()
,
sample_sums()
Other transformations:
modify_metadata
,
rarefy()
,
slice_metadata
,
subset()
,
with()
Examples
library(rbiom)
# rarefy_cols --------------------------------------
biom <- hmp50$clone()
sample_sums(biom) %>% head(10)
biom$counts %<>% rarefy_cols(depth=1000)
sample_sums(biom) %>% head(10)
# rescaling ----------------------------------------
mtx <- matrix(sample(1:20), nrow=4)
mtx
rowSums(mtx)
rowSums(rescale_rows(mtx))
colSums(mtx)
colSums(rescale_cols(mtx))