ps_otu2samdat: Copy phyloseq otu_table data to sample_data

View source: R/ps_otu2samdat.R

ps_otu2samdatR Documentation

Copy phyloseq otu_table data to sample_data

Description

Copy phyloseq otu_table data to sample_data

Usage

ps_otu2samdat(ps, taxa = NULL)

Arguments

ps

phyloseq with sample_data

taxa

list of taxa_names to copy to sample_data, or NULL (which selects all with phyloseq::taxa_names())

Value

phyloseq with augmented sample_data

Examples

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

ps <- dietswap %>% ps_otu2samdat("Akkermansia")
sample_variables(ps)

# or if you do not specify any taxa, all are copied
ps_all <- dietswap %>% ps_otu2samdat()
sample_variables(ps_all)[1:15]

# this could be useful for colouring ordination plots, for example
ps %>%
  ps_mutate(log_akkermansia = log(Akkermansia)) %>%
  dist_calc("bray") %>%
  ord_calc(method = "PCoA") %>%
  ord_plot(
    colour = "log_akkermansia",
    size = 3, shape = "nationality"
  )

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