ps_arrange: Arrange samples in phyloseq by sample_data variables or taxon...

View source: R/ps_arrange.R

ps_arrangeR Documentation

Arrange samples in phyloseq by sample_data variables or taxon abundance

Description

Uses information in the sample_data or tax_table of phyloseq object to set the order of the samples (sample_data or tax_table specified by .target arg)

Give this function arguments in the same way you would use dplyr::arrange()

Usage

ps_arrange(ps, ..., .target = "sample_data")

Arguments

ps

phyloseq object

...

dots passed directly to dplyr::arrange()

.target

arrange samples by "sample_data" variables or "otu_table" taxa abundances

Value

phyloseq

See Also

arrange

Examples

data("dietswap", package = "microbiome")

dietswap %>%
  ps_arrange(subject, timepoint) %>%
  phyloseq::sample_data() %>%
  head(8)

ps <- dietswap %>% ps_arrange(subject, desc(timepoint))
phyloseq::sample_data(ps) %>% head(8)
phyloseq::otu_table(ps)[1:8, 1:8]

# you can also arrange samples by the abundances of taxa in the otu tables
pst <- dietswap %>% ps_arrange(desc(Akkermansia), .target = "otu_table")
phyloseq::otu_table(pst)[1:8, 1:8]
phyloseq::sample_data(pst) %>% head(8)

david-barnett/microViz documentation built on April 17, 2025, 4:25 a.m.