Learn R Programming

CoGAPS (version 2.6.0)

gapsMapTestRun: gapsMapTestRun calls the C++ MCMC code and performs Bayesian matrix factorization returning the two matrices that reconstruct the data matrix; as opposed to gapsRun, this method takes an additional input specifying set patterns in the P matrix. Test procedures allow for the returning of the matrix and atomic information for A and P during each step of the equilibration and sampling.

Description

gapsMapTestRun calls the C++ MCMC code and performs Bayesian matrix factorization returning the two matrices that reconstruct the data matrix; as opposed to gapsRun, this method takes an additional input specifying set patterns in the P matrix. Test procedures allow for the returning of the matrix and atomic information for A and P during each step of the equilibration and sampling. .

Usage

gapsMapTestRun(D, S, FP, ABins = data.frame(), PBins = data.frame(), nFactor = 7,
  simulation_id = "simulation", nEquil = 1000, nSample = 1000,
  nOutR = 1000, output_atomic = FALSE, fixedMatrix="P", fixedBinProbs = FALSE,
  fixedDomain = "N", alphaA = 0.01, nMaxA = 1e+05, max_gibbmass_paraA = 100, 
  alphaP = 0.01, nMaxP = 1e+05, max_gibbmass_paraP = 100)

Arguments

D
data matrix
S
uncertainty matrix (std devs for chi-squared of Log Likelihood)
FP
data.frame with rows giving fixed patterns for P
ABins
a matrix of same size as A which gives relative probability of that element being non-zero
PBins
a matrix of same size as P which gives relative probability of that element being non-zero
nFactor
number of patterns (basis vectors, metagenes), which must be greater than or equal to the number of rows of FP
simulation_id
name to attach to atoms files if created
nEquil
number of iterations for burn-in
nSample
number of iterations for sampling
nOutR
how often to print status into R by iterations
output_atomic
whether to write atom files (large)
fixedMatrix
character indicating whether A or P matrix has fixed columns or rows respectively
fixedBinProbs
Boolean for using relative probabilities given in Abins and Pbins
fixedDomain
character to indicate whether A or P is domain for relative probabilities
alphaA
sparsity parameter for A domain
nMaxA
PRESENTLY UNUSED, future = limit number of atoms
max_gibbmass_paraA
limit truncated normal to max size
alphaP
sparsity parameter for P domain
nMaxP
PRESENTLY UNUSED, future = limit number of atoms
max_gibbmass_paraP
limit truncated normal to max size

Value

  • A list containing:
  • AmeanSampled mean value of the amplitude matrix ${\bf{A}}$.
  • AsdSampled standard deviation of the amplitude matrix ${\bf{A}}$.
  • PmeanSampled mean value of the amplitude matrix ${\bf{P}}$.
  • PsdSampled standard deviation of the amplitude matrix ${\bf{P}}$.
  • atomsAEquilNumber of atoms in ${\bf{A}}$ during each iteration of the equilibration phase.
  • atomsASampNumber of atoms in ${\bf{A}}$ during each iteration of the sampling phase.
  • atomsPEquilNumber of atoms in ${\bf{P}}$ during each iteration of the equilibration phase.
  • atomsPSampNumber of atoms in ${\bf{P}}$ during each iteration of the sampling phase.
  • chiSqValuesValue of $chi^2$ at each step during equilibration and sampling.
  • matricesAEquilState of the ${\bf{A}}$ matrix during each iteration of the equilibration phase.
  • matricesASampState of the ${\bf{A}}$ matrix during each iteration of the sampling phase.
  • matricesPEquilState of the ${\bf{P}}$ matrix during each iteration of the equilibration phase.
  • matricesPSampState of the ${\bf{P}}$ matrix during each iteration of the sampling phase.
  • domainAEquilA list containing the locations and magnitudes of the atoms of ${\bf{A}}$ during each iteration of the equilibration phase.
  • domainASampA list containing the locations and magnitudes of the atoms of ${\bf{A}}$ during each iteration of the sampling phase.
  • domainPEquilA list containing the locations and magnitudes of the atoms of ${\bf{P}}$ during each iteration of the equilibration phase.
  • domainPSampA list containing the locations and magnitudes of the atoms of ${\bf{P}}$ during each iteration of the sampling phase.
  • meanChi2Value of $chi^2$ for Amean and Pmean.

Details

The decomposition in GAPS is achieved by finding amplitude and pattern matrices (${\bf{A}}$ and ${\bf{P}}$, respectively) for which $${\bf{D}} = {\bf{A}}{\bf{P}} + \Sigma$$, where $\Sigma$ is the matrix of uncertainties given by S. The matrices $\bf{A}$ and $\bf{P}$ are assumed to have the atomic prior described in Sibisi and Skilling (1997) and are found with MCMC sampling.

See Also

CoGAPS

Examples

Run this code
## Load data
data('SimpSim')

## Specify the fixed pattern
mapP <- matrix(0,nrow=2,ncol=20)
mapP[1,1:10] <- 1
mapP[2,11:20] <- 1

## Run the GAPS matrix decomposition
nIter <- 10
testmap <- gapsMapTestRun(SimpSim.D, SimpSim.S, FP=mapP, 
                      nFactor=3,nEquil = nIter,nSample = nIter)

## Compare fixed patterns to input patterns (after scaling)
summary(t(testmap$Pmean[2:3,] - sweep(mapP,1,apply(mapP,1,sum),FUN="/")))

Run the code above in your browser using DataLab