# NOT RUN {
# Example 1
library(igraph)
library(SteinerNet)
el <- matrix( c("a", "b", "a", "c", "b", "d","d","e", "c", "b" ), nc = 2, byrow = TRUE)
g1 =graph_from_edgelist(el)
ter_list= c("a","b","e")
SP=steinertree("SP", ter_list, g1, TRUE, FALSE)
SP[[1]]
# Example 2
el <- matrix( c("a", "b", "a", "c", "b", "d","d","e", "c", "b" ), nc = 2, byrow = TRUE)
g1 =graph_from_edgelist(el)
ter_list= c("a","b","e")
KB = steinertree("KB", ter_list, g1 , TRUE)
KB[[1]]
KB[[2]]
# Example 3
EXA = steinertree("EXA", ter_list, g1 , TRUE , FALSE)
EXA[[1]]
# Example 4
EXA2 = steinertree("EXA", ter_list, g1 , TRUE , TRUE)
EXA2[[2]]
# }
# NOT RUN {
# }
# NOT RUN {
# Example 5: A case study with a sample graph and a given gene list
g <- graph( c(9,2,1,2,2,3,3,4,5,6,3,6,2,7,2,5,2,6,5,8), directed=FALSE)
V(g)$name= c("1058", "51203", "6515", "83879", "160897",
"10531", "8659", "2947", "643008")
geneid_list= c("1058","83879", "160897","643")
# We include into the test those geneIDes who exist within the base graph.
r = 1:(length(geneid_list))
t = sapply (r ,function(r) !is.na(match(geneid_list[r],V(g)$name )) )
glist = geneid_list[t==TRUE]
ST1= steinertree( "SP", glist, g)
tkplot(result1) # tkplot function displays labels instead of names
# }
Run the code above in your browser using DataLab