wad_wide | R Documentation |
Transforms weighted average density values into wide-format
wad_wide(
data,
tax_id = c(),
sample_id = c(),
wads = "wad",
iso_trt = c(),
isotope = c(),
average_light = TRUE
)
data |
Data as a long-format data.table where each row represents a taxonomic feature within a single fraction.
Typically, this is the output from the |
tax_id |
Column name specifying unique identifier for each taxonomic feature. |
sample_id |
Column name specifying unique identifier for each replicate. |
wads |
Column name specifying weighted average density values. |
iso_trt |
Column name specifying a two-level categorical column indicating whether a sample has been amended with a stable isotope (i.e., is "heavy") or if
isotopic composition is at natural abundance (i.e., "light").
Any terms may be applied but care should be taken for these values.
If supplied as a factor, |
average_light |
Whether to average the "light" WAD values. |
wad_wide
returns a wide-transformed data.table where each row represents a taxonomic feature within a single replicate.
If averaging unamended ("light") values is not performed, each taxon will have one numeric value and one NA
value based on whether it was present in an unamended "light" sample or an amended "heavy" sample.
If iso_trt
is not a factor, then it will be coerced to one and it will
return a message telling the user which value was assigned to which isotope labeling level.
Most users adopt a scheme of using the terms "light" and "label" to define their
treatments but please note that the word "label" comes first in the alphabet and
will be assigned by the function to be the unlabeled or light treatment.
If you wish to avoid this (you almost certainly do), you must specify your factor levels beforehand.
calc_wad
, calc_excess
# Load in example data
data(example_qsip)
# relativize sequence abundances (should be done after taxonomic filtering)
example_qsip[, rel_abund := seq_abund / sum(seq_abund), by = sampleID]
# ensure that the "light" treatment is the first factor level in the isotope treatment column
levels(example_qsip$iso_trt)
# calculate weighted average densities
wads <- calc_wad(example_qsip,
tax_id = 'asv_id', sample_id = 'sampleID', frac_id = 'fraction',
frac_dens = 'Density.g.ml', frac_abund = 'avg_16S_g_soil',
rel_abund = 'rel_abund',
grouping_cols = c('treatment', 'isotope', 'iso_trt', 'Phylum'))
# transform to wide format
ww <- wad_wide(wads, tax_id = 'asv_id', sample_id = 'sampleID',
iso_trt = 'iso_trt', isotope = 'isotope')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.