cytoscape / py4cytoscape

Python library for calling Cytoscape Automation via CyREST
https://Py4Cytoscape.readthedocs.io
Other
69 stars 15 forks source link

Group attribute layout with certain ordering of the members? #126

Open gmhhope opened 9 months ago

gmhhope commented 9 months ago

Hi Barry,

Trying to use group attribute to do layout, at the same time ordering the members in the group with a fixed order? What might be a good way to do that? How the order was settled in cytoscape?

Screenshot 2023-12-17 at 2 16 22 PM

I am in very urgent need for this settled. Thanks for any input you can provide!

Thanks very much! Happy holiday!

Best, Minghao Gong

bdemchak commented 9 months ago

Hi, Minghao ... Glad to see you working on this. I see the screenshot. Is this a circular layout? If so, what column did you use as the key, and how would you like for this to look instead?

gmhhope commented 9 months ago

Thanks for the prompt response Barry!

I want this to be ordered by Factor #. I would like to make it work both using Circular layout or Group Attribute layout. Both based on two groups (being HC, shown in the screenshot as well as other groups). So the column I used here is anything like "group", "tag" or whatever with character-type string

Hope that clarify.

Best, Minghao Gong

bdemchak commented 8 months ago

Hi, Minghao Gong -

I have a question into the developers about this ... they haven't answered yet. When they do, I'll relay the information I get.

Thanks!

GeneCodeSavvy commented 1 week ago

@gmhhope

Hi Minghao Gong,

I noticed this question is from a while back, but if you’re still looking for a solution or if it might help others, I wanted to share a potential approach!

https://github.com/user-attachments/assets/8bbb487c-35e9-4ef3-8584-738b86d1c739 Here’s a step-by-step breakdown of how you can arrange nodes in a fixed order:

  1. Export the Node Table:

    • Start by exporting your node table from Cytoscape. This will generate a file containing the nodes and their attributes.
  2. Add the 'Order' Column:

    • Open the exported file in a spreadsheet editor (e.g., Excel). Add a new column named order, and fill in the values according to the desired node sequence. For large networks, automating this process programmatically might be more efficient.
  3. Import the Updated Table Back into Cytoscape:

    • Navigate to File → Import → Table from File....
    • Select your updated file (with the order column).
    • In the Target Table Data section, choose where to import the data (e.g., your existing network).
    • For more details on this process, check out the Cytoscape manual.
  4. Use the 'Order' Column for Layout:

    • Once imported, utilize the order column to guide the layout arrangement of your nodes.

Bonus: You can further refine the layout using the Layout → Layout Tools options for scaling, aligning, distributing, stacking, and rotating the network and selected nodes.

Hope this helps!

Best,
Harsh Sharma

cc: @bdemchak