permute_pam: permute_pam: Function to permute a Presence-Absence-Matrix.

View source: R/permute_pam.R

permute_pamR Documentation

permute_pam: Function to permute a Presence-Absence-Matrix.

Description

permute_pam: Function to permute a Presence-Absence-Matrix.

Usage

permute_pam(m, niter = NULL, as_sparse = FALSE)

Arguments

m

Presence-Absence-Matrix (PAM) or a binary matrix with columns representing species and rows sites.

niter

Number of itereations to permute the PAM.

as_sparse

If TRUE the PAM will be returned as a sparse matrix

Details

This function is an implementation of the curve ball algorithm following \insertRefStrona2014bam.

Value

Returns a list of length equal to the number of sites in the PAM (n=nrows(m)). Each entrie of the list has the permuted species.

Author(s)

Luis Osorio-Olvera & Jorge SoberĂ³n

Examples

set.seed(111)
pam <- matrix(rbinom(100,1,0.3),nrow = 10,ncol = 10)
ppam <- bam::permute_pam(m = pam,niter = NULL,as_sparse = FALSE)
# Check if matrices are different
all(pam == ppam)
# Check if row totals are the same
all(Matrix::rowSums(pam) == Matrix::rowSums(ppam))
# Check if column total are the same
all(Matrix::colSums(pam) == Matrix::colSums(ppam))

luismurao/bam documentation built on Nov. 28, 2022, 3:02 p.m.