as_bioregion_pairwise: Convert a matrix or list of matrices to a bioregion...

View source: R/as_bioregion_pairwise.R

as_bioregion_pairwiseR Documentation

Convert a matrix or list of matrices to a bioregion (dis)similarity object

Description

Converts a (dis)similarity matrix or a list of such matrices into a bioregion.pairwise object compatible with the bioregion package. The input can come from base R, dist objects, or outputs from other packages.

Usage

as_bioregion_pairwise(
  mat,
  metric_name = NULL,
  pkg = NULL,
  is_similarity = FALSE
)

Arguments

mat

A matrix, a dist object, or a list of these representing pairwise similarity or dissimilarity values to convert into a bioregion.pairwise object. This function can also directly handle outputs from other R packages (see the pkg argument).

metric_name

Optional character vector or single character string specifying the name of the (dis)similarity metric(s), which will appear as column names in the output (see Note).

pkg

An optional character string indicating the name of the package from which mat was generated (NULL by default, see Details). Available options are "adespatial", "betapart", "ecodist", or "vegan".

is_similarity

A logical value indicating whether the input data represents similarity (TRUE) or dissimilarity (FALSE).

Details

This function can directly handle outputs from ten functions across four packages:

  • adespatial: beta.div, beta.div.comp

  • betapart: beta.pair, beta.pair.abund, betapart.core, betapart.core.abund

  • ecodist: distance, bcdist

  • vegan: vegdist, designdist

See the documentation of these packages for more information:

  • https://cran.r-project.org/package=adespatial

  • https://cran.r-project.org/package=betapart

  • https://cran.r-project.org/package=ecodist

  • https://cran.r-project.org/package=vegan

Value

A dissimilarity or similarity object of class bioregion.pairwise, compatible with the bioregion package.

Note

If no specific package is specified (i.e., pkg = NULL), site names will be based on the row names of the first matrix. If row names are NULL, they will be generated automatically. If mat is a named list, those names will be used as column names only if metric_name = NULL.

Author(s)

Maxime Lenormand (maxime.lenormand@inrae.fr)
Boris Leroy (leroy.boris@gmail.com)
Pierre Denelle (pierre.denelle@gmail.com)

See Also

For more details illustrated with a practical example, see the vignette: https://biorgeo.github.io/bioregion/articles/a3_pairwise_metrics.html.

Associated functions: dissimilarity similarity bind_pairwise

Examples


mat <- matrix(runif(100), 10, 10)
rownames(mat) <- paste0("s",1:10)

pair <- as_bioregion_pairwise(list(mat,mat,mat), 
                              metric_name = NULL,
                              pkg = NULL,
                              is_similarity = FALSE)
                              

bioregion documentation built on March 29, 2026, 5:07 p.m.