Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions R/cytoscapeNetwork.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
```r
# R/cytoscapeNetwork.R
#
# htmlwidgets binding for the Cytoscape network visualisation.
Expand Down Expand Up @@ -490,8 +491,44 @@ cytoscapeNetworkOutput <- function(outputId,
)
}

#' Shiny render binding for cytoscapeNetwork
#' @inheritParams htmlwidgets::shinyRenderWidget
#' Render a Cytoscape network in a Shiny application
#'
#' This function is used to render a Cytoscape network visualization within a Shiny application.
#'
#' @param expr \code{expression} that generates a Cytoscape network widget.
#' @param env \code{environment} in which to evaluate \code{expr}. Defaults to \code{parent.frame()}.
#' @param quoted \code{logical}, is \code{expr} a quoted expression (with \code{quote()})? Default is \code{FALSE}.
#'
#' @return A rendered Cytoscape network widget for use in Shiny applications.
#'
#' @examples
#' \dontrun{
#' library(shiny)
#' library(MSstatsBioNet)
#'
#' ui <- fluidPage(
#' cytoscapeNetworkOutput("cytoNetwork")
#' )
#'
#' server <- function(input, output, session) {
#' output$cytoNetwork <- renderCytoscapeNetwork({
#' nodes <- data.frame(
#' id = c("TP53", "MDM2", "CDKN1A"),
#' logFC = c(1.5, -0.8, 2.1),
#' stringsAsFactors = FALSE
#' )
#' edges <- data.frame(
#' source = c("TP53", "MDM2"),
#' target = c("MDM2", "TP53"),
#' interaction = c("Activation", "Inhibition"),
#' stringsAsFactors = FALSE
#' )
#' cytoscapeNetwork(nodes, edges)
#' })
#' }
#'
#' shinyApp(ui, server)
#' }
#' @export
renderCytoscapeNetwork <- function(expr, env = parent.frame(), quoted = FALSE) {
if (!quoted) expr <- substitute(expr)
Expand All @@ -502,3 +539,4 @@ renderCytoscapeNetwork <- function(expr, env = parent.frame(), quoted = FALSE) {
quoted = TRUE
)
}
```