Closed risserlin closed 6 years ago
trying to get rid of nodes that have no edges.
Was going to use network analyzer and get rid of nodes that have degree = 0 but can't figure out how call network analyzer through rest of RCy3.
instead was going to do:
selectAllEdges
SelectNodesConnectedtoSelectedEdges
InvertNodeSelection
I'll look into adding this function for the next release. In the meantime, here's a trick for getting rid of nodes with no edges:
createSubnetwork(edges='all')
Available in dev release and github. Here's the function:
# ------------------------------------------------------------------------------
#' @title Select Nodes Connected By Selected Edges
#'
#' @description Takes currently selected edges and extends the selection to
#' connected nodes, regardless of directionality.
#' @param network (optional) Name or SUID of the network. Default is the
#' "current" network active in Cytoscape.
#' @param base.url (optional) Ignore unless you need to specify a custom domain,
#' port or version to connect to the CyREST API. Default is http://localhost:1234
#' and the latest version of the CyREST API supported by this version of RCy3.
#' @return Lists of SUIDs for currently selected nodes and edges
#' @examples \donttest{
#' selectNodesConnectedBySelectedEdges()
#' }
#' @export
selectNodesConnectedBySelectedEdges <-
function(network = NULL, base.url = .defaultBaseUrl) {
suid <- getNetworkSuid(network,base.url)
clearSelection(type = 'nodes', suid, base.url)
res <-
commandsPOST(
paste0(
'network select extendEdges="true" edgeList="selected network="',
suid,
'"'
)
)
return(res)
}
Select -> Nodes -> Nodes connected by selected edges