cytoscape / py4cytoscape

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

A general question, can cytoscape render markdown text format? #116

Closed gmhhope closed 1 year ago

gmhhope commented 1 year ago

Hi Barry,

Just a general question, can cytoscape render markdown text in the labeling of the nodes? e.g., CD4<sup>+</sup> M CCR6<sup>-</sup> CXCR3<sup>+</sup> (%). It might run over py4cyotoscape but I guess you might have clues?

Thanks, Minghao Gong

bdemchak commented 1 year ago

Hi --

Yes, I think there would be (at least) two ways of doing this ... this is more a Cytoscape question first, and then you'll be able to see how this is reflected in py4cytoscape.

1) Select a node, then use the Style (aka visual mapper) to locate the Label property, then double-click on Label's Bypass button and enter your value.

2) Create a new column (e.g., NewName) and use Style to locate the Label property, then double-click on Label's Map button. You should see that the Common column is selected for a Passthru mapping. Instead of Common, choose the NewName column. Finally, select a node and enter your value in the NewName column for your node.

The above description is shorthand, and if you're stuck, I'm happy to explain more.

Given the above, I'd focus on:

set_node_label_bypass() set_node_label_mapping() load_table_data()

Feel free to ask questions

image

gmhhope commented 1 year ago

@bdemchak Oh wait, I pasted the CD4<sup>+</sup> M CCR6<sup>-</sup> CXCR3<sup>+</sup> (%) in the bypass. It doesn't render what you have there

Screenshot 2023-08-31 at 2 28 02 PM

Did you convert to the markdown-format before copying into the box?

bdemchak commented 1 year ago

I see ... no, I posted exactly the characters but not with markup.

I'd be very surprised to see markup being rendered here. That type of rendering is a very heavyweight operation, and Cytoscape is trying to display thousands or even millions of nodes. Markup wouldn't be the common case, but it could drag down all cases.

A more reasonable way of displaying markup would be with an Annotation, but I see that even that doesn't do markup rendering.

I'll ask around to see if anyone has suggestions.

bdemchak commented 1 year ago

While I'm asking around, I also played with this a little.

This can be done by choosing a font that has superscript or subscript characters. TimesNewRoman has them (e.g., characters 207A). See the result:

image

Is this what you're looking for?

gmhhope commented 1 year ago

Great to hear this can work out! I will try out. Thanks for the efforts!

Problem solved!