# NOT RUN {
# Load packages
# We compare different simulated data across three methods: MRPC,
# PC in pcalg (Kalisch et al., 2012), and mmhc in bnlearn (Marco Scutari, 2010)
library(pcalg) # library for pc algorithm
library(bnlearn) # library for mmhc
# Load predefined simulated data
# Data pre-processing
# The 1st column of the input matrix will be the genotype of the
# expression quantitative trait loci (eQTL)/Copy number variation (CNV)
# and the remaining columns are the gene expression data.
# We used pre-assigned level alpha = 0.05 that ensures FDR and mFDR
# will remain below 0.05.
# Model 1
Truth <- MRPCtruth$M1 # Truth for model 1
data <- simu.data_M1 # load data for model 1
n <- nrow (data) # Number of rows
V <- colnames(data) # Column names
# Classical correlation
suffStat_C <- list(C = cor(data),
n = n)
# Robust correlation (Beta = 0.005)
Rcor_R <- RobustCor(data, 0.005)
suffStat_R <- list(C = Rcor_R$RR,
n = n)
# Estimated graph by MRPC using gaussCItest and beta = 0.005
MRPC.fit<- MRPC(data,
suffStat_R,
GV = 1,
FDR = 0.05,
indepTest = 'gaussCItest',
labels = V,
verbose = TRUE)
# Estimated graph by mmhc
mmhc.fit <- mmhc(data)
# Estimated graph by PC with alpha = 0.05
pc.fit <- pc(suffStat_C,
indepTest = gaussCItest,
alpha = 0.05,
labels = V,
verbose = TRUE)
# Plot the results
# Show estimated graph
par(mfrow = c(2, 2))
plot(Truth,
main = "(A) Truth")
plot(MRPC.fit,
main = "(B) MRPC")
graphviz.plot(mmhc.fit,
main = "(C) mmhc")
plot(pc.fit,
main ="(D) pc")
# Another option for plot of the results. First fig is the nodes
# dendrogram with colored modules. Second fig is the plot of the graph
# with color based on modules.
# To idendify modules and complex graph (Suitable if you have many nodes)
# Adjacency matrix from directed graph
Adj_directed <- as(MRPC.fit@graph,
"matrix")
# Plot of the graph with colored modules.
DendroModuleGraph(Adj_directed,
minModuleSize = 1,
GV = 1)
# Other models are available and may be called as follows:
# Model 0
# Truth <- MRPCtruth$M0
# data <- simu.data_M0
# Model 2
# Truth <- MRPCtruth$M2
# data <- simu.data_M2
# Model 3
# Truth <- MRPCtruth$M3
# data <- simu.data_M3
# Model 4
# Truth <- MRPCtruth$M4
# data <- simu.data_M4
# Model Multiparent
# Truth <- MRPCtruth$Multiparent
# data <- simu.data_multiparent
# Model Star
# Truth <- MRPCtruth$Star
# data <- simu.data_starshaped
# Model Layered
# Truth <- MRPCtruth$Layered
# data <- simu.data_layered
# }
Run the code above in your browser using DataLab