Skip to content
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

HPO gene to disease ingest #449

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/Sources/HPOA.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ Association to "remarkable normality" may be added in the near future.

The 'disease-to-mode-of-inheritance' ingest script parses 'inheritance' record information out from the annotation file.

### Gene to Disease

This ingest replaces the direct OMIM ingest so that we share g2d associations 1:1 with HPO. The mapping between association_type and biolink predicates shown below is the one way in which this ingest is opinionated, but attempts to be a direct translation into the biolink model.

**genes_to_disease.txt** with the following fields:

- 'ncbi_gene_id'
- 'gene_symbol'
- 'association_type'
- 'disease_id'
- 'source'

### Biolink Captured

* biolink:DiseaseToPhenotypicFeatureAssociation
* id (random uuid)
* subject (ncbi_gene_id)
* predicate (association_type)
* MENDELIAN: `biolink:causes`
* POLYGENIC: `biolink:contributes_to`
* UNKNOWN: `biolink:gene_associated_with_condition`
* object (disease_id)
* primary_knowledge_source (source)
* medgen: `infores:omim`
* orphanet: `infores:orphanet`
* aggregator_knowledge_source (["infores:monarchinitiative"])
* also for medgen: `infores:medgen`

### Disease to Phenotype

**phenotype.hpoa:** [A description of this file is found here](https://hpo-annotation-qc.readthedocs.io/en/latest/annotationFormat.html#phenotype-hpoa-format), has the following fields:
Expand Down
45 changes: 0 additions & 45 deletions docs/Sources/OMIM.md

This file was deleted.

63 changes: 62 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ isort = "^5.9.1"
mkdocs = "^1.3.0"
mkdocs-material = "^8.2.9"
pytest = "^7.1.1"
black = "^23.3.0"

[tool.poetry.scripts]
ingest = "monarch_ingest.main:typer_app"
Expand Down
10 changes: 10 additions & 0 deletions src/monarch_ingest/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# knowledge sources
INFORES_MONARCHINITIATIVE = "infores:monarchinitiative"
INFORES_OMIM = "infores:omim"
INFORES_ORPHANET = "infores:orphanet"
INFORES_MEDGEN = "infores:medgen"

# predicates
BIOLINK_CAUSES = "biolink:causes"
BIOLINK_CONTRIBUTES_TO = "biolink:contributes_to"
BIOLINK_GENE_ASSOCIATED_WITH_CONDITION = "biolink:gene_associated_with_condition"
4 changes: 2 additions & 2 deletions src/monarch_ingest/ingests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ hgnc_gene:
config: 'ingests/hgnc/gene.yaml'
hpoa_disease_phenotype:
config: 'ingests/hpoa/disease_phenotype.yaml'
hpoa_gene_to_disease:
config: 'ingests/hpoa/gene_to_disease.yaml'
hpoa_disease_mode_of_inheritance:
config: 'ingests/hpoa/disease_mode_of_inheritance.yaml'
hpoa_gene_to_phenotype:
Expand All @@ -30,8 +32,6 @@ hpoa_gene_to_phenotype:
# config: 'ingests/mgi/publication_to_gene.yaml'
ncbi_gene:
config: 'ingests/ncbi/gene.yaml'
omim_gene_to_disease:
config: 'ingests/omim/gene_to_disease.yaml'
panther_genome_orthologs:
config: 'ingests/panther/genome_orthologs.yaml'
pombase_gene:
Expand Down
26 changes: 26 additions & 0 deletions src/monarch_ingest/ingests/hpoa/gene_to_disease.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from biolink.pydanticmodel import GeneToDiseaseAssociation
from koza.cli_runner import get_koza_app

from monarch_ingest.constants import INFORES_MONARCHINITIATIVE
from monarch_ingest.ingests.hpoa.hpoa_utils import get_knowledge_sources, get_predicate

koza_app = get_koza_app("hpoa_gene_to_disease")


while (row := koza_app.get_row()) is not None:
gene_id = row["ncbi_gene_id"]
disease_id = row["disease_id"]

predicate = get_predicate(row["association_type"])

primary_knowledge_source, aggregator_knowledge_source = get_knowledge_sources(row["source"], INFORES_MONARCHINITIATIVE)

association = GeneToDiseaseAssociation(
subject=gene_id,
predicate=predicate,
object=disease_id,
primary_knowledge_source=primary_knowledge_source,
aggregator_knowledge_source=aggregator_knowledge_source
)

koza_app.write(association)
27 changes: 27 additions & 0 deletions src/monarch_ingest/ingests/hpoa/gene_to_disease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'hpoa_gene_to_disease'

files:
# - './data/hpoa/genes_to_disease.txt'
- './data/hpoa/subset_genes_to_disease.txt'

format: 'csv'

delimiter: '\t'

columns:
- 'ncbi_gene_id'
- 'gene_symbol'
- 'association_type'
- 'disease_id'
- 'source'

edge_properties:
- 'id'
- 'category'
- 'subject'
- 'predicate'
- 'object'
- 'aggregator_knowledge_source'
- 'primary_knowledge_source'

transform_mode: 'flat'
39 changes: 39 additions & 0 deletions src/monarch_ingest/ingests/hpoa/hpoa_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from loguru import logger

from monarch_ingest.constants import INFORES_MEDGEN, INFORES_OMIM, INFORES_ORPHANET, BIOLINK_CAUSES, \
BIOLINK_CONTRIBUTES_TO, BIOLINK_GENE_ASSOCIATED_WITH_CONDITION


class FrequencyHpoTerm(NamedTuple):
curie: str
Expand Down Expand Up @@ -94,3 +97,39 @@ def phenotype_frequency_to_hpo_term(
return None

return hpo_term, percentage, quotient # percentage and/or quotient will also be None if not applicable


def get_knowledge_sources(original_source: str, additional_source: str) -> (str, List[str]):
"""
Return a tuple of the primary_knowledge_source and original_knowledge_source
"""
_primary_knowledge_source: str = ""
_aggregator_knowledge_source: List[str] = []

if additional_source is not None:
_aggregator_knowledge_source.append(additional_source)

if "medgen" in original_source:
_aggregator_knowledge_source.append(INFORES_MEDGEN)
_primary_knowledge_source = INFORES_OMIM
elif "orphadata" in original_source:
_primary_knowledge_source = INFORES_ORPHANET

if _primary_knowledge_source == "":
raise ValueError(f"Unknown knowledge source: {original_source}")

return _primary_knowledge_source, _aggregator_knowledge_source


def get_predicate(original_predicate: str) -> str:
"""
Convert the association column into a Biolink Model predicate
"""
if original_predicate == 'MENDELIAN':
return BIOLINK_CAUSES
elif original_predicate == 'POLYGENIC':
return BIOLINK_CONTRIBUTES_TO
elif original_predicate == 'UNKNOWN':
return BIOLINK_GENE_ASSOCIATED_WITH_CONDITION
else:
raise ValueError(f"Unknown predicate: {original_predicate}")
Loading