get quantiles from the genotypes

Share:

Description

get quantiles from the genotypes

Usage

1
getQuantiles(data, snp.name, trait.name, cov.names, n = 100, progress.bar = T)

Arguments

data
snp.name
trait.name
cov.names
n
progress.bar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (data, snp.name, trait.name, cov.names, n = 100, progress.bar = T) 
{
    quantiles <- c()
    data.tmp <- data
    phdata(data.tmp) <- cbind(phdata(data.tmp), simpheno = rep(0, 
        nids(data)))
    snp.num <- which(snpnames(data) == snp.name)
    if (progress.bar) {
        pb <- txtProgressBar(style = 3)
    }
    for (i in 1:n) {
        simulated.phenotype <- getSimulatedPhenotype(data, snp.name, 
            trait.name, covars = cov.names)
        phdata(data.tmp)$simpheno <- simulated.phenotype
        form <- paste("simpheno ~ ", paste(cov.names, collapse = "+"), 
            sep = "")
        an0 <- try(qtscore(as.formula(form), data.tmp))
        if (typeof(an0) != "try-error") {
            pvals <- an0@results$P1df
            quantile <- rank(pvals)[snp.num]/nsnps(data)
            quantiles <- c(quantiles, quantile)
        }
        if (progress.bar) {
            setTxtProgressBar(pb, i/n)
        }
    }
    quantiles
  }