calc_taxa_changes: Calculate the changes in taxonomic relative abundances...

View source: R/misc_analyses.R

calc_taxa_changesR Documentation

Calculate the changes in taxonomic relative abundances compared to controls

Description

Calculate the change relative to controls (percent) within sample groups (blocks) on a per taxon basis.

Usage

calc_taxa_changes(
  ts,
  metadata_map,
  block_header,
  treatment_header,
  control_label,
  zero_substitute
)

Arguments

ts

A taxa summary dataframe as generated by summarize_taxonomy.

metadata_map

A metadata mapping dataframe. Usually, input$map_loaded.

block_header

The header name from the metadata map that contains the block (i.e. sample group) designations.

treatment_header

The header name from the metadata map that contains the treatment designations including which samples are controls.

control_label

The designation within the treatment_header column that corresponds to the control samples.

zero_substitute

[OPTIONAL] A value to substitute in for zeros to avoid infinite percent changes. It can be appropriate to use a lower detection limit for this value.

Examples

# calculate the percent difference in organic from conventional for each 
# fruit/veggie
ts = summarize_taxonomy(fruits_veggies, level = 2)
ts_filt = filter_taxa_from_table(ts, filter_thresh = 0.01)
calc_taxa_changes(ts_filt, fruits_veggies$map_loaded, 'Sample_type',
                  'Farm_type', 'Conventional')

leffj/mctoolsr documentation built on Aug. 5, 2022, 1:27 a.m.