-
Notifications
You must be signed in to change notification settings - Fork 8
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
multidigraph_to_digraph transitive reduction option #16
Conversation
background information at https://twitter.com/larsjuhljensen/status/1450188835032375300 Ontologies such as GO can be reduced when collapsing multiple relationship types into a single relationship type DiGraph.
GO edges removed by reductionTransitive reduction of GO went from 87,436 to 79,946 by removing 7,490 redundant edges. Examples of removed edges:
Sourceimport random
import networkx as nx
import pronto
from nxontology.imports import pronto_to_multidigraph, multidigraph_to_digraph
url = "http://release.geneontology.org/2021-02-01/ontology/go-basic.json.gz"
go_pronto = pronto.Ontology(handle=url)
go_multidigraph = pronto_to_multidigraph(go_pronto)
go_digraph_full = multidigraph_to_digraph(go_multidigraph, reduce=False)
go_digraph_reduced = multidigraph_to_digraph(go_multidigraph, reduce=True)
removed_edges = sorted(go_digraph_full.edges - go_digraph_reduced.edges)
print(f"Transitive reduction of GO went from {go_digraph_full.number_of_edges():,} to {go_digraph_reduced.number_of_edges():,} by removing {len(removed_edges):,} redundant edges.")
random.seed(0)
sample_removed_edges = sorted(random.sample(removed_edges, k=10))
for source, target in sample_removed_edges:
print(f"- `{source}` --> `{target}`\n {go_pronto.get_term(source).name} --> {go_pronto.get_term(target).name}") |
Visualizing redundant edgesFrom AmiGo under Graph Views (Graphical View PNG), here are the ancestors (superterms) for Notice the red edge from "negative regulation of defense response to insect" to "defense response to insect". This edge (along with other red edges and some black edges) are be removed by the transitive reduction. |
Hat tip to @eric-czech for first alerting me that |
Hmm could be, though I thought I had attempted it on GO. I was working with the reverse orientation of the edges so maybe that influences the running time a lot? |
background information at https://twitter.com/larsjuhljensen/status/1450188835032375300
Ontologies such as GO can be reduced to minimum equivalent graph when collapsing multiple relationship types into a single relationship type DiGraph.