# NOT RUN {
# Load packages
# We compare different simulated data across five methods: MRPC,
# PC in pcalg (Kalisch et al., 2012), and pc.stable, mmpc and mmhc in
# bnlearn (Marco Scutari, 2010)
library(MRPC) # MRPC
library(pcalg) # pc
library(bnlearn) # pc.stable, mmpc and mmhc
# 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.
# Load predefined simulated data
# 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
# Calculate Pearson correlation
suffStat_C <- list(C = cor(data),
n = n)
# Infer the graph by MRPC
MRPC.fit <- MRPC(data,
suffStat = suffStat_C,
GV = 1,
FDR = 0.05,
alpha = 0.05,
indepTest = 'gaussCItest',
labels = V,
FDRcontrol = TRUE,
verbose = TRUE)
# Infer the graph by PC
pc.fit <- pc(suffStat = suffStat_C,
indepTest = gaussCItest,
alpha = 0.05,
labels = V,
verbose = TRUE)
# arcs not to be included from gene expression to genotype used in pc.stable, mmpc
bl <- data.frame (from=colnames (data)[-1], to='V1')
# Infer the graph by pc.stable
pc.stable.fit <- pc.stable(data.frame(data),blacklist=bl,undirected = FALSE)
# Infer the graph by mmpc
mmpc.fit <- mmpc(data.frame(data),blacklist=bl,undirected = FALSE)
# Infer the graph by mmhc
mmhc.fit <- mmhc(data.frame(data),blacklist=bl)
# Plot the inferred graphs
par(mfrow = c(2, 3))
plot(Truth,
main = "(A) Truth")
plot(MRPC.fit,
main = "(B) MRPC")
plot(pc.fit,
main ="(C) pc")
graphviz.plot(pc.stable.fit,
main = "(D) pc.stable")
graphviz.plot(mmpc.fit,
main = "(E) mmpc")
graphviz.plot(mmhc.fit,
main = "(F) mmhc")
# 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 dendrogram with modules colors of nodes
PlotDendrogramObj <- PlotDendrogram(Adj_directed,
minModuleSize = 2)
# Visualization of inferred graph with modules colors
PlotGraphWithModulesObj <- PlotGraphWithModules(Adj_directed,
PlotDendrogramObj,
GV=1,
node.size=8,
arrow.size = 5,
label.size = 3,
alpha = 1)
# Plot
plot(PlotGraphWithModulesObj)
# 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