cytoscape / cytoscape-automation

Collection of scripts that include programmatic io and control of Cytoscape
Creative Commons Zero v1.0 Universal
81 stars 58 forks source link

want RCy3 code to do "Analyze Subset of Nodes" and "Generate Style from Statistics" #53

Closed tangmaomao16 closed 4 years ago

tangmaomao16 commented 4 years ago

I used to use the graphic interface of Cytoscape software. And I use the "Analyze Subset of Nodes" and "Generate Style from Statistics". But now I need to do a lot of such work. So I set up RCy3 environment on Ubuntu 1804 system. But I cannot find the codes of "Analyze Subset of Nodes" and "Generate Style from Statistics". Please tell me how can I get the codes or achieve such effect.

I want to display the correlation between genus and environment_parameter.

My network file is a tsv file with content like this: genus environment_parameter r_value r_label Russula pH 0.71 pos Mortierella pH 0.75 pos

My node data is a tsv file with content like this: var group Mortierella genus pH environoment_parameter

AlexanderPico commented 4 years ago

Good news: I just recently added the analyzeNetwork function to RCy3, so we should be all set. However, there are a couple issues I'm not sure about:

  1. "Analyze Subset of Nodes" -- I don't think this exists anymore, even in the GUI. If I'm wrong, please point me to it. I think the recommended way to do this now is to make a subnetwork and then perform Tools>Analyze Network. This we can do in RCy3, no problem!
  2. "Generate Style from Stats" -- I don't recall ever seeing this feature. Again, can you point me to it in the manual or in a screenshot? Assuming it's not there anymore, then you'll have to provide more details on what the style entails. The function analyzeNetwork will dump all the stats into the Node and Edge tables. So, it is easy to make styles from the results using RCy3.

The new analyzeNetwork function can be used in Cytoscape 3.8 (released today!) and the dev version of RCy3 (form bioconductor or github). The official bioconductor release will occur in a couple weeks, so it's not there yet.

tangmaomao16 commented 4 years ago

Thank you for your work! Below are Cytoscape-3.7.2 on Windows 10 64bit system screenshot.

Cytoscape-3.7.2-Analyze_Subset_of_Nodes [

Cytoscape-3 7 2-Analyze_Subset_of_Nodes

](url)

Cytoscape-3.7.2-Generate_Style_from_Statistics [

Cytoscape-3 7 2-Generate_Style_from_Statistics

](url)

AlexanderPico commented 4 years ago

Thanks! Huh, never used those. The style feature is simply an older, more limited version of the Style Panel Screen Shot 2020-04-18 at 10 47 17 AM

So, you can Ananlyze Subset using these RCy3 functions:

createSubnetwork()
analyzeNetwork()

(again, you'll need the dev version of RCy3 and the latest Cytoscape v3.8 to get the new analyzeNetwork() function)

And you can set those four styles based on analysis results using these:

setNodeSizeMapping()
setNodeColorMapping()
setEdgeLineWidthMapping()
setEdgeColorMapping()

Good news: You can set any of many dozens of node and edge style properties based on analysis results, so you are longer limited to just these four.

If you need help with updating your script, please provide what you have so far and sample files.

tangmaomao16 commented 4 years ago

Dear friend,when I use the RCy3,I have another problem. The nodes in the plotting figure could be overlapped! So I need to manually use my computer mouse to drag those nodes so that display them not too close.  My question is whether there are some codes in CRy3 to set the nodes display not too close. 

---Original--- From: "Alexander Pico"<notifications@github.com> Date: Sun, Apr 19, 2020 01:55 AM To: "cytoscape/cytoscape-automation"<cytoscape-automation@noreply.github.com>; Cc: "Author"<author@noreply.github.com>;"tangmaomao16"<419242057@qq.com>; Subject: Re: [cytoscape/cytoscape-automation] want RCy3 code to do "Analyze Subset of Nodes" and "Generate Style from Statistics" (#53)

Thanks! Huh, never used those. The style feature is simply an older, more limited version of the Style Panel

So, you can Ananlyze Subset using these RCy3 functions: createSubnetwork() analyzeNetwork()
(again, you'll need the dev version of RCy3 and the latest Cytoscape v3.8 to get the new analyzeNetwork() function)

And you can set those four styles based on analysis results using these: setNodeSizeMapping() setNodeColorMapping() setEdgeLineWidthMapping() setEdgeColorMapping()
Good news: You can set any of many dozens of node and edge style properties based on analysis results, so you are longer limited to just these four.

If you need help with updating your script, please provide what you have so far and sample files.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

AlexanderPico commented 4 years ago

Cytoscape layouts have parameters you can tune to automatically get more spacing, etc:

layoutNetwork('force-directed defaultSpringCoefficient=.00006 defaultSpringLength=80')

Play with the layout parameters in the GUI first to settle on values that you think will work well with the networks you plan to run in your script: Layouts > Layout Settings

You can also interrogate node positions and calculate overlaps if really want to. X and Y positions are just node properties like anything else. You can then programmatically change positions to resolve overlaps. This is a bit extreme, imo. But it is possible. I'd try tuning layouts first :)