-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
References #35
- Loading branch information
Showing
6 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
layout: page | ||
title: Graph | ||
permalink: /graph/ | ||
--- | ||
This chart shows various aspects of the positive mappings graph. Larger components means that more extensive curation | ||
has been done. Higher density components means that they have been checked multiple times. | ||
|
||
<img src="https://raw.githubusercontent.com/biomappings/biomappings/main/docs/img/components.png" alt="Comparison"/> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ keywords = | |
|
||
[options] | ||
install_requires = | ||
networkx | ||
requests | ||
click | ||
pyyaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Load Biomappings as a graph.""" | ||
|
||
import os | ||
|
||
import matplotlib.pyplot as plt | ||
import networkx as nx | ||
import seaborn as sns | ||
|
||
from biomappings.resources import load_mappings | ||
from biomappings.utils import IMG, MiriamValidator | ||
|
||
|
||
def get_positive_graph() -> nx.Graph: | ||
"""Get a graph of the positive mappings.""" | ||
v = MiriamValidator() | ||
graph = nx.Graph() | ||
for mapping in load_mappings(): | ||
source_curie = v.get_curie(mapping['source prefix'], mapping['source identifier']) | ||
graph.add_node( | ||
source_curie, | ||
prefix=mapping['source prefix'], | ||
identifier=mapping['source identifier'], | ||
name=mapping['source name'], | ||
) | ||
target_curie = v.get_curie(mapping['target prefix'], mapping['target identifier']) | ||
graph.add_node( | ||
target_curie, | ||
prefix=mapping['target prefix'], | ||
identifier=mapping['target identifier'], | ||
name=mapping['target name'], | ||
) | ||
graph.add_edge( | ||
source_curie, | ||
target_curie, | ||
provenance=mapping['source'], | ||
type=mapping['type'], | ||
) | ||
return graph | ||
|
||
|
||
def _main(): | ||
fig, axes = plt.subplots(1, 3, figsize=(10, 3.5)) | ||
graph = get_positive_graph() | ||
|
||
sizes = [len(c) for c in nx.connected_components(graph)] | ||
sns.histplot(sizes, ax=axes[0]) | ||
axes[0].set_yscale('log') | ||
axes[0].set_title('Component Node Sizes') | ||
|
||
sizes = [graph.subgraph(c).number_of_edges() for c in nx.connected_components(graph)] | ||
sns.histplot(sizes, ax=axes[1]) | ||
axes[1].set_yscale('log') | ||
axes[1].set_title('Component Edge Sizes') | ||
axes[1].set_ylabel('') | ||
|
||
densities = [nx.density(graph.subgraph(c)) for c in nx.connected_components(graph)] | ||
sns.histplot(densities, ax=axes[2], kde=True) | ||
axes[2].set_xlim([0.0, 1.0]) | ||
axes[2].set_title('Component Densities') | ||
axes[2].set_ylabel('') | ||
|
||
path = os.path.join(IMG, 'components.png') | ||
print('saving to', path) | ||
plt.tight_layout() | ||
plt.savefig(path, dpi=300) | ||
plt.close(fig) | ||
|
||
|
||
if __name__ == '__main__': | ||
_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters