| rarefy_pq | R Documentation |
Rarefy (subsample to an even depth) a phyloseq object. rarefy_pq() is a
drop-in, R-version-robust replacement for phyloseq::rarefy_even_depth()
that can additionally repeat the rarefaction n times and return the
averaged OTU table, reducing the stochasticity of a single subsampling
pass. With n = 1 (default) the behaviour matches a standard single
rarefaction.
rarefy_pq(physeq, sample_size = NULL, n = 1, seed = 123, replace = FALSE, ...)
physeq |
(required) a |
sample_size |
(integer) the depth to rarefy to. If |
n |
(integer, default 1) number of rarefaction repetitions to average over. Values > 1 return a non-integer (averaged) OTU table. |
seed |
(integer, default 123) random seed. Set to |
replace |
(logical, default FALSE) sample with replacement? |
... |
Not used. Kept for backward compatibility. |
Rarefaction is performed internally rather than by calling
phyloseq::rarefy_even_depth(), whose replace = FALSE code path relies
on rep_len(x["OTUi"], x["times"]) and errors with invalid 'length.out' value under recent R-devel (see phyloseq issue 1753). For a single
rarefaction (n = 1), the result is identical to
phyloseq::rarefy_even_depth() with trimOTUs = FALSE for the same
seed, sample_size and replace — except in the degenerate case where
a retained sample has a single read, in which phyloseq triggers a
sample() edge-case bug that rarefy_pq() avoids. Empty OTUs are never
trimmed.
A new phyloseq-class object with a
rarefied (or averaged-rarefied) otu_table.
Adrien Taudière
phyloseq::rarefy_even_depth(), transform_pq()
data_f_rar <- rarefy_pq(data_fungi_mini, sample_size = 500, seed = 1)
sample_sums(data_f_rar)
data_f_rar5 <- rarefy_pq(data_fungi_mini, sample_size = 500, n = 5, seed = 1)
sample_sums(data_f_rar5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.