permutation.pvalues.b: Produces the p-values of a beta diversity measure f on a...

Description Usage Arguments Value Author(s) References See Also Examples

Description

Given a matrix M and a beta diversity measure f, the function calculates the p-values of f based on the permutation null model.

Usage

1
permutation.pvalues.b(matrix, f, args, observed.vals, reps=1000)

Arguments

matrix

A matrix with integer values. The matrix should not contain any NA values.

f

A beta diversity function f. The interface of f should be such that f(matrix,args) returns a matrix V where the entry stored at the i-th row and j-th column of V is equal to the value of f when applied at the i-th and j-th row of the input matrix. To fit this interface, the user might have to develop f as a wrapper around an existing R function (see Examples).

args

A list with extra arguments needed by f.

observed.vals

A set of pre-calculated values for which we want to compute their p-values.

reps

The number of randomizations. This argument is optional and its default value is set to one thousand.

Value

A numeric vector that stores the p-values of f, calculated based on the permutation null model. The i-th element of the vector stores the p-value for the i-th element in vector observed.vals.

Author(s)

Constantinos Tsirogiannis (tsirogiannis.c@gmail.com)

References

Gotelli, N. J., 2000. Null Model Analysis of Species Co-Occurrence Patterns. Ecology, 81(9), pp.2606-2621.

Tsirogiannis, C., A. Kalvisa, B. Sandel and T. Conradi. Column-Shuffling Null Models Are Simpler Than You Thought. To appear.

See Also

permutation.communities.b

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#In the next example null-model calculations are
#performed using a function of phylogenetic diversity.
#Hence, we first load the required packages.
require(CNull)
require(ape)
require(PhyloMeasures)

#Load phylogenetic tree of bird families from package "ape"
data(bird.families, package = "ape")

#Create 100 random communities with 50 families each
comm = matrix(0,nrow = 100,ncol = length(bird.families$tip.label))
for(i in 1:nrow(comm)) {comm[i,sample(1:ncol(comm),50)] = 1}
colnames(comm) = bird.families$tip.label

#Set function f to be the Common Branch Length measure (CBL)
#as defined in the R package PhyloMeasures.
my.f = function(mt,args){ return (cbl.query(args[[1]],mt))}

# This function takes one extra argument, which is a phylogenetic tree.
# Hence, create a list whose only element is the desired tree.
arguments = list()
arguments[[1]] = bird.families

#Compute the values of f for all pairs of observed communities in M.
#Turn the resulting matrix with the observed diversity values into a vector  
obs.v=my.f(comm,arguments)
vals = as.vector(t(obs.v))

# Calculate the p-values of f for the communities in comm 
# based on the permutation model, using 2000 Monte Carlo randomizations.
permutation.pvalues.b(comm,f=my.f,args=arguments,observed.vals=vals,reps=2000)

CNull documentation built on May 2, 2019, 1:44 p.m.