# NOT RUN {
pheno.col <- 1:13
max.parents <- 12
size.qtlnet(pheno.col, max.parents)
# }
# NOT RUN {
## Compute all phenotype/parent combinations.
## This shows how to break up into many smaller jobs.
#########################################
## STEP 1: Preparation. Fast. Needed in steps 2 and 3.
pheno.col <- 1:13
max.parents <- 12
threshold <- 3.83
## Load cross object. Here we use internal object.
data(Pscdbp)
## or: load("Pscdbp.RData")
cross <- Pscdbp
## or: cross <- read.cross("Pscdbp.csv", "csv")
## Break up into groups to run on several machines.
## ~53 groups of ~1000, for a total of 53248 scanone runs.
parents <- parents.qtlnet(pheno.col, max.parents)
groups <- group.qtlnet(parents = parents, group.size = 1000)
## Save all relevant objects for later steps.
save(cross, pheno.col, max.parents, threshold, parents, groups,
file = "Step1.RData", compress = TRUE)
#########################################
## STEP 2: Compute BIC scores. Parallelize.
## NB: Configuration of parallelization determined using Step 1 results.
## Load Step 1 computations.
load("Step1.RData")
## Parallelize this:
for(i in seq(nrow(groups)))
{
## Pre-compute BIC scores for selected parents.
bic <- bic.qtlnet(cross, pheno.col, threshold,
max.parents = max.parents,
parents = parents[seq(groups[i,1], groups[i,2])])
save(bic, file = paste("bic", i, ".RData", sep = ""), compress = TRUE)
}
#########################################
## STEP 3: Sample Markov chain (MCMC). Parallelize.
## NB: n.runs sets the number of parallel runs.
n.runs <- 100
## Load Step 1 computations.
load("Step1.RData")
## Read in saved BIC scores and combine into one object.
bic.group <- list()
for(i in seq(nrow(groups)))
{
load(paste("bic", i, ".RData", sep = ""))
bic.group[[i]] <- bic
}
saved.scores <- bic.join(cross, pheno.col, bic.group)
## Parallelize this:
for(i in seq(n.runs))
{
## Run MCMC with randomized initial network.
mcmc <- mcmc.qtlnet(cross, pheno.col, threshold = threshold,
max.parents = max.parents, saved.scores = saved.scores, init.edges = NULL)
save(mcmc, file = paste("mcmc", i, ".RData", sep = ""), compress = TRUE)
}
#########################################
## STEP 4: Combine results for post-processing.
## NB: n.runs needed from Step 3.
n.runs <- 100
## Combine outputs together.
outs.qtlnet <- list()
for(i in seq(n.runs))
{
load(paste("mcmc", i, ".RData", sep = ""))
outs.qtlnet[[i]] <- mcmc
}
out.qtlnet <- c.qtlnet(outs.qtlnet)
summary(out.qtlnet)
print(out.qtlnet)
## End of parallel example.
#########################################
# }
# NOT RUN {
dim(Pscdbp.bic)
# }
Run the code above in your browser using DataLab