emmo-repo / EMMOntoPy

Library for representing and working with ontologies in Python
https://emmo-repo.github.io/EMMOntoPy
BSD 3-Clause "New" or "Revised" License
40 stars 9 forks source link

visualization of EMMO based ontology #412

Closed mdforti closed 2 years ago

mdforti commented 2 years ago

I am trying to follow the examples, but the first cytoscape example at

https://github.com/emmo-repo/EMMO-python/blob/master/examples/jupyter-visualization/emmographs.ipynb

fails with this message:

File /scratch/AnacondaEnvironments/Ontologies/lib/python3.9/site-packages/ontopy/graph.py:1073, in cytoscapegraph(graph, onto, infobox) 1070 data = cytoscape_data(pydot_graph)["elements"] 1071 for datum in data["edges"]: 1072 datum["data"]["label"] = ( -> 1073 datum["data"]["label"].rsplit(" ", 1)[0].lstrip('"') 1074 ) 1075 lab = datum["data"]["label"].replace("Inverse(", "").rstrip(")") 1076 try:

KeyError: 'label'

I would appreciate any guidance on this.

francescalb commented 2 years ago

Thank you for pointing this out to us.

I see that the reason for this i a change in the default values for the original graph generation.

If you add edgelabels=True, it should work i.e.

replacing the line: graph = OntoGraph(onto, onto.Perspective, leafs=leafs, parents=1

with graph = OntoGraph(onto, onto.Perspective, leafs=leafs, parents=1, edgelabels=True)

mdforti commented 2 years ago

First of all, thank you for the fix based on this issue! I also needed to update networkx to conda-forge version to make it work, finally. It would also be helpfull if you can provide some references on how to tweak the cytograph plots, i.e. labels on relations, orientation and forcing position of some nodes.

francescalb commented 2 years ago

Hi, we have not gone into details on how to tweak the graphs as of yet. We are using the ipycytoscapegraph package which is documented here https://ipycytoscape.readthedocs.io/en/master/index.html .