#================================================
# Loading the library and its dependencies
#================================================
library("MVR")
#===================================================
# MVR package news
#===================================================
MVR.news()
#================================================
# MVR package citation
#================================================
citation("MVR")
#===================================================
# Loading of the Synthetic and Real datasets
# (see description of datasets)
#===================================================
data("Synthetic", "Real", package="MVR")
?Synthetic
?Real
#================================================
# Regularized t-test statistics (Synthetic dataset)
# Multi-Group Assumption
# Assuming unequal variance between groups
# With option to use prior MVR clustering results
# Without computation of p-values
# Without cluster usage
#================================================
nc.min <- 1
nc.max <- 10
probs <- seq(0, 1, 0.01)
n <- 10
GF <- factor(gl(n = 2, k = n/2, len = n),
ordered = FALSE,
labels = c("G1", "G2"))
mvr.obj <- mvr(data = Synthetic,
block = GF,
tolog = FALSE,
nc.min = nc.min,
nc.max = nc.max,
probs = probs,
B = 100,
parallel = FALSE,
conf = NULL,
verbose = TRUE)
mvrt.obj <- mvrt.test(obj = mvr.obj,
pval = FALSE,
parallel = FALSE,
conf = NULL,
verbose = TRUE)
#===================================================
# Examples of parallelization below with
# a SOCKET or MPI cluster configuration
#===================================================
# 1- WINDOWS multicores PC with SOCKET communication
# With a 2-Quad (8-CPUs) PC
#===================================================
if (.Platform$OS.type == "windows") {
cpus <- detectCores()
conf <- list("names" = rep("localhost", cpus),
"cpus" = cpus,
"type" = "SOCK",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
}
#===================================================
# 2- LINUX multinodes cluster with SOCKET communication
# with 4-nodes (32-CPUs) cluster
# with 1 masternode and 3 workernodes
# All hosts run identical setups
# Same number of core CPUs (8) per node
#===================================================
if (.Platform$OS.type == "unix") {
masterhost <- Sys.getenv("HOSTNAME")
slavehosts <- c("compute-0-0", "compute-0-1", "compute-0-2")
nodes <- length(slavehosts) + 1
cpus <- 8
conf <- list("names" = c(rep(masterhost, cpus),
rep(slavehosts, cpus)),
"cpus" = nodes * cpus,
"type" = "SOCK",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
}
#===================================================
# 3- LINUX multinodes cluster with MPI communication
# Here, a file named ".nodes" (e.g. in the home directory)
# must contain the list of nodes of the cluster
#===================================================
if (.Platform$OS.type == "unix") {
hosts <- scan(file=paste(Sys.getenv("HOME"), "/.nodes", sep=""),
what="",
sep="\n")
hostnames <- unique(hosts)
nodes <- length(hostnames)
cpus <- length(hosts)/length(hostnames)
conf <- list("cpus" = nodes * cpus,
"type" = "MPI",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
}
#===================================================
# Mean-Variance Regularization (Real dataset)
# Multi-Group Assumption
# Assuming unequal variance between groups
#===================================================
nc.min <- 1
nc.max <- 30
probs <- seq(0, 1, 0.01)
n <- 6
GF <- factor(gl(n = 2, k = n/2, len = n),
ordered = FALSE,
labels = c("M", "S"))
mvr.obj <- mvr(data = Real,
block = GF,
tolog = FALSE,
nc.min = nc.min,
nc.max = nc.max,
probs = probs,
B = 100,
parallel = TRUE,
conf = conf,
verbose = TRUE)
#===================================================
# Regularized t-test statistics (Real dataset)
# Multi-Group Assumption
# Assuming unequal variance between groups
# With option to use prior MVR clustering results
# With computation of p-values
#===================================================
mvrt.obj <- mvrt.test(obj = mvr.obj,
pval = TRUE,
replace = FALSE,
n.resamp = 100,
parallel = TRUE,
conf = conf,
verbose = TRUE)
Run the code above in your browser using DataLab