tmuetze / Bioconductor_RCy3_the_new_RCytoscape

Update RCytoscape to work for Cytoscape 3.0 and higher using CyREST
16 stars 10 forks source link

Rules cannot overturn a style #44

Open kieran-mace opened 6 years ago

kieran-mace commented 6 years ago

If I choose to use a default style, but want to modify something about it, I can't. For example, I'm implementing the Curved style below, and if I try to change the node color rules after, they do not take effect.

deleteAllWindows(CytoscapeConnection())

cw <- CytoscapeWindow ('setNodeColorRule.test', graph=makeSimpleGraph())
displayGraph (cw)
layoutNetwork (cw, 'force-directed')

# Here I set the visual style, which does include node color
setVisualStyle(cw, 'Curved')

# here I update the colors using lookup mode but they have no effect
data.values <- c("kinase", "transcription factor", "glycoprotein")
node.colors <- c("#0000AA", "#FFFF00", "#0000AA") 
setNodeColorRule (cw, node.attribute.name='type', data.values, node.colors, mode='lookup', default.color='#AA0000')
AlexanderPico commented 6 years ago

It looks like all you need to do is add style.name = 'Curved' to your arg list for setNodeColorRule. Without this arg, the rule is applied to the default style. This does NOT mean the last style you set, but rather the style named default which is a fixed thing. Does this make sense?

kieran-mace commented 6 years ago

Thanks for the suggestion. It does make sense, however when I give your solution a go, I get an error:

setNodeColorRule (cw, 
    node.attribute.name='type', 
    data.values, 
    node.colors, 
    mode='lookup', 
    default.color='#AA0000', 
    style.name = 'Curved')
Error in setNodeColorRule(cw, node.attribute.name = "type", data.values,  : 
  unused argument (style.name = "Curved")

Also the docs don't have a style.name argument for setNodeColorRule. Maybe I need to update RCy3?

AlexanderPico commented 6 years ago

Ah, sorry. I'm in the middle of a refactor which includes some renamed args. The arg in the currently release version is vizmap.style.name. Can you try that?