epistatic.correlation:

Usage Arguments Examples

Usage

1
epistatic.correlation(gwas_id, gwas_p, pvalue = 1e-04, phenotype, genotype, parallel = 20)

Arguments

gwas_id
gwas_p
pvalue
phenotype
genotype
parallel

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
34
35
##---- 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 (gwas_id, gwas_p, pvalue = 1e-04, phenotype, genotype, 
    parallel = 20) 
{
    registerDoParallel(parallel)
    gwas <- cbind(gwas_id, gwas_p)
    gwas <- as.data.frame(gwas)
    gwas$gwas_p <- as.numeric(as.character(gwas$gwas_p))
    gwas <- gwas[gwas$gwas_id %in% colnames(genotype), ]
    cand <- gwas[gwas$gwas_p < pvalue, ]
    snp_matrix <- matrix(NA, nrow = nrow(cand), ncol = nrow(cand))
    rownames(snp_matrix) <- cand$gwas_id
    colnames(snp_matrix) <- cand$gwas_id
    cand <- which(gwas$gwas_p <= pvalue)
    for (i in 1:(nrow(snp_matrix) - 1)) {
        snp_matrix[i, (i + 1):nrow(snp_matrix)] <- foreach(j = (i + 
            1):nrow(snp_matrix), .combine = "rbind", .inorder = T, 
            .verbose = F) %dopar% {
            phenotype$SNP1 = as.numeric((genotype[, cand[i]]))
            phenotype$SNP2 = as.numeric((genotype[, cand[j]]))
            tmp_correlation = asreml(OI ~ 1 + SNP1 + SNP2 + SNP1 * 
                SNP2, na.method.X = "omit", na.method.Y = "omit", 
                data = phenotype)
            return(tmp_correlation$coefficients$fixed[1])
        }
    }
    new <- t(snp_matrix)
    diag(new) <- 1
    new[upper.tri(new)] <- snp_matrix[upper.tri(snp_matrix)]
    return(new)
  }

victorcarmelo/WISH_beta documentation built on May 3, 2019, 6:11 p.m.