## Not run:
# # 1) SNP-based ontology
# # 1a) ig.EF (an object of class "igraph" storing as a directed graph)
# g <- xRDataLoader('ig.EF')
#
# # 1b) load GWAS SNPs annotated by EF (an object of class "dgCMatrix" storing a spare matrix)
# anno <- xRDataLoader(RData='GWAS2EF')
#
# # 1c) prepare for annotation data
# # randomly select 5 terms/vertices (and their annotation data)
# annotation <- anno[, sample(1:dim(anno)[2],5)]
#
# # 1d) obtain the induced subgraph according to the input annotation data
# # based on shortest paths (i.e. the most concise subgraph induced)
# dag <- xDAGanno(g, annotation, path.mode="shortest_paths",
# verbose=TRUE)
#
# # 1e) color-code nodes/terms according to the number of annotations
# data <- sapply(V(dag)$anno, length)
# names(data) <- V(dag)$name
# dnet::visDAG(g=dag, data=data, node.info="both")
#
# ####################
# # Below is for those SNPs annotated by the term called 'ankylosing spondylitis'
# # The steps 1a) and 1b) are the same as above
# # 1c') prepare for annotation data
# # select a term 'ankylosing spondylitis'
# terms <- V(g)$term_id[grep('ankylosing spondylitis',V(g)$term_name,
# perl=TRUE)]
# ind <- which(colnames(anno) %in% terms)
# annotation <- lapply(ind, function(x){names(which(anno[,x]!=0))})
# names(annotation) <- colnames(anno)[ind]
#
# # 1d') obtain the induced subgraph according to the input annotation data
# # based on all possible paths (i.e. the complete subgraph induced)
# dag <- xDAGanno(g, annotation, path.mode="all_paths", verbose=TRUE)
#
# # 1e') color-code nodes/terms according to the number of annotations
# data <- sapply(V(dag)$anno, length)
# names(data) <- V(dag)$name
# dnet::visDAG(g=dag, data=data, node.info="both")
#
# ###########################################################
# # 2) Gene-based ontology
# # 2a) ig.MP (an object of class "igraph" storing as a directed graph)
# g <- xRDataLoader('ig.MP')
#
# # 2b) load human genes annotated by MP (an object of class "GS" containing the 'gs' component)
# GS <- xRDataLoader(RData='org.Hs.egMP')
# anno <- GS$gs # notes: This is a list
#
# # 2c) prepare for annotation data
# # randomly select 5 terms/vertices (and their annotation data)
# annotation <- anno[sample(1:length(anno),5)]
#
# # 2d) obtain the induced subgraph according to the input annotation data
# # based on shortest paths (i.e. the most concise subgraph induced)
# # but without applying true-path rule
# dag <- xDAGanno(g, annotation, path.mode="shortest_paths",
# true.path.rule=TRUE, verbose=TRUE)
#
# # 2e) color-code nodes/terms according to the number of annotations
# data <- sapply(V(dag)$anno, length)
# names(data) <- V(dag)$name
# dnet::visDAG(g=dag, data=data, node.info="both")
# ## End(Not run)
Run the code above in your browser using DataLab