Search code examples
cytoscape

How to implement new node shapes


I am plotting a network in Cytoscape, and it would be convenient to add several node shapes that mimic the pch shapes in R so that my networks match all of my other figures for a publication.

Network layouts in R generally look bad, however I can format the nodes to be very similar to those in other plots. On the other hand, Cytoscape makes much better layouts however the node shapes and styles are limited.

Is it possible to implement additional shapes in Cytoscape (such as through a plugin), or alternatively, can I export a network layout from Cytoscape and use it in R? Thank you!


Solution

  • I solved this on my own. The answer was to use the "RCy3" R package. I made a layout of my network in Cytoscape, then connected to Cytoscape in R through RCy3. This package has the function getNodePosition which will return the node positions of the current network in Cytoscape.

    The following code will get this layout (Cytoscape must be running and open to the desired network):

    cytoscapePing()
    mygraph<-createIgraphFromNetwork()
    mylayout<-getNodePosition()
    mylayout$x_location<-as.numeric(as.character(mylayout$x_location))
    mylayout$y_location<-as.numeric(as.character(mylayout$y_location))
    colnames(mylayout)<-c("x","y")
    

    This can then be plotted using ggraph or other network plotting packages in R, with the R pch symbols as node shapes.