fit_msn | R Documentation |
Implement Gibbs sampling for MSN model with no spatial random effects
fit_msn(Y, K, nsim = 2000, burn = 1000, z_init = NULL)
Y |
An n x g matrix of gene expression values. n is the number of cell spots and g is the number of features. |
K |
The number of mixture components to fit. |
nsim |
Number of total MCMC iterations to run. |
burn |
Number of MCMC iterations to discard as burn in. The number of saved samples is nsim - burn. |
z_init |
Optional initialized allocation vector. Randomly initialized if NULL. |
a list of posterior samples
## Not run:
# parameters
n <- 1000 #
number of observations
g <- 3 # number of features
K <- 3 # number of clusters (mixture components)
pi <- rep(1/K,K) # cluster membership probability
z <- sample(1:K, size = n, replace = TRUE, prob = pi) # cluster indicators
z <- remap_canonical2(z)
t_true <- truncnorm::rtruncnorm(n,0,Inf,0,1)
t <- t_true
# Cluster Specific Parameters
# cluster specific means
Mu <- list(
Mu1 = rnorm(g,-5,1),
Mu2 = rnorm(g,0,1),
Mu3 = rnorm(g,5,1)
)
# Cluster speficic skewness
Xi <- list(
Xi1 = rep(2,g),
Xi2 = rep(0,g),
Xi3 = rep(-3,g)
)
# cluster specific variance-covariance
S <- matrix(1,nrow = g,ncol = g) # covariance matrix
diag(S) <- 1.5
Sig <- list(
Sig1 = S,
Sig2 = S,
Sig3 = S
)
Y <- matrix(0, nrow = n, ncol = g)
for(i in 1:n)
{
Y[i,] <- mvtnorm::rmvnorm(1,mean = Mu[[z[i]]] + t[i]*Xi[[z[i]]],sigma = Sig[[z[i]]])
}
# fit model
fit1 <- fit_msn_clustering(Y,3,10,0)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.