RCy3: updating node attribute of existing network

332 views
Skip to first unread message

Shraddha Pai

unread,
Jun 5, 2018, 9:42:51 AM6/5/18
to cytoscape-helpdesk
Hi,
I have Cytoscape 3.5.1 and the latest version of RCy3 (2.1.2) installed.
I have a network already open in Cytoscape and want to programmatically change the node fill attribute based on a node attribute, then save the image... and then repeat in a loop for a set of attributes.
I opened up R and typed:

> require(RCy3)
> setNodeColorMapping(table.column="verbal", colors=c("#ff0000","#00ff00","#0000ff"), mapping.type="d")

but I get this error:

RCy3::commandsPOST, HTTP Error Code: 405
 body={
 "network": "current",
"namespace": "default",
"columnList": "SUID"
}
Error in file(con, "r") : cannot open the connection

"Available arguments for 'network get attribute':

columnList

namespace

network"


So it seems like the Cytoscape server is up and running. Why isn't this command working?

I got this example from https://www.bioconductor.org/packages/devel/bioc/vignettes/RCy3/inst/doc/Upgrading-existing-scripts.html#5_example_upgrades


Thanks,Shraddha

---

Post-doctoral Fellow

http://baderlab.org



Barry Demchak

unread,
Jun 5, 2018, 12:06:35 PM6/5/18
to cytoscape...@googlegroups.com

Hi, Shraddha –

 

Are you sure you have 3.5.1? Would you mind trying this on 3.6.1? A lot has changed, especially with CyREST.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpd...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/495c72e9-8bda-4593-be5c-fdb0bc88f894%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shraddha Pai

unread,
Jun 5, 2018, 1:04:53 PM6/5/18
to cytoscape...@googlegroups.com
Hi Barry,
Thanks for writing back. I've updated to 3.6.1. There seem to be a number of things happening at once:

1) It seems if there are several network collections open, even if I am looking at the view of the 3rd one and trying to manipulate that one, CyREST is trying to update the first network in the list. 

