This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Parallelize association tests performed with the R package GENESIS

We have about 20 phenotypes to test for assosiation with the genotypes. Calculation took about 3 h per phenotype. Is there a way to speed up this process using parallelization. Here is the R code embedded in a for loop:

# load genotypes
geno <- GdsGenotypeReader(filename = "genotype.gds")
genoData <- GenotypeData(geno)
# pt contains the number of phenotypes
for(i in pt){
            # load phenotype which is stored in mydat
            phenotype <- data.frame(scanID = mydat$scanID,
                                    mydat[,i],
                                    sex = mydat$Sex)
            pheno <- colnames(mydat)[i]
            colnames(phenotype)[2] <- pheno
            scanAnnot <- ScanAnnotationDataFrame(phenotype)
           # fit null model using 'sex' as fixed effect and the genetic relationship matrix (GRM) as random effect
           nullmod <- fitNullModel(scanAnnot, outcome = pheno,
                                   covars = "sex",
                                   cov.mat = myGRM,
                                   family ="gaussian")
           # perform association test
           assoc <- assocTestSingle(genoData,
                                   null.model = nullmod)
           # save all results
           write.table(assoc, file = paste0(dir_results, pheno, "_sex_.assoc"))
           # save only significant results
           res <- assoc[which(-log10(assoc$Score.pval) > 6.5),]
           res <- res[order(res$Score.pval),]
           write.table(res, file = paste0(dir_results, pheno, "sigSNPs_GRM_sex.txt"))
}
close(genoData)
end <- proc.time()
end - begin

Thanks in advance for your answers.

Hermann

parallelization

Is there a way to speed up this process using parallelization

run a distcint instance of the code for each phenotype using a parallel tool; eg. Makefile -j <njobs> , snakemake , nextflow etc....

0 answers

No answers yet.

Log in to answer this question.