[BioC] initializing RCy node & edge attributes [was Re: problem getting setNodeColorRule from RCytoscape to work]

Paul Shannon pshannon at fhcrc.org
Mon Mar 19 06:01:08 CET 2012


Hi Burak,

On Mar 17, 2012, at 12:08 PM, Burak Kutlu wrote:

> Hi Paul
> A little bit of Zen was really helpful: the example you provided, when executed in a calm, quiet place,  works :-)

Whew!  Glad to hear that everything now works for you.

> There are a couple of things going on here: please confirm if you agree.
> 
> 1. The only difference between the example in the help page and the example you provide is " displayGraph(cw) " call after creating the Cytoscape Window object. May I suggest including that in the help page example for both setNodeColorRule and setEdgeColorRule?
> 
> More specifically:
> I would insert displayGraph(cw) after this line
> cw <- new.CytoscapeWindow ('setNodeColorRule.test', graph=makeSimpleGraph())

Thanks -- good suggestion.  'displayGraph' should be in ALL of the examples.   It will be with the new bioc release.

> I realize that I am still confused when to call displayGraph or redraw, after already calling displayGraph for the first time. Can you comment on this?
> 
> 2. You tried earlier in vain to convince me to initiate the edge attributes.  Calling "InitEdgeAttributes" solved the issues I was having. Now I am really convinced. I am still confused, though, why you force this even when attributes exist for all edges.
> 

I would be glad to hear any suggestions on this topic.  Here is the current story:

I try to motivate, explain, and justify initEdgeAttributes and initNodeAttributes in the RCy vignette which is excerpted below.  The short version:  Bioconductor graph classes require nodeDataDefaults and edgeDataDefaults method calls to initialize the attribute slots.  RCy wraps those methods in the 'init[Node|Edge]Attribute methods, which additionally require you to specify the type of the attribute.  Thus there are no EXTRA methods to call in initializing a graph, just replacement methods, which wrap and supersede edgeDataDefaults and nodeDataDefaults

Maybe there is a better way to do this?

From the vignette:

  You will encounter one obscurity in the code chunk just below: the explicit initialization of 
  node (and edge) attributes for a graph. This is similar to, but goes a bit further than, calls 
  to nodeDataDefaults required for Bioconductor graph objects. In fact, such calls are executed 
  within the RCytocape initNodeAttribute and initEdgeAttribute methods. An additional bit of 
  information is required here: the ’class’ or data type of the attribute you are initializing. 
  It can be ’char’, ’integer’ or ’numeric’.

  For instance, the node attribute ’moleculeType’ has values which are character strings. The node 
  attribute ’lfc’ (log fold change) is declared to be numeric. This extra fuss is unavoidable: if 
  you do not stipulate the class of each node and edge attribute, as is demonstrated below, then 
  RCytoscape will report an error. We require this because it is only by way of such explicit 
  assignment that RCytoscape can resolve the difference between integer and floating point 
  values – necessary in the statically typed Java language (in which Cytoscape is written) though not in R.

 - Paul


> 
> 
> 
> On Mar 17, 2012, at 11:13 AM, Paul Shannon wrote:
> 
>> Thanks, Burak.  
>> 
>> So far so good.  Now try, if you will --  just to step through this slow and easy:
>> 
>>> cw = new.CytoscapeWindow (title = 'bug?', graph=g)
>>> displayGraph (cw)
>>   entering RCytoscape::displayGraph
>>   sending 3 nodes
>>   sending 3 edges
>>   adding node attributes...
>>   [1] "type"
>>   [1] "lfc"
>>   [1] "label"
>>   [1] "count"
>>   adding edge attributes...
>>   [1] "edgeType"
>>   entering setEdgeAttributesDirect, edgeType, with 3 names and 3 values
>>   [1] "score"
>>   entering setEdgeAttributesDirect, score, with 3 names and 3 values
>>   [1] "misc"
>> 
>>> noa (cw at graph, 'lfc')
>>   A  B  C
>>  -3  0  3
>> 
>>> control.points <- c (-3.0, 0.0, 3.0)   # typical range of log-fold-change ratio values
>>> node.colors <- c ("#00AA00", "#00FF00", "#FFFFFF", "#FF0000", "#AA0000")
>>> noa (cw at graph, 'lfc')  # do this again, just to be sure
>>   A  B  C
>>  -3  0  3
>>> setNodeColorRule (cw, node.attribute.name='lfc', control.points, node.colors, mode='interpolate')
>>> redraw (cw)
>> 
>> - Paul
>> 
>> 
>> On Mar 17, 2012, at 11:04 AM, Burak Kutlu wrote:
>> 
>>> Hi Paul
>>> Thanks for the prompt response!!
>>> 
>>> Here's the output which looks identical to yours. 
>>> 
>>>> noa.names (cw at graph)
>>> [1] "type"  "lfc"   "label" "count"
>>>> noa (cw at graph, 'lfc')
>>> A  B  C 
>>> -3  0  3 
>>> 
>>> -burak
>>> 
>>> On Mar 17, 2012, at 11:02 AM, Paul Shannon wrote:
>>> 
>>>> noa.names (cw at graph)
>>>> noa (cw at graph, 'lfc')
>>> 
>> 
> 



More information about the Bioconductor mailing list