taxatree_label: Add logical label column to taxatree_stats dataframe

View source: R/taxatree_label.R

taxatree_labelR Documentation

Add logical label column to taxatree_stats dataframe

Description

taxatree_label is used internally by taxatree_plotkey, but can also be used prior to taxatree_plots to label those plots directly

... arguments are passed to dplyr::filter(), so all filter syntax can be used.

Usage

taxatree_label(
  data,
  ...,
  .label_var = "label",
  .node_fun = list(prevalence = prev)
)

Arguments

data

psExtra (or phyloseq)

...

REQUIRED logical conditions for labelling e.g. rank == "Phylum", p.value < 0.1 | taxon %in% listOfTaxa

.label_var

name of label indicator variable to be created. If you change this, beware that taxatree_plotkey will not work, you will need to called taxatree_plot_label with

.node_fun

named list of length 1 providing taxatree_nodes fun arg. (name of list iterm is available for use in ...)

Details

If taxatree_stats missing (or if data is a phyloseq) it will create a plain taxatree_stats dataframe using only taxatree_nodes

node_fun can also be a precalculated dataframe (output of taxatree_nodes) but you should probably not use this option. This is used internally for efficiency inside taxatree_plotkey()

Value

psExtra with (modified) taxatree_stats dataframe

Examples

# simple example with plain phyloseq input
data("dietswap", package = "microbiome")
labelled <- dietswap %>%
  tax_prepend_ranks() %>%
  taxatree_label(rank == "Phylum", prevalence > 0.1)

# Note that "prevalence" column was available in data
# because it is created by `taxatree_nodes()` using the named function
# provided to the `node_fun` argument

# psExtra is returned
labelled

# notice how both conditions must be met for label column to be TRUE
labelled %>% taxatree_stats_get()

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