ClassEnrichmentCalculationInterface Examples
See also Python docs
[6]:
from oaklib.datamodels.input_specification import InputSpecification
from oaklib import get_adapter
spec = InputSpecification(
ontology_resources={
"hp": {
"selector": "sqlite:obo:hp"
},
},
association_resources={
"hpoa": {
"selector": "hpoa:"
}
}
)
adapter = get_adapter(spec)
[7]:
from oaklib.interfaces.association_provider_interface import AssociationProviderInterface
if not isinstance(adapter, AssociationProviderInterface):
raise ValueError("Adapter is not an AssociationProviderInterface")
[8]:
from oaklib.datamodels.vocabulary import IS_A
pinna_associations = list(adapter.associations(objects=["HP:0000377"], object_closure_predicates=[IS_A]))
[9]:
for assoc in pinna_associations[0:10]:
print(assoc.subject, assoc.object, adapter.label(assoc.object))
OMIM:619426 HP:0020206 Simple ear
OMIM:619426 HP:0000400 Macrotia
OMIM:619426 HP:0000369 Low-set ears
OMIM:619354 HP:0100830 Round ear
OMIM:117650 HP:0000358 Posteriorly rotated ears
OMIM:117650 HP:0000369 Low-set ears
OMIM:615546 HP:0008551 Microtia
OMIM:618076 HP:0009748 Large earlobe
OMIM:618076 HP:0000369 Low-set ears
OMIM:618076 HP:0008551 Microtia
[10]:
diseases = {assoc.subject for assoc in pinna_associations}
len(diseases)
[10]:
1885
[11]:
from oaklib.interfaces.class_enrichment_calculation_interface import ClassEnrichmentCalculationInterface
if not isinstance(adapter, ClassEnrichmentCalculationInterface):
raise ValueError("Adapter is not an AssociationProviderInterface")
[12]:
results = list(adapter.enriched_classes(
subjects=diseases,
object_closure_predicates=[IS_A],
))
[13]:
for r in results[0:10]:
print(r)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
[ ]: