# Example 1: Gene network estimation using the bootstrap ranking LASSO method.
# Gaussian graph with OR-rule.
library(SIS)
data(leukemia.train)
# Genes screened by the LASSO algorithm as candidates for graphical modeling.
x <- as.matrix(leukemia.train[, -7130])
y <- as.numeric(leukemia.train[, 7130])
set.seed(0123)
cvfit <- cv.glmnet(x=x, y=y, type.measure="deviance", nfolds=3, family="binomial")
model.final <- cvfit$glmnet.fit
nzero <- as.matrix(coef(model.final, s=cvfit$lambda.min))
# To reduce the running time, only half of significant genes are shown.
var_nz <- sort(abs(nzero[nzero[,1]!=0, ][-1]), decreasing=TRUE)
var_nz <- names(var_nz[1:(length(var_nz)/2)])
sub_data <- leukemia.train[, c(var_nz, "V7130")]
# Gene expression data subset from patients with acute myeloid leukemia.
subset_1 <- subset(sub_data, sub_data$V7130==1)
subset_1 <- as.matrix(subset_1[, -dim(subset_1)[2]])
# The parameters of B and Boots in the following example are set as small values to
# reduce the running time, however the default values are proposed.
Sparse.graph.fit1 <- Sparse.graph(subset_1, graph.type=c("gaussian"),
B=2, Boots=1, edge.rule=c("OR"))
# Give out the adjacency matrix of variables.
Sparse.graph.fit1$adj.matrix
# Example 2: Gaussian graph with AND-rule.
# The parameters of B and Boots in the following example are set as small values to
# reduce the running time, however the default values are proposed.
Sparse.graph.fit2 <- Sparse.graph(subset_1, graph.type=c("gaussian"),
B=2, Boots=1, edge.rule=c("OR"), plot=FALSE)
# Give out the adjacency matrix of variables.
Sparse.graph.fit2$adj.matrix
# Plot the graph based on the adjacency matrix of variables using the qgraph package.
library(qgraph)
qgraph(Sparse.graph.fit2$adj.matrix, directed=FALSE, color="blue",
negCol="red", edge.labels=TRUE, layout="circle")
Run the code above in your browser using DataLab