Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prior Knowledge: Integrate BioCypher #17

Open
vicpaton opened this issue May 30, 2024 · 8 comments
Open

Prior Knowledge: Integrate BioCypher #17

vicpaton opened this issue May 30, 2024 · 8 comments
Assignees
Milestone

Comments

@vicpaton
Copy link
Collaborator

The integration of BioCypher in NC should provide a graph (networkx or CORNETO graph) retrieved from various prior knowledge sources, including OmniPath.

@nilskre
Copy link

nilskre commented Jun 3, 2024

To keep track of the current state: the issue to create a networkx output adapter for BioCypher. I keep you updated, when this is implemented in BioCypher.

@slobentanzer
Copy link
Member

@vicpaton @martingarridorc The NetworkX output adapter is merged: biocypher/biocypher#352

Currently, the workflow is to write a pickle of the NetworkX object to disk. Maybe it's worth considering an addition to do the transfer in-memory as well (as we do with the Pandas object). This could make the workflow of handover to the algorithm part of networkcommons more seamless.

When using the NetworkX mode as described in the docs, BioCypher also writes an ingestion script as an accessibility tool for loading the object back into Python.

@vicpaton
Copy link
Collaborator Author

great! this is very useful thanks @slobentanzer @nilskre

@vicpaton vicpaton added this to the EBI-retreat milestone Jun 18, 2024
@vicpaton vicpaton self-assigned this Jun 18, 2024
@vicpaton
Copy link
Collaborator Author

@slobentanzer @nilskre do you think it would be possible to directly provide the networkx graph? It would allow better integration with the nc

@nilskre
Copy link

nilskre commented Jun 18, 2024

By directly you mean, that you have a BioCypher instance (bc) within nc and can directly get the networkx in-memory representation of the KG by calling something like bc.get_networkx() returning the networkx graph, right? (so kind of similar how it is done with Pandas at the moment within BioCypher https://biocypher.org/api.html#in-memory-pandas-knowledge-graph).

@slobentanzer
Copy link
Member

Yes, I think that would be most seamless.

@vicpaton
Copy link
Collaborator Author

@nilskre yes, exactly! that would be great

@nilskre
Copy link

nilskre commented Jun 18, 2024

Alright, got it. Just created an issue in BioCypher to also make this use case directly possible.

Until we have implemented this in BioCypher a fast workaround for your PoC, would be to directly access the networkx graph by the private attributes (not recommended for permanent use!)

    bc = BioCypher(
        biocypher_config_path="biocypher_config.yaml", # with dbms: networkx
        schema_config_path="schema_config.yaml",
    )
    # Run the import
    bc.write_nodes(node_generator())
    bc.write_edges(edge_generator())

    # Write command line call
    bc.write_import_call() # <- important to call this, otherwise the networkx graph is not initialized

    in_memory_graph = bc._writer.G # <- this returns the in memory networkx graph
    print(in_memory_graph)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants