fwGenotypes.Rd
This function samples the latent Markov chain of a hidden Markov model given the observed values, given an HMM for unphased genotypes.
fwGenotypes(X, r, alpha, theta, seed = 123, cluster = NULL, display_progress = FALSE)
X | a 0,1,2 matrix of size n-by-p containing the original variables. |
---|---|
r | a vector of length p containing the "r" parameters estimated by fastPHASE. |
alpha | a matrix of size p-by-K containing the "alpha" parameters estimated by fastPHASE. |
theta | a matrix of size p-by-K containing the "theta" parameters estimated by fastPHASE. |
seed | an integer random seed (default: 123). |
cluster | a computing cluster object created by makeCluster (default: NULL). |
display_progress | whether to show progress bar (default: FALSE). |
A 0,1,2 matrix of size n-by-p containing the knockoff variables.
Sesia M, Katsevich E, Bates S, Candès E, Sabatti C (2019). “Multi-resolution localization of causal variants across the genome.” bioRxiv. doi: 10.1101/631390 .
Other hmm: fwHMM
, fwHaplotypes
# Problem size p = 10 n = 100 # Load HMM to generate data r_file = system.file("extdata", "haplotypes_rhat.txt", package = "SNPknock") alpha_file = system.file("extdata", "haplotypes_alphahat.txt", package = "SNPknock") theta_file = system.file("extdata", "haplotypes_thetahat.txt", package = "SNPknock") char_file = system.file("extdata", "haplotypes_origchars", package = "SNPknock") hmm.data = loadHMM(r_file, alpha_file, theta_file, char_file, compact=FALSE, phased=FALSE) hmm.data$Q = hmm.data$Q[1:(p-1),,] hmm.data$pEmit = hmm.data$pEmit[1:p,,] # Sample X from this HMM X = sampleHMM(hmm.data$pInit, hmm.data$Q, hmm.data$pEmit, n=n) # Load HMM to generate knockoffs hmm = loadHMM(r_file, alpha_file, theta_file, char_file) hmm$r = hmm$r[1:p] hmm$alpha = hmm$alpha[1:p,] hmm$theta = hmm$theta[1:p,] # Forward-backward sampling H = fwGenotypes(X, hmm$r, hmm$alpha, hmm$theta)