Closed gmhhope closed 1 year ago
Hi, Minghao ...
These are very good questions ... thanks for raising them.
For the easy one, here are the documented definitions:
singlePartition (string, optional): Don't partition graph before layout, only boolean values allowed: true or false , spacing (string, optional): Circle size, in numeric value
This documentation came from the CyREST documentation available via Cytoscape's Help | Automation | CyREST Command API
... in the POST /v1/commands/layout/attribute-circle section
. You couldn't have known this, but that's the truth.
In your example, I note that you set the layout properties after executing the layout. It's probably not the end of the world, as I'm not exactly sure how to use these functions, but I'll find out.
While I'm doing that, I can give you some good hints.
In the Cytoscape GUI, you can use Layout | Layout Settings
to see that you can select a layout (e.g., Attribute Circle Layout
) to see what kinds of properties can be set. In this case, column name, circle size and partition-graph.
The next step would be to figure out how those properties map to useable property names. For this, use the py4cytoscape getLayoutPropertyNames()
function. For the attribute-circle layout, I see that singlePartition
and spacing
are available. I don't see a property name for the column name.
Ultimately, I think the best answer is probably found in Cytoscape's Command Line feature. To activate it, click on the Command Line button in Cytoscape's lower left corner. Then enter the Command help layout attribute-circle
and notice all of the options. I see:
To me, this implies that there should be a form of command_post() that issues the layout attribute-circle
command and supplies one or more of the properties listed. This isn't directly provided in py4cytoscape, but can be accessed through a custom command_post()
call.
I have to leave for an appointment, but can work on a clear example of this for you tomorrow.
I would really love to hear for an example! Thanks! But the Command line that I have used looks very useful to figure out some of the things in-between!
Again, thanks for the quick reply!
Best, Minghao
I learned how to look into the function but I think I am facing some confusion here.
What I am trying to do is simply replacing the manual step in GUI showing below:
But somehow I just cannot find it in the attribute-circle layout.
Am I really looking at the same function? Let me know! THanks!
Hi --
I think you're pretty close. I should add a little more information.
First, the py4cytoscape call I think you're looking for would be something like this:
import py4cytoscape as p4c
p4c.commands_post('layout attribute-circle nodeAttribute="Degree"')
This creates the attribute-circle layout on the current network using the Degree
column. You can add the network=
parameter if you'd like to choose a network that's not current. Here's a variant that adds more parameters:
import py4cytoscape as p4c
p4c.commands_post('layout attribute-circle nodeAttribute="Degree" network="galFiltered.sif" nodeList="selected"')
This creates the layout on the galFiltered.sif network and uses only nodes that are selected.
To see all of the possible parameters, see the Command Line help (below).
What's really going on here?
There are two REST pathways into Cytoscape, and you can see them by choosing CyREST Command API
and CyREST API
options in Help | Automation
. Each pathway offers different options. The CyREST API
functions access features that resemble function calls, and the CyREST Command API
functions are available in Cytoscape's Command Line window.
py4cytoscape uses these functions to implement its functions, and it does so by using commands_*()
and cyrest_*()
functions as described below. These functions are exposed for your use, too, for cases where the py4cytoscape functions aren't general enough. You can read about this here.
To access CyREST Command API
calls, you would use the Command Line window to figure out the exact command you want, or you would use the CyREST Command API
Swagger page. They do the same thing. Once you have the exact command you want, you can use p4c.commands_post()
to do the same thing from py4cytoscape.
To access the CyREST API
calls, you would use the CyREST API
Swagger page. Once you have a good understanding of the parameters, you would use p4c.cyrest_get()
, p4c.cyrest_post()
, p4c.cyrest_put()
or p4c.cyrest_delete()
.
CyREST Command API
calls are usually easier because they're higher level, as is the case in your situation.
For this situation, feel free to build your own function to call p4c.commands_post()
with whatever command and/or parameters you like.
To understand the layout attribute-circle
documentation, you'd first have to understand the layout and how it works, and then you'd have to already know what the documentation is trying to say. Our apologies for this ... that level of documentation has gotten a lot of attention, but sometimes not enough.
And feel free to ask questions ...
Wonderful! That sounds pretty helpful! I will try it out! Thanks again!
Problem is solved and it is great to see how this alternative can work out in more other usage!
Hi Barry,
I am trying to set the
attribute-circle
usingBut I cannot find any way to do it. BTW, where can I find the documentation of
spacing
andsinglePartition
? Thanks very much!Best, Minghao Gong