Skip to content

Commit

Permalink
feat(visualizeNetworks): Enable use of other columns for node labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywu1999 committed Jan 22, 2025
1 parent c33b317 commit 3474738
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions R/utils_getSubnetworkFromIndra.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
id = input$Protein,
logFC = input$log2FC,
pvalue = input$adj.pvalue,
hgncName = if ("HgncName" %in% colnames(input)) input$HgncName else NA,
stringsAsFactors = FALSE
)
nodes <- nodes[which(nodes$id %in% edges$source | nodes$id %in% edges$target),]
Expand Down
7 changes: 5 additions & 2 deletions R/visualizeNetworks.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#' Default is 0.05
#' @param logfcCutoff log fold change cutoff for coloring significant
#' proteins. Default is 0.5
#' @param node_label_column The column of the nodes dataframe to use as the
#' node label. Default is "id". "hgncName" can be used for gene name.
#' @importFrom RCy3 createNetworkFromDataFrames mapVisualProperty
#' createVisualStyle setVisualStyle layoutNetwork addAnnotationShape
#' addAnnotationText getNodePosition getNetworkCenter
Expand All @@ -32,7 +34,8 @@
#'
visualizeNetworks <- function(nodes, edges,
pvalueCutoff = 0.05,
logfcCutoff = 0.5) {
logfcCutoff = 0.5,
node_label_column = "id") {
.validateVisualizeNetworks(nodes)

# Add additional columns for visualization
Expand All @@ -55,7 +58,7 @@ visualizeNetworks <- function(nodes, edges,
VISUAL_STYLE_NAME <- "MSstats-Indra Visual Style"

VISUAL_STYLE_MAPPINGS <- list(
mapVisualProperty("Node Label", "id", "p"),
mapVisualProperty("Node Label", node_label_column, "p"),
mapVisualProperty(
"Node Fill Color", "logFC_color", "c",
c(-logfcCutoff, 0.0, logfcCutoff),
Expand Down
11 changes: 10 additions & 1 deletion man/visualizeNetworks.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3474738

Please sign in to comment.