distinctiveness_range: Alternative Truncated Functional Distinctiveness

View source: R/distinctiveness_range.R

distinctiveness_rangeR Documentation

Alternative Truncated Functional Distinctiveness

Description

Computes functional distinctiveness from a site-species matrix (containing presence-absence or relative abundances) of species with provided functional distance matrix considering only species within a given range in the functional space. The sites-species matrix should have sites in rows and species in columns, similar to vegan package defaults.

Usage

distinctiveness_range(pres_matrix, dist_matrix, given_range, relative = FALSE)

Arguments

pres_matrix

a site-species matrix (presence-absence or relative abundances), with sites in rows and species in columns

dist_matrix

a species functional distance matrix

given_range

a numeric indicating the dissimilarity range at which the the influence of other species is not considered anymore

relative

a logical indicating if distinctiveness should be scaled relatively to the community (scaled by max functional distance among the species of the targeted community)

Details

The Functional Distinctiveness of a species is the average functional distance from a species to all the other in the given community. It is computed as such:

D_i (T) = ((Σ_(j = 0, j != i, T ≥ min(d_ij))^N d_ij * Ab_j) / (Σ_(j = 0, j != i, T ≥ min(d_ij))^N Ab_j)) * (1 - Σ_(j = 0, j != i, T ≥ min(d_ij))^N Ab_j),

with D_i the functional distinctiveness of species i, N the total number of species in the community and d_ij the functional distance between species i and species j. T is the chosen maximal range considered. When presence-absence are used Ab_j = 1/N and the term ≤ft(1 - \frac{ ∑\limits_{ j = 1 ~, j \neq i ~, d_{ij} ≤q T}^S Ab_j }{ N } \right) is replaced by 1. IMPORTANT NOTE: in order to get functional rarity indices between 0 and 1, the distance metric has to be scaled between 0 and 1.

Value

a similar matrix from provided pres_matrix with Distinctiveness values in lieu of presences or relative abundances, species absent from communities will have an NA value (see Note section)

Note

Absent species should be coded by 0 or NA in input matrices.

When a species is alone in its community the functional distinctiveness cannot be computed (denominator = 0 in formula), and its value is assigned as NaN.

For speed and memory efficiency sparse matrices can be used as input of the function using as(pres_matrix, "dgCMatrix") from the Matrix package. (see vignette("sparse_matrices", package = "funrar"))

Examples

data("aravo", package = "ade4")
# Site-species matrix
mat = as.matrix(aravo$spe)

# Compute relative abundances
mat = make_relative(mat)

# Example of trait table
tra = aravo$traits[, c("Height", "SLA", "N_mass")]
# Distance matrix
dist_mat = compute_dist_matrix(tra)

di = distinctiveness_range(pres_matrix = mat, dist_matrix = dist_mat, 0.2)
di[1:5, 1:5]


funrar documentation built on Sept. 23, 2022, 5:10 p.m.