Ontology¶
The Ontology class retrieves GO term metadata and gene associations from
the official Gene Ontology API. GO accessions are authoritative; phenotype
text is used only as a display label or a locally registered alias.
Import¶
Quick example¶
from neko._annotations.gene_ontology import Ontology
onto = Ontology(taxon_id=9606)
# Structured records retain both the gene symbol and source identifier.
genes = onto.fetch_go_genes("GO:0062043")
print([(gene.symbol, gene.gene_id) for gene in genes])
# The backward-compatible helper returns symbols only.
markers = onto.get_markers(id_accession="GO:0062043")
By default, only associations whose object is the requested GO term are
returned. Set include_descendants=True to include annotations propagated
from more specific terms. The default taxon is human (NCBITaxon:9606).
Numeric taxonomy IDs and complete NCBITaxon: CURIEs are both accepted.
Automatic assertions are included by default. Pass
exclude_automatic_assertions=True to remove ECO:0000501 associations.
This and the exact-term filter are enforced locally because deployments of
the upstream API have not always applied their corresponding query flags.
HTTP, decoding, and response-schema failures raise GeneOntologyError.
Unknown accessions raise GeneOntologyNotFoundError; a valid term with no
matching genes returns an empty list.
Class reference¶
Ontology ¶
Ontology(taxon_id=9606, timeout=30.0, user_agent='NeKo (https://github.com/sysbio-curie/Neko)', session=None)
class that stores some functionalities to connect phenotypes to nodes and to associate information for each node at tissue level
Source code in neko/_annotations/gene_ontology.py
Methods:¶
get_term ¶
Return canonical metadata for a GO accession.
Source code in neko/_annotations/gene_ontology.py
fetch_go_genes ¶
fetch_go_genes(go_id, *, taxon_id=None, include_descendants=False, exclude_automatic_assertions=False, page_size=_GO_PAGE_SIZE, max_pages=_GO_MAX_PAGES)
Fetch unique genes associated with a GO term.
Source code in neko/_annotations/gene_ontology.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | |
get_markers ¶
get_markers(phenotype=None, id_accession=None, *, taxon_id=None, include_descendants=False, exclude_automatic_assertions=False)
Return gene symbols associated with a GO term.
Source code in neko/_annotations/gene_ontology.py
resolve_accession ¶
Resolve an explicit accession or a registered phenotype alias.
Source code in neko/_annotations/gene_ontology.py
check_tissue_annotations ¶
Check whether genes have detected HPA expression in a tissue.
Args: genes_df (DataFrame): DataFrame containing gene symbols. tissue (str): Tissue to match exactly after case/whitespace normalization.
Returns: DataFrame: Gene symbols and their detected-expression status.
Raises: AnnotationServiceError: If OmniPath is unavailable or returns an unexpected annotation schema.
Source code in neko/_annotations/gene_ontology.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | |