Learn R Programming

CountClust (version 1.0.2)

nullmodel_GoM: Null models for Grade of Membership (GoM) cluster validation

Description

Use null models (popular in ecology) to generate randomized matrix of counts given the observed data matrix, fit the GoM model to these null matrices and compare the fit on null model data with that on the observed data. Used for validating the GoM clusters

Usage

nullmodel_GoM(counts, K, tol = 0.1, null.model = c("frequency", "richness", "independentswap", "trialswap"), iter_fill = 1000, iter_randomized = 100, plot = TRUE)

Arguments

counts
The counts matrix (N x G): N- the number of samples, G- number of features
K
The number of clusters to fit
tol
The tolerance of the GoM model fitted
null.model
The type of nullmodel used (similar to the 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 of log Bayes factor

Value

Returns a list with
GoMBF.obs
log BF for the observed counts with K=2 against the null with no clusters
GoMBF.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

Run this code

data("ex.counts")
nullmodel_GoM(ex.counts,
              K=2,
              tol=500,
              null.model="frequency",
              iter_randomized=3,
              plot=FALSE)

Run the code above in your browser using DataLab