ecos_nullmodel: Null models for ecostructure_fit clustering validation

Description Usage Arguments Value Examples

View source: R/ecos_nullmodel.R

Description

Generate randomized matrix of counts given the observed data matrix for a particular null model, run ecos_fit on these null matrices and compare the fit on null model data with that on the observed data. Used for validating the clustering.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ecos_nullmodel(
  counts,
  K,
  tol = 0.1,
  null.model = c("frequency", "richness", "independentswap", "trialswap"),
  iter_fill = 100,
  iter_randomized = 30,
  option,
  plot = TRUE
)

Arguments

counts

The counts matrix (N x G): N- the number of samples (sites), G- number of features (bird species)

K

The number of clusters to fit

tol

The tolerance limit of the ecos_fit.

null.model

The type of nullmodel used (similar to the picante::randomizeMatrix() function argument in picante package)

iter_fill

The number of swaps/fills in each randomized matrix build

iter_randomized

The number of randomization matrices generated

plot

If TRUE, plots density function of log Bayes factor over the randomized iterations

Value

Returns a list with

BF.obs

log Bayes Factor for the observed counts with K=2 against the null with no clusters

BF.rand

a vector of log BF for each randomized count matrix with K=2 against the null with no clusters

pval

the p-value of the observed log Bayes factor against the ones from randomized matrices

Examples

1
2
3
4
5
6
7
data("himalayan_birds")
species_abundance_counts <- t(exprs(himalayan_birds));
out <- ecos_nullmodel(species_abundance_counts, K=2, 
                iter_randomized=5, option = "BF")
out2 <- ecos_nullmodel(species_abundance_counts, K=2, 
                iter_randomized=5, ption = "BIC")              
  

kkdey/ecostructure documentation built on Jan. 26, 2021, 4:10 p.m.