#####################################################
###
### Using forking with RAM objects
###
#####################################################
### Note to windows users: under Windows, this will
### result in sequential execution, as forking is not
### available.
## Get example input data and create data objects
data(inputEx)
## (this is not necessary, but is convenient;
## you could do the subsetting in the call themselves)
cgh.dat <- inputEx[, -c(1, 2, 3)]
chrom.dat <- as.integer(inputEx[, 2])
pos.dat <- inputEx[, 3]
## Segment with HaarSeg
haar.RAM.fork <- pSegmentHaarSeg(cgh.dat, chrom.dat,
merging = "MAD")
pChromPlot(haar.RAM.fork,
cghRDataName = cgh.dat,
chromRDataName = chrom.dat,
posRDataName = pos.dat,
imgheight = 350)
## Not run:
#
# #####################################################
# ###
# ### Using a cluster with ff objects and create imagemaps
# ###
# #####################################################
#
#
#
# ## Create a temp dir for storing output
# dir.create("ADaCGH2_plot_tmp_dir")
# originalDir <- getwd()
# setwd("ADaCGH2_plot_tmp_dir")
#
#
# ## Start a socket cluster. Change the appropriate number of CPUs
# ## for your hardware and use other types of clusters (e.g., MPI)
# ## if you want.
#
# cl2 <- makeCluster(4,"PSOCK")
# clusterSetRNGStream(cl2)
# setDefaultCluster(cl2)
# clusterEvalQ(NULL, library("ADaCGH2"))
# ## The following is not really needed if you create the cluster AFTER
# ## changing directories. But better to be explicit.
# wdir <- getwd()
# clusterExport(NULL, "wdir")
# clusterEvalQ(NULL, setwd(wdir))
#
#
# ## Get input data in ff format
# ## (we loaded the RData above, but we need to find the full path
# ## to use it in the call to inputToADaCGH)
#
# fname <- list.files(path = system.file("data", package = "ADaCGH2"),
# full.names = TRUE, pattern = "inputEx.RData")
#
# inputToADaCGH(ff.or.RAM = "ff",
# RDatafilename = fname)
#
#
#
# ## Segment with HaarSeg
#
# haar.ff.cluster <- pSegmentHaarSeg("cghData.RData",
# "chromData.RData",
# merging = "MAD",
# typeParall= "cluster")
#
# ## Save the output (an ff object) and plot
# save(haar.ff.cluster, file = "haar.ff.cluster.out.RData",
# compress = FALSE)
#
#
# pChromPlot(outRDataName = "haar.ff.cluster.out.RData",
# cghRDataName = "cghData.RData",
# chromRDataName = "chromData.RData",
# posRDataName = "posData.RData",
# probenamesRDataName = "probeNames.RData",
# imgheight = 350,
# imagemap = TRUE,
# typeParall= "cluster")
#
# ### Explicitly stop cluster
# stopCluster(NULL)
#
# ### Clean up (DO NOT do this with objects you want to keep!!!)
# load("chromData.RData")
# load("posData.RData")
# load("cghData.RData")
#
# delete(cghData); rm(cghData)
# delete(posData); rm(posData)
# delete(chromData); rm(chromData)
# unlink("chromData.RData")
# unlink("posData.RData")
# unlink("cghData.RData")
# unlink("probeNames.RData")
#
# lapply(haar.ff.cluster, delete)
# rm(haar.ff.cluster)
# unlink("haar.ff.cluster.out.RData")
#
# ### Try to prevent problems in R CMD check
# ## Sys.sleep(2)
#
#
# ### Delete all png files and temp dir
# setwd(originalDir)
# ## Sys.sleep(2)
# unlink("ADaCGH2_plot_tmp_dir", recursive = TRUE)
# ## Sys.sleep(2)
#
# ## End(Not run)
### PNGs are in this directory
getwd()
Run the code above in your browser using DataLab