# NOT RUN {
# Continuous data with genetic varitant (GV)
# load the data
data("data_examples")
# Extract the sample size
n <- nrow(data_examples$simple$cont$withGV$data)
# Extract the node/column names
V <- colnames(data_examples$simple$cont$withGV$data)
# Calculate Pearson correlation
suffStat_C <- list(C = cor(data_examples$simple$cont$withGV$data),
n = n)
# Infer the graph by MRPC
data.mrpc.cont.withGV <- MRPC(data = data_examples$simple$cont$withGV$data,
suffStat = suffStat_C,
GV = 2,
FDR = 0.05,
alpha = 0.05,
indepTest = 'gaussCItest',
labels = V,
FDRcontrol = TRUE,
verbose = TRUE)
# Plot the results
par(mfrow = c(1, 2))
# plot the true graph
plot(data_examples$simple$cont$withGV$graph,
main = "truth")
# plot the inferred graph
plot(data.mrpc.cont.withGV,
main = "inferred")
# Continuous data without genetic information
# load the data
data("data_examples")
# Extract the sample size
n <- nrow(data_examples$simple$cont$withoutGV$data)
# Extract the node/column names
V <- colnames(data_examples$simple$cont$withoutGV$data)
# Calculate Pearson correlation
suffStat_C <- list(C = cor(data_examples$simple$cont$withoutGV$data),
n = n)
# Infer the graph by MRPC
data.mrpc.cont.withoutGV <- MRPC(data = data_examples$simple$cont$withoutGV$data,
suffStat = suffStat_C,
GV = 0,
FDR = 0.05,
alpha = 0.05,
indepTest = 'gaussCItest',
labels = V,
FDRcontrol = TRUE,
verbose = TRUE)
# Plot the results
par(mfrow = c(1, 2))
# plot the true graph
plot(data_examples$simple$cont$withoutGV$graph,
main = "truth")
# plot the inferred graph
plot(data.mrpc.cont.withoutGV,
main = "inferred")
# Discrete data with genetic information
# load the data
data("data_examples")
# Extract the sample size
n <- nrow(data_examples$simple$disc$withGV$data)
# Extract the node/column names
V <- colnames(data_examples$simple$disc$withGV$data)
# Calculate Pearson correlation
suffStat_C <- list(C = cor(data_examples$simple$disc$withGV$data),
n = n)
# Infer the graph by MRPC
data.mrpc.disc.withGV <- MRPC(data = data_examples$simple$disc$withGV$data,
suffStat = suffStat_C,
GV = 1,
FDR = 0.05,
alpha = 0.05,
indepTest = 'gaussCItest',
labels = V,
FDRcontrol = TRUE,
verbose = TRUE)
# Plot the results
par (mfrow = c(1, 2))
# plot the true graph
plot(data_examples$simple$disc$withGV$graph,
main = "truth")
# Plot the inferred causal graph
plot(data.mrpc.disc.withGV,
main = "inferred")
# Discrete data without genetic information
# load the data
data("data_examples")
# Extract the sample size
n <- nrow (data_examples$simple$disc$withoutGV$data)
# Extract the node/column names
V <- colnames(data_examples$simple$disc$withoutGV$data)
# Calculate Pearson correlation
suffStat_C <- list(C = cor(data_examples$simple$disc$withoutGV$data),
n = n)
# Infer the graph by MRPC
data.mrpc.disc.withoutGV <- MRPC(data = data_examples$simple$disc$withoutGV$data,
suffStat = suffStat_C,
GV = 1,
FDR = 0.05,
alpha = 0.05,
indepTest = 'gaussCItest',
labels = V,
FDRcontrol = TRUE,
verbose = TRUE)
# Plot the results
par(mfrow = c(1, 2))
# plot the true graph
plot(data_examples$simple$disc$withoutGV$graph,
main = "truth")
# plot the inferred graph
plot(data.mrpc.disc.withoutGV,
main = "inferred")
# Continuous data with genetic information for complex model
# load the data
data("data_examples")
# Graph without clustering
plot(data_examples$complex$cont$withGV$graph)
# Adjacency matrix from directed example graph
Adj_directed <- as(data_examples$complex$cont$withGV$graph,
"matrix")
# Plot of dendrogram with modules colors of nodes
PlotDendrogramObj <- PlotDendrogram(Adj_directed,
minModuleSize = 5)
# Visualization of inferred graph with modules colors
PlotGraphWithModulesObj <- PlotGraphWithModules(Adj_directed,
PlotDendrogramObj,
GV=14,
node.size=8,
arrow.size = 5,
label.size = 3,
alpha = 1)
# plot
plot(PlotGraphWithModulesObj)
# }
Run the code above in your browser using DataLab