2) Running this command returns an error in R, but it still works.
> setNodeColorMapping(default.color="#00aa00")
Error in mapVisualProperty("NODE_FILL_COLOR", table.column, "c", table.column.values,  :
  argument "table.column" is missing, with no default

Node fill is still updated to dark green in the first network in the set of collections (but not in the third network, which I have open in the View panel).

3) Now if I move my debugging efforts to the first net, and try to see if EasyCyrest works there, I still run into issues.
There is a binary node attribute, "verbal". If I select it in the "Styles" GUI, I can see that it has two possible values, 0 and 1, and am able to assign a discrete colour scheme to it. But in R:
---
> setNodeColorMapping('verbal',table.column.values=c(0,1),colors=c('#000000','#FFFFFF'),mapping.type='d')
RCy3::cyrestPUT, HTTP Error Code: 500
 body=[
 {
 "mappingType": "discrete",
"mappingColumn": "verbal",
"mappingColumnType": "Integer",
"visualProperty": "NODE_FILL_COLOR",
"map": [
 {
 "key":      0,
"value": "#000000"
},
{
 "key":      1,
"value": "#FFFFFF"
}
]
}
]
Error in cyrestPUT(paste("styles", style.name, "mappings", visual.prop.name,  :

> setNodeColorMapping('verbal',colors=c('#000000','#FFFFFF'),mapping.type='d')
Error in map[[i]] <- list(key = table.column.values[i], value = toString(visual.prop.values[i])) :
  attempt to select less than one element in integerOneIndex
> setNodeColorMapping("verbal",colors=c('#000000','#FFFFFF'))
Error in points[[i]] <- list(value = table.column.values[i], lesser = visual.prop.values[i +  :
  attempt to select less than one element in integerOneIndex
---

What do I need to change about the call or setup to effect a colour scheme? The output of sessionInfo() is printed below incase there is some other dependency that needs to be updated.

Thanks,Shraddha
---
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] RCy3_2.1.2

loaded via a namespace (and not attached):
 [1] httr_1.3.1          compiler_3.4.4      magrittr_1.5
 [4] R6_2.2.2            tools_3.4.4         parallel_3.4.4
 [7] igraph_1.2.1        curl_3.2            RJSONIO_1.3-0
[10] BiocGenerics_0.24.0 pkgconfig_2.0.1     stats4_3.4.4
[13] XML_3.98-1.10       graph_1.56.0


To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/YsGGPyikZ-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.

David Otasek

unread,
Jun 5, 2018, 3:11:26 PM6/5/18
to cytoscape-helpdesk
Hi Shraddha,

I'll double check that the mapping functions in CyREST are giving the
expected behaviours. In the meantime, could I get a copy of the
session file you're working with so that we're both looking at the
same error?

Thanks.
>> email to cytoscape-helpd...@googlegroups.com.
>> To post to this group, send email to cytoscape...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/cytoscape-helpdesk/495c72e9-8bda-4593-be5c-fdb0bc88f894%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "cytoscape-helpdesk" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/cytoscape-helpdesk/YsGGPyikZ-4/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> cytoscape-helpd...@googlegroups.com.
>> To post to this group, send email to cytoscape...@googlegroups.com.
> --
> You received this message because you are subscribed to the Google Groups
> "cytoscape-helpdesk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cytoscape-helpd...@googlegroups.com.
> To post to this group, send email to cytoscape...@googlegroups.com.
> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cytoscape-helpdesk/CA%2BBJnuOdZge0V3jRLfPrQZs6_WZX1WttgMMo4HwDkRSouK%3DDew%40mail.gmail.com.

David Otasek

unread,
Jun 8, 2018, 2:33:04 PM6/8/18
to cytoscape-helpdesk
After some investigation, the following came to light: the
specification for discrete mappings is that the value field should be
a String. The quick fix for Shraddha's issue is using:

> setNodeColorMapping('verbal',table.column.values=c('0','1'),colors=c('#000000','#FFFFFF'),mapping.type='d')

Instead of:

> setNodeColorMapping('verbal',table.column.values=c(0,1),colors=c('#000000','#FFFFFF'),mapping.type='d')

The values=c(0,1) should be c('0','1') to work with CyREST.

Shraddha informs me that the documentation for the R function
specifies integers. If this is the case, which particular library is
being used so I can report this?

Ruth

unread,
Jun 8, 2018, 3:27:32 PM6/8/18
to cytoscape...@googlegroups.com
Hi David,
The function is from the bio conductor RCy3 library.
Thanks,
Ruth
> To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/CAGXvV6S-Vgu33M56MdHZ9nJwnZWh-Q1mVPc1VKyC4%3Dxp-i9FdA%40mail.gmail.com.

David Otasek

unread,
Jun 8, 2018, 3:40:10 PM6/8/18
to cytoscape-helpdesk
OK, I'll make an issue for the documentation.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/7685C8FC-2142-45B5-8E6B-57DDA0DB0E2B%40utoronto.ca.

Alex Pico

unread,
Jun 17, 2018, 7:53:29 PM6/17/18
to cytoscape-helpdesk
I went ahead and updated the underlying function to turn all table.column.values into strings for these functions. This should all users to enter integers, floats or strings and it will just work.

Thanks for reporting this!
 - Alex
>>> email to cytoscape-helpdesk+unsub...@googlegroups.com.
>>> To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/cytoscape-helpdesk/495c72e9-8bda-4593-be5c-fdb0bc88f894%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "cytoscape-helpdesk" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/cytoscape-helpdesk/YsGGPyikZ-4/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/cytoscape-helpdesk/011701d3fce7%241b3eecf0%2451bcc6d0%24%40gmail.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "cytoscape-helpdesk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to cytoscape-helpdesk+unsub...@googlegroups.com.
>> To post to this group, send email to cytoscape-helpdesk@googlegroups.com.

Shraddha Pai

unread,
Jun 18, 2018, 11:58:56 AM6/18/18
to cytoscape...@googlegroups.com
Thanks Alex and David! Will let you know when I next try it. 
Best,Shraddha

>>> To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/cytoscape-helpdesk/495c72e9-8bda-4593-be5c-fdb0bc88f894%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "cytoscape-helpdesk" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/cytoscape-helpdesk/YsGGPyikZ-4/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/cytoscape-helpdesk/011701d3fce7%241b3eecf0%2451bcc6d0%24%40gmail.com.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "cytoscape-helpdesk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an

--
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/YsGGPyikZ-4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
Reply all
Reply to author
Forward
0 new messages