Description Usage Arguments Details Value References See Also Examples

View source: R/knockoffs_snp.R

This function efficiently constructs group-knockoffs of 0,1,2 variables distributed according to the Li and Stephens model for unphased genotypes.

1 2 | ```
knockoffGenotypes(X, r, alpha, theta, groups = NULL, 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. |

`groups` |
a vector of length p containing group memberships for each variable. Indices are assumed to be monotone increasing, starting from 1 (default: NULL). |

`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). |

Generate group-knockoffs of unphased genotypes according to the Li and Stephens HMM. The required model parameters can be obtained through fastPHASE and loaded with loadHMM. This function is more efficient than knockoffHMM for haplotype data.

A 0,1,2 matrix of size n-by-p containing the knockoff variables.

sesia2019multiSNPknock

Other knockoffs: `knockoffDMC`

,
`knockoffHMM`

,
`knockoffHaplotypes`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
# 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,]
# Generate knockoffs
Xk = knockoffGenotypes(X, hmm$r, hmm$alpha, hmm$theta)
# Generate group-knockoffs for groups of size 3
groups = rep(seq(p), each=3, length.out=p)
Xk = knockoffGenotypes(X, hmm$r, hmm$alpha, hmm$theta, groups=groups)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.