mcmcChain: Read MCMC chain associated with a BayesSpace clustering or...

View source: R/mcmcChain.R

mcmcChainR Documentation

Read MCMC chain associated with a BayesSpace clustering or enhancement

Description

BayesSpace stores the MCMC chain associated with a clustering or enhancement on disk in an HDF5 file. The mcmcChain() function reads any parameters specified by the user into a coda::mcmc object compatible with TidyBayes.

Usage

mcmcChain(sce, params = NULL)

removeChain(sce)

Arguments

sce

SingleCellExperiment with a file path stored in its metadata.

params

List of model parameters to read

Details

To interact with the HDF5 file directly, obtain the filename from the SingleCellExperiment's metadata: metadata(sce)$chain.h5. Each parameter is stored as a separate dataset in the file, and is represented as a matrix of size (n_iterations x n_parameter_indices). Parameter choices for the spot-level clustering include:

  • z (cluster assignments)

  • weights (w_i)

  • mu (mean vectors)

  • lambda (precision matrix)

  • plogLik (pseudo-log-likelihood)

Parameter choices for the subspot-level enhanced clustering include:

  • z (cluster assignments)

  • weights (w_i)

  • Y (enhanced PCs)

  • mu (mean vectors)

  • lambda (precision matrix)

  • Ychange (acceptance rate for the jittering of PCs)

For best results, Ychange should average between 0.25 and 0.40.

Value

Returns an mcmc object containing the values of the requested parameters over the constructed chain.

Examples

set.seed(149)
sce <- exampleSCE()
sce <- spatialCluster(sce, 7, nrep=100, burn.in=10, save.chain=TRUE)
chain <- mcmcChain(sce)
removeChain(sce)


edward130603/BayesSpace documentation built on May 11, 2023, 6:13 a.m.