calc_pop | R Documentation |
Calculates population growth and death rates
calc_pop(
data,
tax_id = c(),
sample_id = c(),
wads = "wad",
iso_trt = c(),
time = c(),
abund = "abund",
t0_grouping = c(),
mu = 0.6,
bootstrap = FALSE,
iters = 999L,
grouping_cols = c(),
min_freq = 3,
correction = TRUE,
rm_outliers = TRUE,
non_grower_prop = 0.1
)
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.
The default option is "wad" which is created by |
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, |
time |
Column name specifying the timepoint at which each sample was collected. For population rates, the lowest timepoint will be assumed to be the initial timepoints with which to base changes in abundances on. |
abund |
Column name specifying abundance measurement for each taxon in each sample.
The default option is "abund" which is created by |
mu |
Assumption of the fraction of oxygen atoms incorporated into new DNA that come from water (instead of from carbon sources) |
bootstrap |
Whether to generate bootstrapped enrichment values for each taxonomic feature across groups of samples.
If |
iters |
Integer specifying the number of bootstrap iterations to perform. |
grouping_cols |
Column(s) used to indicate bootstrap resampling groups. Within each group, replicates will be resampled with replacement. Resampling will not occur across groups. |
min_freq |
Minimum number of replicates a taxonomic feature must occur in to be kept. If treatment grouping columns are specified, frequencies will be assessed at this level. For unlabeled "light" samples, treatment groupings will be ignored when assessing adequate frequency of occurrence. |
correction |
Whether to apply a correction to fractional enrichment values to ensure a certain proportion are positive. |
rm_outlers |
Whether or not to remove fractional enrichment values that are 1.5X greater or lesser than the distance between the median and interquartile ranges. |
non_grower_group |
Fractional value applied if |
calc_pop
can only calculate growth rates with samples enriched in 18O.
As such, the isotope
parameter is not included here, but the user must ensure
that carbon and nitrogen isotopic samples are not included.
The default parameter for mu
is 0.6 which was determined by sensitivity analysis
to be the value which produced nearly all positive growth rates in a pilot study.
By default, calc_pop
averages the abundances of taxa from the initial time point.
If boostrap = TRUE
, replicates will be resampled (with replacement) then averaged so that
population rates are a product of bootstrapped abundances as well as densities.
calc_pop
returns a data.table where each row represents a taxonomic feature within a single replicate.
The following columns are produced: growth rate (growth
), mortality or turnover rate (mortality
).
Bootstrap functionality produces the columns: 2.5%
, 50%
, and 97.5%
reflecting the median bootstrapped rate value and the 95% confidence interval
of rate values.
In addition, probability that a taxon's enrichment was less than zero is represented
in the p_val
column which is based on the proportion sub-zero bootstrapped observations.
Growth and mortality rates are differentiated by the rate
column.
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.
Koch, Benjamin, et al. 2018. Estimating taxon-specific population dynamics in diverse microbial communities. Ecosphere 9.
calc_wad, wad_wide
# 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'))
# calculate population fluxes
rates <- calc_pop(wads, tax_id = 'asv_id', sample_id = 'sampleID',
iso_trt = 'iso_trt', time = 'timepoint')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.