rarefy_sample_count_by_modality: Rarefy (equalize) the number of samples per modality of a...

View source: R/dada_phyloseq.R

rarefy_sample_count_by_modalityR Documentation

Rarefy (equalize) the number of samples per modality of a factor

Description

lifecycle-experimental

This function randomly draw the same number of samples for each modality of factor. It is usefull to dissentangle the effect of different number of samples per modality on diversity. Internally used in accu_plot_balanced_modality().

Usage

rarefy_sample_count_by_modality(physeq, fact, rngseed = FALSE, verbose = TRUE)

Arguments

physeq

(required): a phyloseq-class object obtained using the phyloseq package.

fact

(required): The variable to rarefy. Must be present in the sam_data slot of the physeq object.

rngseed

(Optional). A single integer value passed to set.seed, which is used to fix a seed for reproducibly random number generation (in this case, reproducibly random subsampling). If set to FALSE, then no iddling with the RNG seed is performed, and it is up to the user to appropriately call

verbose

(logical). If TRUE, print additional informations.

Value

A new phyloseq-class object.

Author(s)

Adrien Taudière

See Also

accu_plot_balanced_modality()

Examples

table(data_fungi_mini@sam_data$Height)
data_fungi_mini2 <- rarefy_sample_count_by_modality(data_fungi_mini, "Height")
table(data_fungi_mini2@sam_data$Height)
if (requireNamespace("patchwork")) {
  ggvenn_pq(data_fungi_mini, "Height") + ggvenn_pq(data_fungi_mini2, "Height")
}

adrientaudiere/MiscMetabar documentation built on Oct. 13, 2024, 9:42 p.m.