# load library
# library(variancePartition)
# optional step to run analysis in parallel on multicore machines
# Here, we used 4 threads
library(doParallel)
cl <- makeCluster(4)
registerDoParallel(cl)
# or by using the doSNOW package
# load simulated data:
data(varPartData)
# specify formula
form <- ~ Age + (1|Individual) + (1|Tissue)
# fit and return linear mixed models for each gene
fitList <- fitVarPartModel( geneExpr[1:10,], form, info )
# Focus on the first gene
fit = fitList[[1]]
# plot correlation sturcture based on Individual, reordering samples with hclust
plotCorrStructure( fit, "Individual" )
# don't reorder
plotCorrStructure( fit, "Individual", reorder=FALSE )
# plot correlation sturcture based on Tissue, reordering samples with hclust
plotCorrStructure( fit, "Tissue" )
# don't reorder
plotCorrStructure( fit, "Tissue", FALSE )
# plot correlation structure based on all random effects
# reorder manually by Tissue and Individual
idx = order(info$Tissue, info$Individual)
plotCorrStructure( fit, reorder=idx )
# plot correlation structure based on all random effects
# reorder manually by Individual, then Tissue
idx = order(info$Individual, info$Tissue)
plotCorrStructure( fit, reorder=idx )
# stop cluster
stopCluster(cl)
Run the code above in your browser using DataLab