# 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:
# geneExpr: matrix of gene expression values
# info: information/metadata about each sample
data(varPartData)
# Specify variables to consider
form <- ~ Age + (1|Individual) + (1|Tissue)
# Fit model
varPart <- fitExtractVarPartModel( geneExpr, form, info )
# Bar plot for a subset of genes showing variance fractions
plotPercentBars( varPart[1:5,] )
# Move the legend to the top
plotPercentBars( varPart[1:5,] ) + theme(legend.position="top")
# stop cluster
stopCluster(cl)
Run the code above in your browser using DataLab