-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* First pass at oboformat and obographs conformance suite. See - owlcollab/oboformat#146 - geneontology/obographs#106 Note that that may move from the OAK repo in the longer term. * Allow choice of format when exporting OWL. Addung missing features to obo conversion * lint * lint * Lint. Removing prints. * Added format_utilities.py -- see #687 * lint * Fixing spelling mistakes * dumper * Fixed tests and dumper --------- Co-authored-by: Nico Matentzoglu <[email protected]>
- Loading branch information
Showing
513 changed files
with
15,065 additions
and
61 deletions.
There are no files selected for viewing
248 changes: 248 additions & 0 deletions
248
notebooks/Interfaces/ClassEnrichmentCalculationInterface.ipynb
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,248 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"# ClassEnrichmentCalculationInterface Examples\n", | ||
"\n", | ||
"See also [Python docs](https://incatools.github.io/ontology-access-kit/packages/interfaces/class-enrichment.html)\n", | ||
"\n" | ||
], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "37b92ff6d4a9d98c" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"outputs": [], | ||
"source": [ | ||
"from oaklib.datamodels.input_specification import InputSpecification\n", | ||
"from oaklib import get_adapter\n", | ||
"spec = InputSpecification(\n", | ||
" ontology_resources={\n", | ||
" \"hp\": {\n", | ||
" \"selector\": \"sqlite:obo:hp\"\n", | ||
" },\n", | ||
" },\n", | ||
" association_resources={\n", | ||
" \"hpoa\": {\n", | ||
" \"selector\": \"hpoa:\"\n", | ||
" }\n", | ||
" }\n", | ||
")\n", | ||
"\n", | ||
"adapter = get_adapter(spec)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:15.716905Z", | ||
"start_time": "2024-03-14T00:42:17.829253Z" | ||
} | ||
}, | ||
"id": "d603fc57b88cc6b4" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"outputs": [], | ||
"source": [ | ||
"from oaklib.interfaces.association_provider_interface import AssociationProviderInterface\n", | ||
"\n", | ||
"if not isinstance(adapter, AssociationProviderInterface):\n", | ||
" raise ValueError(\"Adapter is not an AssociationProviderInterface\")\n" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:15.721279Z", | ||
"start_time": "2024-03-14T00:43:15.717935Z" | ||
} | ||
}, | ||
"id": "7e90e7b35311c8b0" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"outputs": [], | ||
"source": [ | ||
"from oaklib.datamodels.vocabulary import IS_A\n", | ||
"\n", | ||
"pinna_associations = list(adapter.associations(objects=[\"HP:0000377\"], object_closure_predicates=[IS_A]))" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:16.024951Z", | ||
"start_time": "2024-03-14T00:43:15.734336Z" | ||
} | ||
}, | ||
"id": "935a60c956947ad2" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"OMIM:619426 HP:0020206 Simple ear\n", | ||
"OMIM:619426 HP:0000400 Macrotia\n", | ||
"OMIM:619426 HP:0000369 Low-set ears\n", | ||
"OMIM:619354 HP:0100830 Round ear\n", | ||
"OMIM:117650 HP:0000358 Posteriorly rotated ears\n", | ||
"OMIM:117650 HP:0000369 Low-set ears\n", | ||
"OMIM:615546 HP:0008551 Microtia\n", | ||
"OMIM:618076 HP:0009748 Large earlobe\n", | ||
"OMIM:618076 HP:0000369 Low-set ears\n", | ||
"OMIM:618076 HP:0008551 Microtia\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for assoc in pinna_associations[0:10]:\n", | ||
" print(assoc.subject, assoc.object, adapter.label(assoc.object))" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:16.035600Z", | ||
"start_time": "2024-03-14T00:43:16.025992Z" | ||
} | ||
}, | ||
"id": "b9fea431d59366fb" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": "1885" | ||
}, | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"diseases = {assoc.subject for assoc in pinna_associations}\n", | ||
"len(diseases)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:16.044305Z", | ||
"start_time": "2024-03-14T00:43:16.039789Z" | ||
} | ||
}, | ||
"id": "5e7bc45185328732" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"outputs": [], | ||
"source": [ | ||
"from oaklib.interfaces.class_enrichment_calculation_interface import ClassEnrichmentCalculationInterface\n", | ||
"\n", | ||
"if not isinstance(adapter, ClassEnrichmentCalculationInterface):\n", | ||
" raise ValueError(\"Adapter is not an AssociationProviderInterface\")\n" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:16.063572Z", | ||
"start_time": "2024-03-14T00:43:16.044169Z" | ||
} | ||
}, | ||
"id": "ce52323e5f0c095b" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"outputs": [], | ||
"source": [ | ||
"results = list(adapter.enriched_classes(\n", | ||
" subjects=diseases,\n", | ||
" object_closure_predicates=[IS_A],\n", | ||
"))" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:38.162127Z", | ||
"start_time": "2024-03-14T00:43:16.052039Z" | ||
} | ||
}, | ||
"id": "e397ed9448310f70" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"ClassEnrichmentResult(class_id='HP:0000347', class_label=None, rank=1, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=738, sample_total=1885, background_count=1138, background_total=12496, ancestor_of_more_informative_result=None, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0009118', class_label=None, rank=2, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=741, sample_total=1885, background_count=1142, background_total=12496, ancestor_of_more_informative_result=True, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0001167', class_label=None, rank=3, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=960, sample_total=1885, background_count=2064, background_total=12496, ancestor_of_more_informative_result=None, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0009116', class_label=None, rank=4, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=749, sample_total=1885, background_count=1161, background_total=12496, ancestor_of_more_informative_result=True, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0000277', class_label=None, rank=5, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=972, sample_total=1885, background_count=1611, background_total=12496, ancestor_of_more_informative_result=True, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0030791', class_label=None, rank=6, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=1008, sample_total=1885, background_count=1700, background_total=12496, ancestor_of_more_informative_result=True, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0000288', class_label=None, rank=7, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=690, sample_total=1885, background_count=991, background_total=12496, ancestor_of_more_informative_result=None, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0200006', class_label=None, rank=8, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=691, sample_total=1885, background_count=980, background_total=12496, ancestor_of_more_informative_result=None, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0000177', class_label=None, rank=9, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=903, sample_total=1885, background_count=1418, background_total=12496, ancestor_of_more_informative_result=True, descendant_of_more_informative_result=None)\n", | ||
"ClassEnrichmentResult(class_id='HP:0002683', class_label=None, rank=10, p_value=0.0, p_value_adjusted=0.0, false_discovery_rate=None, fold_enrichment=None, probability=None, sample_count=812, sample_total=1885, background_count=1475, background_total=12496, ancestor_of_more_informative_result=None, descendant_of_more_informative_result=None)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for r in results[0:10]:\n", | ||
" print(r)" | ||
], | ||
"metadata": { | ||
"collapsed": false, | ||
"ExecuteTime": { | ||
"end_time": "2024-03-14T00:43:38.166018Z", | ||
"start_time": "2024-03-14T00:43:38.162557Z" | ||
} | ||
}, | ||
"id": "3a4052bbf6960d51" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"outputs": [], | ||
"source": [], | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"id": "b69c08ab05ab268e" | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.