| Title: | Integral Analysis of Diversity Based on Hill Numbers |
|---|---|
| Description: | Measures and compares the diversity of biological communities (e.g. tables of operational taxonomic units (OTUs), amplicon sequence variants (ASVs) or metagenome-assembled genomes (MAGs)) based on Hill numbers, in a unified framework for neutral, phylogenetic and functional diversity measurement, diversity partitioning, (dis)similarity measurement, diversity profiles, evenness, redundancy and attribution of Hill power-sum weight and beta dissimilarity to taxa and sets. The statistical framework encompasses richness, Shannon and Simpson diversity, Faith's phylogenetic diversity (PD), Rao's quadratic entropy and Sorensen- and UniFrac-type dissimilarities, all grounded in a single Hill-number framework. Methods are described in Jost (2007) <doi:10.1890/06-1736.1>, Chao et al. (2010) <doi:10.1098/rstb.2010.0272>, Chiu et al. (2014) <doi:10.1890/12-0960.1> and reviewed in Alberdi & Gilbert (2019) <doi:10.1111/1755-0998.13014>. Optional import adapters interoperate with the Bioconductor packages 'phyloseq', 'SummarizedExperiment' and 'TreeSummarizedExperiment', which are available from <https://bioconductor.org>. |
| Authors: | Antton Alberdi [aut, cre] (ORCID: <https://orcid.org/0000-0002-2875-6446>) |
| Maintainer: | Antton Alberdi <[email protected]> |
| License: | GPL-3 |
| Version: | 3.1.0.9000 |
| Built: | 2026-10-08 09:19:58 UTC |
| Source: | https://github.com/alberdilab/hilldiv3 |
A small, simulated example data set representing metagenome-assembled
genome (MAG) abundances across host samples from two groups (control and
treatment), where a block of MAGs is enriched in the treatment group so
that beta diversity is non-trivial. Generated by data-raw/make-data.R.
gut_countsgut_counts
An integer matrix with 24 rows (MAGs, mag01..mag24) and 12
columns (samples, ctrl01..ctrl06 and trt01..trt06).
hilldiv(gut_counts, q = c(0, 1, 2))hilldiv(gut_counts, q = c(0, 1, 2))
A trait table for the 24 MAGs in gut_counts, mixing continuous, categorical
and binary traits. Convert it to a functional distance with traits2dist()
for the functional-diversity paths.
gut_traitsgut_traits
A data frame with 24 rows (MAGs) and 4 columns:
Approximate genome size in Mbp (numeric).
GC content as a proportion (numeric).
Oxygen tolerance: aerobe, anaerobe or facultative (factor).
Motility indicator, 0/1 (integer).
gut_counts, gut_tree, traits2dist()
d <- traits2dist(gut_traits) hilldiv(gut_counts, q = c(0, 1), dist = d)d <- traits2dist(gut_traits) hilldiv(gut_counts, q = c(0, 1), dist = d)
An ultrametric coalescent tree over the 24 MAGs in gut_counts, scaled to unit depth. Use it for the phylogenetic-diversity paths.
gut_treegut_tree
A phylo object (see the ape package) with 24 tips whose
labels match the rows of gut_counts.
hilldiv(gut_counts, q = c(0, 1), tree = gut_tree)hilldiv(gut_counts, q = c(0, 1), tree = gut_tree)
Show which taxa contribute most to dissimilarity between every pair of
samples or among samples in a group. Default singleton-taxon contributions
are nonnegative and add up to the corresponding value from hillpair() or
hilldiss(). A taxon's
share is its fraction of that dissimilarity; it is NA when the
dissimilarity is zero.
hillcontrib( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), by = c("pairwise", "collective"), groups = NULL, sets = NULL )hillcontrib( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), by = c("pairwise", "collective"), groups = NULL, sets = NULL )
data |
A count table (taxa x samples) or a supported object; a single sample is not meaningful for partitioning. |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
metric |
Dissimilarity metric(s) to return, any of |
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
by |
|
groups |
For |
sets |
An optional named list of character vectors of taxon names,
as in |
For each taxon (or phylogenetic branch), the contribution kernel is the
Jensen gap between its pooled abundance and its abundances across samples.
The gap is zero if its abundance is constant. At q = 0 the gap measures
uneven occurrence; at q = 1 it is the entropy gap; at other orders it is
the power-sum gap. For neutral and functional diversity the kernel belongs
directly to a taxon. For phylogenetic diversity each branch's gap is
assigned to descendant taxa in proportion to their own neutral Jensen
gaps at the same order. This is one explicit allocation of shared branches,
rather than a unique taxon-level decomposition of phylogenetic turnover.
The kernel fractions are multiplied by the selected dissimilarity metric.
Thus singleton-taxon contributions add exactly to that metric, while their
relative ranking is the same for S, C, U, and V at a given order and
comparison.
Zero-length branches and taxa absent from every selected sample receive
zero. Every selected sample must have a positive total. Functional beta
uses the package's raw-count partitioning, so unequal sample totals can
contribute to functional dissimilarity even when relative composition is
unchanged.
A data frame with columns first, second, group, q, type,
metric, set, contribution, share, and rank. Pairwise rows use
first and second; collective rows use group. Rows are ranked from
largest to smallest contribution within each comparison, order, and
metric. Sets that omit taxa sum to less than the total dissimilarity;
overlapping sets can sum to more.
hillshare(), hillpair(), hilldiss()
counts <- matrix(c(5, 0, 2, 3, 4, 0, 0, 2, 6), nrow = 3, dimnames = list(c("A", "B", "C"), c("s1", "s2", "s3"))) hillcontrib(counts, q = 1, metric = "C") hillcontrib(counts, q = 1, metric = "C", by = "collective")counts <- matrix(c(5, 0, 2, 3, 4, 0, 0, 2, 6), nrow = 3, dimnames = list(c("A", "B", "C"), c("s1", "s2", "s3"))) hillcontrib(counts, q = 1, metric = "C") hillcontrib(counts, q = 1, metric = "C", by = "collective")
Compute overall (multi-sample) dissimilarity metrics from the Hill-number
beta diversity following Chiu et al. (2014). These are the complements of the
similarities returned by hillsim().
hilldiss( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )hilldiss( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )
data |
A count table (taxa x samples) or a supported object; a single sample is not meaningful for partitioning. |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
metric |
Dissimilarity metric(s) to return, any of |
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
out |
Output shape: |
A long-format data.frame of class hill_dissimilarity (default,
with a plot() method), or a matrix/vector of dissimilarities when
out = "matrix".
hillsim(), hillpair(), hillpart()
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hilldiss(counts) plot(hilldiss(counts))counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hilldiss(counts) plot(hilldiss(counts))
Compute neutral, phylogenetic and/or functional Hill numbers (alpha
diversity) from a single sample or a count table. By default the computation
is cumulative: every diversity type whose inputs are present is returned.
Counts are always available, so neutral is always computed; a tree adds
phylogenetic and a dist adds functional. Supplying both a tree and a
dist therefore returns neutral, phylogenetic and functional side by side in
a single tibble (with a type column). Use type to restrict the output to
a subset.
hilldiv( data, q = c(0, 1, 2), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), reference = c("pool", "sample"), out = c("tibble", "matrix") )hilldiv( data, q = c(0, 1, 2), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), reference = c("pool", "sample"), out = c("tibble", "matrix") )
data |
Counts: a numeric vector (one sample), a matrix/data.frame
(taxa x samples), a |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type(s) to compute. |
reference |
Reference tree depth for phylogenetic Hill numbers
(ignored for neutral and functional types). |
out |
Output shape: |
A long-format data.frame of class hill_diversity (default). With
out = "matrix", a matrix of Hill numbers (samples in rows, diversity
orders q0, q1, ... in columns) for a single type, or a named list of
such matrices when several types are computed.
Chao, A., Chiu, C.-H. & Jost, L. (2010). Phylogenetic diversity measures
based on Hill numbers. Phil. Trans. R. Soc. B, 365, 3599-3609.
Alberdi, A. & Gilbert, M.T.P. (2019). A guide to the application of Hill
numbers to DNA-based diversity analyses. Mol. Ecol. Resour., 19, 804-817.
hillpart(), hilldiss(), hillprof()
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hilldiv(counts) hilldiv(counts, q = c(0, 1, 2)) plot(hilldiv(counts, q = c(0, 1, 2))) # Supplying both a tree and a distance matrix returns neutral, phylogenetic # and functional diversity together, distinguished by a `type` column. tree <- ape::read.tree(text = "((t1:1,t2:1):1,t3:2);") dist <- as.matrix(stats::dist(c(t1 = 0, t2 = 1, t3 = 4))) hilldiv(counts, tree = tree, dist = dist) # Restrict the output with `type` (a scalar or a vector): hilldiv(counts, tree = tree, dist = dist, type = c("neutral", "functional"))counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hilldiv(counts) hilldiv(counts, q = c(0, 1, 2)) plot(hilldiv(counts, q = c(0, 1, 2))) # Supplying both a tree and a distance matrix returns neutral, phylogenetic # and functional diversity together, distinguished by a `type` column. tree <- ape::read.tree(text = "((t1:1,t2:1):1,t3:2);") dist <- as.matrix(stats::dist(c(t1 = 0, t2 = 1, t3 = 4))) hilldiv(counts, tree = tree, dist = dist) # Restrict the output with `type` (a scalar or a vector): hilldiv(counts, tree = tree, dist = dist, type = c("neutral", "functional"))
Evenness expressed through Hill numbers as the ratio of diversity of order
q to richness (qD / 0D), which ranges from 0 to 1.
hilleven( data, q = c(1, 2), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )hilleven( data, q = c(1, 2), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )
data |
Counts: a numeric vector (one sample), a matrix/data.frame
(taxa x samples), a |
q |
Numeric vector of diversity orders (> 0 are meaningful for
evenness). Defaults to |
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
out |
Output shape: |
A long-format data.frame of class hill_evenness (default) with a
plot() method, or a matrix of evenness values (samples in rows, orders in
columns) when out = "matrix".
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hilleven(counts) plot(hilleven(counts, q = c(1, 1.5, 2)))counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hilleven(counts) plot(hilleven(counts, q = c(1, 1.5, 2)))
Compute dissimilarity metrics for every pair of samples, returning distance objects suitable for ordination (e.g. NMDS, PCoA).
hillpair( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("dist", "tibble"), parallel = FALSE )hillpair( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("dist", "tibble"), parallel = FALSE )
data |
A count table (taxa x samples) or a supported object; a single sample is not meaningful for partitioning. |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
metric |
Dissimilarity metric(s) to return, any of |
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
out |
Output type: |
parallel |
Logical; if |
The type-specific structure (per-sample normalisation, the tree traversal or
the functional similarity product) is computed once over all samples via
the partitioning engine; each pair then only combines its two precomputed
columns into beta, which is turned into the requested overlap metrics. The
maths are therefore identical to hilldiss() on two samples, without
re-running the full engine per pair. When parallel = TRUE and the furrr
package is installed, pairs are computed in parallel via the active future
plan. A progressr progress bar is reported when that package is installed
and a handler is active.
For out = "dist", a named list of dist objects (one per
order/metric, named e.g. "q0S"), collapsed to a single dist when only
one combination is requested. For out = "tibble", a long-format
data.frame with columns first, second, q, metric, value.
counts <- matrix(c(10, 0, 5, 2, 8, 1, 3, 4, 0, 6, 2, 7), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2", "s3", "s4"))) hillpair(counts, q = 1, metric = "C")counts <- matrix(c(10, 0, 5, 2, 8, 1, 3, 4, 0, 6, 2, 7), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2", "s3", "s4"))) hillpair(counts, q = 1, metric = "C")
Partition neutral, phylogenetic or functional Hill-number diversity into
alpha, gamma and beta components across a set of samples. With a hierarchy
formula it instead performs multi-scale (nested) partitioning, returning
one beta per hierarchical level.
hillpart( data, q = c(0, 1, 2), tree = NULL, dist = NULL, tau = NULL, hierarchy = NULL, metadata = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )hillpart( data, q = c(0, 1, 2), tree = NULL, dist = NULL, tau = NULL, hierarchy = NULL, metadata = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )
data |
A count table (taxa x samples) or a supported object; a single sample is not meaningful for partitioning. |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
hierarchy |
Optional one-sided nesting formula, coarsest to finest, e.g.
|
metadata |
Optional per-sample |
type |
Diversity type: |
out |
Output shape: |
A long-format data.frame of class hill_partition (default) with a
plot() method, or a matrix with columns alpha, gamma, beta and
diversity orders in rows when out = "matrix". With hierarchy, a
hill_hierarchy long-format data.frame (with its own plot() method) or
the corresponding wide matrix.
hilldiv(), hilldiss(), hillsim()
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hillpart(counts) plot(hillpart(counts)) # Multi-scale partitioning across a nested design. set.seed(1) tab <- matrix(rpois(12 * 8, 5), nrow = 12, dimnames = list(paste0("t", 1:12), paste0("s", 1:8))) md <- data.frame(region = rep(c("N", "S"), each = 4), site = rep(c("a", "b", "c", "d"), each = 2), row.names = paste0("s", 1:8)) hillpart(tab, hierarchy = ~ region / site, metadata = md)counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hillpart(counts) plot(hillpart(counts)) # Multi-scale partitioning across a nested design. set.seed(1) tab <- matrix(rpois(12 * 8, 5), nrow = 12, dimnames = list(paste0("t", 1:12), paste0("s", 1:8))) md <- data.frame(region = rep(c("N", "S"), each = 4), site = rep(c("a", "b", "c", "d"), each = 2), row.names = paste0("s", 1:8)) hillpart(tab, hierarchy = ~ region / site, metadata = md)
Compute a diversity profile: Hill numbers evaluated over a fine sweep of
diversity orders q. Profiles are the standard diagnostic for comparing the
diversity of assemblages, since the ranking of samples can change with q.
hillprof( data, q = seq(0, 3, by = 0.1), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), reference = c("pool", "sample"), out = c("tibble", "matrix") )hillprof( data, q = seq(0, 3, by = 0.1), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), reference = c("pool", "sample"), out = c("tibble", "matrix") )
data |
Counts: a numeric vector (one sample), a matrix/data.frame
(taxa x samples), a |
q |
Numeric vector of diversity orders to evaluate. Defaults to a fine sweep from 0 to 3. |
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
reference |
Reference tree depth for phylogenetic Hill numbers
(ignored for neutral and functional types). |
out |
Output type: |
A long-format data.frame of class hill_profile (columns q,
sample, value) with a plot() method, or a matrix
(samples in rows, orders in columns) when out = "matrix".
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) prof <- hillprof(counts) plot(prof)counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) prof <- hillprof(counts) plot(prof)
Estimate phylogenetic or functional redundancy by fitting the saturating
relationship between neutral diversity and phylogenetic/functional diversity
across samples: y = -a * 2^(-x / b) + c. Redundancy is summarised as
1 - b / max(x).
hillred( data, q = c(0, 1, 2), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "phylogenetic", "functional"), reference = c("pool", "sample"), out = c("tibble", "matrix") )hillred( data, q = c(0, 1, 2), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "phylogenetic", "functional"), reference = c("pool", "sample"), out = c("tibble", "matrix") )
data |
A count table (taxa x samples); requires either |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
reference |
Reference tree depth for phylogenetic Hill numbers
(ignored for neutral and functional types). |
out |
Output shape: |
A data.frame of class hill_redundancy (default) with a
plot() method, or a matrix with columns
redundancy, a, b, c (one row per q) when out = "matrix". The
tibble carries the per-sample neutral and phylogenetic/functional diversity
used for the fit as a "hill_fit" attribute, which the plot method draws.
hilldiv(), plot.hill_redundancy()
d <- traits2dist(gut_traits) red <- hillred(gut_counts, dist = d) red plot(red)d <- traits2dist(gut_traits) red <- hillred(gut_counts, dist = d) red plot(red)
Compute overall similarity metrics from the Hill-number beta diversity
(Chiu et al. 2014). These are 1 - the dissimilarities from hilldiss().
hillsim( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )hillsim( data, q = c(0, 1, 2), metric = c("S", "C", "U", "V"), tree = NULL, dist = NULL, tau = NULL, type = c("auto", "neutral", "phylogenetic", "functional"), out = c("tibble", "matrix") )
data |
A count table (taxa x samples) or a supported object; a single sample is not meaningful for partitioning. |
q |
Numeric vector of diversity orders (>= 0). Defaults to
|
metric |
Dissimilarity metric(s) to return, any of |
tree |
A phylogenetic tree of class |
dist |
A functional distance matrix (or |
tau |
Optional functional distance threshold. Defaults to |
type |
Diversity type: |
out |
Output shape: |
A long-format data.frame of class hill_similarity (default, with
a plot() method), or a matrix/vector of similarities when
out = "matrix".
counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hillsim(counts) plot(hillsim(counts))counts <- matrix(c(10, 0, 5, 2, 8, 1), nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) hillsim(counts) plot(hillsim(counts))
Subsets and reorders a count table so that its taxa match those of a
phylogenetic tree or a functional distance matrix, dropping taxa absent from
the reference. This realises the match_data() helper that hilldiv2's
documentation referred to but never provided.
match_data(data, tree = NULL, dist = NULL)match_data(data, tree = NULL, dist = NULL)
data |
A count matrix/data.frame (taxa x samples) with row names. |
tree |
A |
dist |
A distance matrix (optional). |
The count matrix restricted to and ordered by the shared taxa.
counts <- matrix(1:6, nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) tree <- ape::read.tree(text = "((t1:1,t2:1):1,t4:2);") match_data(counts, tree = tree)counts <- matrix(1:6, nrow = 3, dimnames = list(c("t1", "t2", "t3"), c("s1", "s2"))) tree <- ape::read.tree(text = "((t1:1,t2:1):1,t4:2);") match_data(counts, tree = tree)
Base-graphics plot of a hillprof() result: one line per sample showing the
Hill number against the diversity order q.
## S3 method for class 'hill_profile' plot(x, ...)## S3 method for class 'hill_profile' plot(x, ...)
x |
A |
... |
Further arguments passed to |
The hill_profile object, invisibly.
Base-graphics plot of a hillred() result. For each diversity order q it
shows the per-sample neutral diversity (x) against phylogenetic/functional
diversity (y), overlaid with the fitted saturating curve
y = -a * 2^(-x / b) + c. A curve that bends sharply and plateaus well below
the points' spread indicates high redundancy; a near-linear fit indicates
low redundancy. This mirrors the profile plot of hillprof().
## S3 method for class 'hill_redundancy' plot(x, ...)## S3 method for class 'hill_redundancy' plot(x, ...)
x |
A |
... |
Further arguments passed to |
The hill_redundancy object, invisibly.
hillred(), plot.hill_profile()
Build a pairwise functional distance matrix from a table of taxon traits,
suitable as the dist argument of hilldiv() and friends.
traits2dist(traits, method = c("gower", "euclidean", "manhattan"))traits2dist(traits, method = c("gower", "euclidean", "manhattan"))
traits |
A table with taxa (OTUs/ASVs/MAGs) in rows and traits in columns. Traits may be continuous, binary or proportional. |
method |
Distance metric passed to |
A numeric distance matrix.
traits <- data.frame(body = c(1, 0.2, 0.9), diet = c(0L, 1L, 1L), row.names = c("t1", "t2", "t3")) traits2dist(traits)traits <- data.frame(body = c(1, 0.2, 0.9), diet = c(0L, 1L, 1L), row.names = c("t1", "t2", "t3")) traits2dist(traits)
Normalise a numeric vector or count matrix so that each sample (column) sums
to one. Columns that sum to zero are returned as all-zero (the 0/0 = NaN
case is mapped to 0).
tss(abund)tss(abund)
abund |
A numeric vector or a matrix/data.frame of counts with taxa (OTUs/ASVs/MAGs) in rows and samples in columns. |
A normalised object of the same shape as abund (vector in, vector
out; matrix/data.frame in, matrix out).
tss(c(a = 1, b = 3)) tss(matrix(c(1, 0, 3, 0, 0, 2), nrow = 3))tss(c(a = 1, b = 3)) tss(matrix(c(1, 0, 3, 0, 0, 2), nrow = 3))