CorrScatterPlot: Correlation Scatter Plots

Usage Arguments Examples

Usage

1
CorrScatterPlot(mEQTL, threshold, expr, genot, visual = TRUE, cis = TRUE)

Arguments

mEQTL
threshold
expr
genot
visual
cis

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
36
37
38
39
40
41
42
43
44
##---- 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 (mEQTL, threshold, expr, genot, visual = TRUE, cis = TRUE) 
{
    corr <- NULL
    phenotype <- NULL
    genotype <- NULL
    if (cis == TRUE) {
        index <- which(mEQTL$cis$eqtls$FDR <= threshold)
        eqtls <- mEQTL$cis$eqtls[index, ]
    }
    else {
        index <- which(mEQTL$trans$eqtls$FDR <= threshold)
        eqtls <- mEQTL$trans$eqtls[index, ]
    }
    for (i in 1:nrow(eqtls)) {
        phenotype[[i]] <- expr[which(expr$geneid == as.character(eqtls$gene[i])), 
            2:ncol(expr)]
        genotype[[i]] <- genot[which(genot$snpid == as.character(eqtls$snps[i])), 
            2:ncol(genot)]
        corr[i] <- cor(as.numeric(phenotype[[i]]), as.numeric(genotype[[i]]))
    }
    if (visual) {
        genotypes <- range(genot[, 2:ncol(genot)])[1]:range(genot[, 
            2:ncol(genot)])[2]
        for (i in 1:nrow(eqtls)) {
            geno <- as.numeric(genotype[[i]])
            pheno <- as.numeric(phenotype[[i]])
            values <- NULL
            for (j in 1:length(genotypes)) {
                values[[j]] <- pheno[which(genotype[[i]] == genotypes[j])]
            }
            plot(values, xlab = "miRNA Expression", ylab = "mRNA Expression", 
                main = paste(as.character(eqtls$snps[i]), " genotype", 
                  "\nCorrelation: ", format(corr[i], 2), "P-value: ", 
                  format(eqtls$pvalue[i], 2), " FDR: ", format(eqtls$FDR[i], 
                    2)))
        }
    }
    return(corr)
  }

shilab/meQTL_functions documentation built on May 29, 2019, 9:25 p.m.