Depth-robust alpha diversity residuals (McKnight / Mikryukov)
Source:R/normalize_pq.R
mcknight_residuals_pq.RdComputes the residuals from a linear regression of \(\log(\text{richness})\) against \(\log(\text{sequencing depth})\) as a depth-robust alpha diversity metric (Mikryukov et al. 2023; McKnight et al. 2018, doi:10.5061/dryad.tn8qs35 ). This avoids discarding data through rarefaction.
Arguments
- physeq
(required) a
phyloseq-classobject obtained using thephyloseqpackage.- add_to_sam_data
(logical, default
TRUE) ifTRUE, a columnmcknight_residualsis added tosample_data(physeq)and the augmented phyloseq object is returned. IfFALSE, the numeric residuals vector is returned.
Value
Either a phyloseq object with an augmented sample_data (default)
or a named numeric vector of residuals.
Examples
data_f_res <- mcknight_residuals_pq(data_fungi_mini)
head(sample_data(data_f_res)$mcknight_residuals)
#> [1] 0.3273090 -0.1430749 0.5681529 0.7310108 -0.7698491 0.4374109