Annotate NetBox graph
annotateGraph.Rd
This function annotates the graph based on user input.
Arguments
- netboxResults
Output from
geneConnector
function. a list of returned netboxr resultsnetboxGraph: 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.
Author
Guanlan Dong, guanlan_dong@g.harvard.edu
Examples
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)
#> Loading network of 10433 nodes and 246590 interactions
#> Treated as undirected network
#> Removing multiple interactions and loops
#> Returning network of 10433 nodes and 213301 interactions
geneList <- pathway_commons_v8_reactome$geneList
results <- geneConnector(geneList = geneList, networkGraph = graphReduced,
directed = FALSE, pValueAdj = "BH", pValueCutoff = 2e-5,
communityMethod = "ebc", keepIsolatedNodes = FALSE)
#> 189 / 354 candidate nodes match the name in the network of 10433
#> nodes
#> Only test neighbor nodes with local degree equals or exceeds 2
#> Multiple hypothesis corrections for 1944 neighbor nodes in the network
#> For p-value 2e-05 cut-off, 9 nodes were included as linker nodes
#> Connecting 189 candidate nodes and 9 linker nodes
#> Remove 82 isolated candidate nodes from the input
#> Final network contains 116 nodes and 336 interactions
#> Detecting modules using "edge betweeness" method
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()
#> agg_png
#> 2
# 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()
#> agg_png
#> 2