annotateGraph: Annotate NetBox graph

Description Usage Arguments Details Value Author(s) Examples

View source: R/annotateGraph.R

Description

This function annotates the graph based on user input.

Usage

1
2
3
4
5
6
annotateGraph(
  netboxResults,
  edgeColors = NULL,
  directed = FALSE,
  linker = TRUE
)

Arguments

netboxResults

Output from geneConnector function. a list of returned netboxr results

  • netboxGraph: igraph object of NetBox algorithm identified network nodes and connections

  • netboxCommunity: igraph object of network community assignment

  • netboxOutput: data frame of NetBox algorithm identified network nodes and connections

  • nodeType: data frame of node types ("candidate" or "linker") in the NetBox algorithm indentified network.

  • moduleMembership: data frame of module (community) membership.

  • neighborData: data frame of information of nodes directly connected to candidate gene nodes.

edgeColors

table containing hex color codes for interaction types. The first column is interaction type and the second column is hex color code.

directed

boolean value indicating whether the NetBox algorithm identified network is directed or undirected (default = FALSE)

linker

boolean value indicating whether "linker" nodes exist in the NetBox algorithm identified network or not (default = TRUE)

Details

If a table of color codes for interaction types is provided, then the edges will be colored accordingly by interaction types. If directed is TRUE, then the edges will be arrows with the same directionality as the original input network for NetBox. If linker is TRUE, then linker nodes will be shown as squares while non-linker nodes stay as circles.

Value

annotated version of netboxGraph

Author(s)

Guanlan Dong, guanlan_dong@g.harvard.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
data(pathway_commons_v8_reactome)
interaction_type_color <- read.csv(system.file("interaction_type.color.txt", package = "netboxr"),
                                   header=TRUE, sep="\t", stringsAsFactors=FALSE)

sifNetwork<-pathway_commons_v8_reactome$network
graphReduced <- networkSimplify(sifNetwork,directed = FALSE)

geneList <- pathway_commons_v8_reactome$geneList

results <- geneConnector(geneList = geneList, networkGraph = graphReduced, 
                         directed = FALSE, pValueAdj = "BH", pValueCutoff = 2e-5, 
                         communityMethod = "ebc", keepIsolatedNodes = FALSE)

netboxGraphAnnotated <- annotateGraph(netboxResults = results,
                                      edgeColors = interaction_type_color,
                                      directed = TRUE,
                                      linker = TRUE)

# As an example, plot both the original and the annotated graphs
ll <- layout_with_fr(results$netboxGraph) # Save the layout for easier comparison
# Plot original graph
pdf("originalGraph.pdf", width = 50, height = 50)
plot(results$netboxCommunity, results$netboxGraph, layout = ll,
     vertex.size=3)
dev.off()
# Plot annotated graph
pdf("annotatedGraph.pdf", width = 50, height = 50)
plot(results$netboxCommunity, netboxGraphAnnotated, layout = ll,
     vertex.size = 3,
     vertex.shape = V(netboxGraphAnnotated)$shape,
     edge.color = E(netboxGraphAnnotated)$interactionColor,
     edge.width = 3)
# Add legend
ind <- which(interaction_type_color$INTERACTION_TYPE %in% E(netboxGraphAnnotated)$interaction)
legend_interaction_type <- interaction_type_color$INTERACTION_TYPE[ind]
legend_interaction_type_color <- interaction_type_color$COLOR[ind]
legend(x=-1.1, y=1.1, 
       legend=c("Candidate", "Linker"),
       pch=c(19, 15), # solid circle, filled square
       pt.cex = 8,
       bty="n",
       title="Node Types",
       cex=4, ncol=1)
legend(x=-1.15, y=0.95, 
       legend=legend_interaction_type,
       col = legend_interaction_type_color,
       lty = 1, lwd = 10,
       bty="n",
       title="Interaction Types (Edges)",
       cex=4, ncol=1)
dev.off()

netboxr documentation built on Nov. 8, 2020, 5:01 p.m.