rarefy_even_depth_pq: Rarefy a phyloseq object to even sequencing depth

View source: R/normalize_pq.R

rarefy_even_depth_pqR Documentation

Rarefy a phyloseq object to even sequencing depth

Description

lifecycle-stable

An R-version-robust drop-in replacement for phyloseq::rarefy_even_depth(), heavily inspired by that function.

Usage

rarefy_even_depth_pq(
  physeq,
  sample_size = NULL,
  rngseed = FALSE,
  replace = TRUE,
  trimOTUs = TRUE
)

Arguments

physeq

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

sample_size

(integer) the sequencing depth to rarefy to. If NULL (default), min(sample_sums(physeq)) is used. Samples with fewer reads than sample_size are dropped.

rngseed

(logical or integer, default FALSE) random seed. Set to an integer to seed the RNG before subsampling and restore the caller's global RNG state on exit (matching phyloseq::rarefy_even_depth() behaviour). FALSE leaves the global RNG untouched.

replace

(logical, default TRUE) sample with replacement? TRUE matches the phyloseq::rarefy_even_depth() default.

trimOTUs

(logical, default TRUE) if TRUE, taxa that are entirely emptied by subsampling are removed from the returned object.

Value

A new phyloseq-class object with a rarefied otu_table.

Author(s)

Adrien Taudière

See Also

phyloseq::rarefy_even_depth(), rarefy_pq()

Examples

data_f_rar <- rarefy_even_depth_pq(data_fungi_mini, sample_size = 500)
sample_sums(data_f_rar)


data_f_rar_notrim <- rarefy_even_depth_pq(
  data_fungi_mini,
  sample_size = 500,
  trimOTUs = FALSE
)


MiscMetabar documentation built on June 8, 2026, 5:07 p.m.