Paul Shannon | 14 Mar 22:44 2013

Re: Quick questions about RCytoscape

Hi Ricardo,

Answers (and attempts at answers) below.

 - Paul

On Mar 14, 2013, at 10:51 AM, Ricardo Silva wrote:

> Hi Paul,
> 
> thank you, sorry for the unfocused question again.
> 
> I was thinking in export graphs in .sif from R, like this one
> 
> http://metexplore.toulouse.inra.fr/metexploreJoomla/metexplore/tmp/graph_1584167971.sif
> 
> maybe some one already did that.
> So exporting a file like this I could send to a collaborator.
> 
> I usually export as
> cw <- new.CytoscapeWindow ('Pathway', graph=g)
> 
> and inside cytoscape I save as .sif. I will be nice save the graphs from R.

RCytoscape has an internal method which converts a graphNEL to a data.frame. 
We could make it a normal exported function at the next release.  It is
generally quite undesirable to call an internal method, so I mention this
approach with trepidation. 

Here is how the internal method is currently defined:

classicGraphToNodePairTable = function (g) {
    edges.g <- edges(g)
    edge.names = as.character(unlist(sapply(names(edges.g), function (a) {
         bs = edges.g[[a]]; 
         if (length(bs) > 0) paste(a, edges.g[[a]], sep='~') 
         })))

    pairs = strsplit(edge.names, '~')
    a = sapply(pairs, "[", 1)
    b = sapply(pairs, "[", 2)

    if ('edgeType' %in% eda.names(g))
        edgeType = as.character(edgeData(g, from=a, to=b, attr='edgeType'))
    else
        edgeType = rep('unspecified', length (a))

   return(data.frame(source=a, target=b, edgeType=edgeType, stringsAsFactors=FALSE))
   }

You can call it like this:

library(RCytoscape)
tbl.sif <- classicGraphToNodePairTable(makeSimpleGraph())
tbl.sif

  source target         edgeType
1      A      B   phosphorylates
2      B      C synthetic lethal
3      C      A        undefined

And then create a sif file by taking these steps:

write.table(tbl.sif[,c(1,3,2)], file="simple.sif", row.names=FALSE, 
            col.names=FALSE, quote=FALSE)

> (by the way, today I tried to communicate with cytoscape and had this error:
> 
> cw <- existing.CytoscapeWindow ('human_BioCyc',  copy.graph.from.cytoscape.to.R=TRUE)
> Error in function (type, msg, asError = TRUE)  : 
>   Recv failure: Connection reset by peer
> cw <- new.CytoscapeWindow ('vignette', graph=g)
> Error in function (type, msg, asError = TRUE)  : 
>   Recv failure: Connection reset by peer
> 
> do you know this error?

Sorry, I don't recognize this error.  It looks like the RPC server, possibly the one in the CytoscapeRPC
plugin, has gone haywire.  Does it still fail after you restart Cytoscape (and R)?

> 
> About the plots, I know which plots I want from R, but, even working with small networks (up to 60 nodes) one
plot to each node will be very hard to visualize at once. So, if we could "hide' them and show with one click,
will help a lot. In my case each node is a metabolite, and I have intensities for various samples, with a
scatter plot for all samples together.

I'm afraid that capability does not exist right now.  Maybe in Cytoscape 3?  My inclination would be to do it
with RCytoscape, but that means that those you wish to share the data with will have to know a little bit of R.  

 - Paul

> 
> Thanks 
> 
> Ricardo
> 
> 2013/3/14 Paul Shannon <pshannon@...>
> Hi Ricardo,
> 
> I believe there are three strategies to explore:
> 
>    1) CyRFace: http://www.ebi.ac.uk/saezrodriguez/cno/cyrface/
>    2) RCytoscape:  the Bioconductor package
>    3) Write appropriate cytoscape files from R (interactions, node & edge attributes)
> 
> Some specifics below.
> 
> On Mar 13, 2013, at 2:40 PM, Ricardo Silva wrote:
> 
> > Hi,
> >
> > Anyone knows if there is a way to include R plots as node attributes, so
> > that we can click and see the plots for each node in cytoscape?
> 
> RCytoscape offers something vaguely like this, in which the nodes ARE plots.   See:
> 
>   http://rcytoscape.systemsbiology.net/versions/current/cookbook/infoNodes-plots/
> 
> More flexibly, still using RCytoscape, you could write an R function which
> 
>   1) queried Cytoscape for currently selected node/s
>   2) marshalled appropriate data in R and created the plot you want.
> 
>    plotExpression(getSelectedNodes(cw, list.of.conditions))
> 
> I have not tried it, but by attaching an instance of RServe to Cytoscape, CyRFace perhaps permits you to
issue an R plotting command from Cytoscape.
> 
> 
> >
> > Additionally, is it possible to export a cytoscape format from R, so that
> > can produce graphs automatically and send to someone without opening
> > cytoscape myself?
> 
> Do you want to send
>    a) Cytoscape session files?
>    b) a jpeg or png of the resulting network?
>    c) input files your intended user could interactively load into Cytoscape?
>    d) R code which creates a graph and displays it in Cytoscape?
> 
> All of these are possible.  I'd be glad to give you specifics.
> 
> Cheers,
> 
>  - Paul
> 
> 
> 
> > Sorry if it is too basic or unreasonable.
> >
> > thks
> >
> > Ricardo
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor@...
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
> 
> 

_______________________________________________
Bioconductor mailing list
Bioconductor@...
https://stat.ethz.ch/mailman/listinfo/bioconductor
Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


Gmane