annotateGraph {netboxr}R Documentation

Annotate NetBox graph

Description

This function annotates the graph based on user input. 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.

Usage

annotateGraph(netboxResults, edgeColors = NULL, directed = TRUE,
  linker = TRUE)

Arguments

netboxResults

Output from geneConnector(). A list with six lists (i.e. netboxGraph, netboxCommunity, netboxOutput, nodeType, moduleMembership, neighborData) netboxGraph is an igraph object. netboxCommunity is an igraph object. netboxOutput is a data frame. nodeType is a data frame. moduleMembership is a data frame. neighborData is a data frame.

edgeColors

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

directed

TRUE or FALSE

linker

TRUE or FALSE

Value

annotated version of netboxGraph

Author(s)

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)

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()


[Package netboxr version 0.99.988 Index]