Applying Matrix eQTL and recording the results for MT-eQTL analysis requies only minor adjustments to the standard code for running Matrix eQTL. Namely:
pvOutputThreshold.cis = 1;
pvOutputThreshold = 0;
noFDRsaveMemory = TRUE;
cat(file="df.txt", tissue, "\t", me$param$dfFull, "\n", append=TRUE);
### Run separately for every tissue
tissue = "Adipose";
################ Running Matrix eQTL ##########################
library("MatrixEQTL");
### Load genotype info
snps = SlicedData$new();
snps$LoadFile(paste0("genotypes/",tissue,".snps.txt"),
skipRows = 1, skipColumns = 1, sliceSize = 500);
### Load gene expression info
expr = SlicedData$new();
expr$LoadFile(paste0("expression/",tissue,".expr.txt"),
skipRows = 1, skipColumns = 1, sliceSize = 500);
### Load covariates
cvrt = SlicedData$new();
cvrt$LoadFile(paste0("covariates/",tissue,".covariates.txt"),
skipRows = 1, skipColumns = 1, sliceSize = 500);
### Load gene locations
geneloc = read.table("geneloc.txt",
sep = "\t", header = TRUE, stringsAsFactors = FALSE);
### Load SNP locations
snpsloc = read.table("snpsloc.txt",
sep = "\t", header = TRUE, stringsAsFactors = FALSE);
options(MatrixEQTL.dont.preserve.gene.object = TRUE);
### Run Matrix eQTL
me = Matrix_eQTL_main(
snps = snps,
gene = expr,
cvrt = cvrt,
output_file_name = "",
pvOutputThreshold = 0,
useModel = modelLINEAR,
errorCovariance = numeric(),
verbose = TRUE,
output_file_name.cis = paste0("eQTL_results_AL_",tissue,"_cis.txt"),
pvOutputThreshold.cis = 1,
snpspos = snpsloc,
genepos = geneloc,
cisDist = 1e5, #### cis window = 100kb
pvalue.hist = FALSE,
noFDRsaveMemory = TRUE);
### Save the number of degrees of freedom for each tissue
cat(file="df.txt", tissue, "\t", me$param$dfFull, "\n", append=TRUE);