cytoscape / py4cytoscape

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

Figure export to PDF cannot fit the whole graph #110

Closed gmhhope closed 1 year ago

gmhhope commented 1 year ago

Dear developers,

I tried to export the figure automatically which fits the whole figure. But it still renders this partial figure. Could you see what might be the issue. I copycat a layout and prune the network then export like following:

# set layout; p4c.layout_network()
p4c.layout_copycat(source_network = source_network_UUID,target_network= "current", source_column='name', target_column='name')

# bundle edge
p4c.bundle_edges()
# p4c.clear_edge_bends()

# export figure
p4c.fit_content()
p4c.export_image(filename="path2my_file.pdf"), 
         type='PDF', 
         height=None, 
         width=None, 
         zoom=None,
         overwrite_file=True) # 

Focused_Factor19_sub-tree-pruneBy-1_to_4_7_to_8_10_to_15_18_to_19_tp1.pdf

Thanks very much for your help!

Best, Minghao Gong

bdemchak commented 1 year ago

Hi ... nothing jumps out as being a problem. Would you be able to provide a version of your network as it exists immediately before calling layout_copycat()? The easiest thing to do would be to save that state in a session file (.cy3) using the Cytoscape GUI.

Thanks

gmhhope commented 1 year ago

Thanks for the prompt response,

I figured that out just now. It looks like somehow if I performed this in a loop, the exported image seems to be scaled based on the source_network. If I scaled the source network to the proper size. The offspring network seems to fit in the page based on its source_network.

The funny part is that: after the loop, if I looked back to the generated network in cytoscape GUI. They become fitted based on their own network size. But during the for loop, I can see the network dynamically fit into the size of its source network (from layout_copycat). And the exported PDF follows the what it looks like in the dynamic process?

Any suggestions?

Thanks, Minghao Gong