translator-openpredict

๐Ÿ”ฎ๐Ÿ A package to help serve predictions of biomedical concepts associations as Translator Reasoner API

https://github.com/maastrichtu-ids/translator-openpredict

Science Score: 72.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • โœ“
    CITATION.cff file
    Found CITATION.cff file
  • โœ“
    codemeta.json file
    Found codemeta.json file
  • โœ“
    .zenodo.json file
    Found .zenodo.json file
  • โ—‹
    DOI references
  • โœ“
    Academic publication links
    Links to: ncbi.nlm.nih.gov, science.org
  • โœ“
    Committers with academic emails
    1 of 8 committers (12.5%) from academic institutions
  • โœ“
    Institutional organization owner
    Organization maastrichtu-ids has institutional domain (www.maastrichtuniversity.nl)
  • โ—‹
    JOSS paper metadata
  • โ—‹
    Scientific vocabulary similarity
    Low similarity (14.3%) to scientific vocabulary

Keywords

biomedical-concepts-associations openapi predict translator-api trapi
Last synced: 6 months ago · JSON representation ·

Repository

๐Ÿ”ฎ๐Ÿ A package to help serve predictions of biomedical concepts associations as Translator Reasoner API

Basic Info
Statistics
  • Stars: 12
  • Watchers: 7
  • Forks: 7
  • Open Issues: 17
  • Releases: 12
Topics
biomedical-concepts-associations openapi predict translator-api trapi
Created over 5 years ago · Last pushed 12 months ago
Metadata Files
Readme Contributing License Citation Codeowners

README.md

๐Ÿ”ฎ๐Ÿ Translator OpenPredict

Python versions

This repository contains the code for the OpenPredict Translator API available at openpredict.semanticscience.org, which serves a few prediction models developed at the Institute of Data Science.

  • various folders for different prediction models served by the OpenPredict API are available under src/:
    • the OpenPredict drug-disease prediction model in src/openpredict_model/
    • a model to compile the evidence path between a drug and a disease explaining the predictions of the OpenPredict model in src/openpredict_evidence_path/
    • a prediction model trained from the Drug Repurposing Knowledge Graph (aka. DRKG) in src/drkg_model/
  • the code for the OpenPredict API endpoints in src/trapi/ defines:
    • a TRAPI endpoint returning predictions for the loaded models

The data used by the models in this repository is downloaded into the data/ folder, and stored on HuggingFace at https://huggingface.co/datasets/um-ids/translator-openpredict

Deploy the OpenPredict API locally

Requirements: Python 3.8+ and pip installed

  1. Clone the repository with submodule:

bash git clone --recursive https://github.com/MaastrichtU-IDS/translator-openpredict.git cd translator-openpredict

  1. Start the API in development mode with docker on http://localhost:8808, the API will automatically reload when you make changes in the code:

bash docker compose up api

[Note regarding the data files: The docker container should download the data automatically from the huggingface repo into the data subfolder. If, for any reason, you need to download separately, you can do this from the commandline using huggingface_cli:

bash huggingface-cli download um-ids/translator-openpredict \ --local-dir ./data/ --repo-type dataset The data can also be downloaded manually from the repo if needed.

]

Contributions are welcome! If you wish to help improve OpenPredict, see the instructions to contribute :woman_technologist: for more details on the development workflow

Test the OpenPredict API

Run the tests locally with docker:

bash docker compose run tests

See the TESTING.md file for more details on testing the API.

You can change the entrypoint of the test container to run other commands, such as training a model:

```bash docker compose run --entrypoint "python src/openpredict_model/train.py train-model" tests

Or with the helper script:

./resources/run.sh python src/openpredict_model/train.py train-model ```

Use the OpenPredict API

The user provides a drug or a disease identifier as a CURIE (e.g. DRUGBANK:DB00394, or OMIM:246300), and choose a prediction model (only the Predict OMIM-DrugBank classifier is currently implemented).

The API will return predicted targets for the given drug or disease:

  • The potential drugs treating a given disease :pill:
  • The potential diseases a given drug could treat :microbe:

Feel free to try the API at openpredict.semanticscience.org

TRAPI operations

Operations to query OpenPredict using the Translator Reasoner API standards.

Query operation

The /query operation will return the same predictions as the /predict operation, using the ReasonerAPI format, used within the Translator project.

The user sends a ReasonerAPI query asking for the predicted targets given: a source, and the relation to predict. The query is a graph with nodes and edges defined in JSON, and uses classes from the BioLink model.

You can use the default TRAPI query of OpenPredict /query operation to try a working example.

Example of TRAPI query to retrieve drugs similar to a specific drug:

json { "message": { "query_graph": { "edges": { "e01": { "object": "n1", "predicates": [ "biolink:similar_to" ], "subject": "n0" } }, "nodes": { "n0": { "categories": [ "biolink:Drug" ], "ids": [ "DRUGBANK:DB00394" ] }, "n1": { "categories": [ "biolink:Drug" ] } } } }, "query_options": { "n_results": 3 } }

Predicates operation

The /predicates operation will return the entities and relations provided by this API in a JSON object (following the ReasonerAPI specifications).

Try it at https://openpredict.semanticscience.org/predicates

Notebooks examples :notebookwithdecorative_cover:

We provide Jupyter Notebooks with examples to use the OpenPredict API:

  1. Query the OpenPredict API
  2. Generate embeddings with pyRDF2Vec, and import them in the OpenPredict API

Add embedding :station:

The default baseline model is openpredict_baseline. You can choose the base model when you post a new embeddings using the /embeddings call. Then the OpenPredict API will:

  1. add embeddings to the provided model
  2. train the model with the new embeddings
  3. store the features and model using a unique ID for the run (e.g. 7621843c-1f5f-11eb-85ae-48a472db7414)

Once the embedding has been added you can find the existing models previously generated (including openpredict_baseline), and use them as base model when you ask the model for prediction or add new embeddings.

Predict operation :crystal_ball:

Use this operation if you just want to easily retrieve predictions for a given entity. The /predict operation takes 4 parameters (1 required):

  • A drug_id to get predicted diseases it could treat (e.g. DRUGBANK:DB00394)
    • OR a disease_id to get predicted drugs it could be treated with (e.g. OMIM:246300)
  • The prediction model to use (default to Predict OMIM-DrugBank)
  • The minimum score of the returned predictions, from 0 to 1 (optional)
  • The limit of results to return, starting from the higher score, e.g. 42 (optional)

The API will return the list of predicted target for the given entity, the labels are resolved using the Translator Name Resolver API

Try it at https://openpredict.semanticscience.org/predict?drug_id=DRUGBANK:DB00394


More about the data model :minidisc:

  • The gold standard for drug-disease indications has been retrieved from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3159979
  • Metadata about runs, models evaluations, features are stored as RDF using the ML Schema ontology.

Diagram of the data model used for OpenPredict, based on the ML Schema ontology (mls):

OpenPredict datamodel


Translator application

Service Summary

Query for drug-disease pairs predicted from pre-computed sets of graphs embeddings.

Add new embeddings to improve the predictive models, with versioning and scoring of the models.

Component List

API component

  1. Component Name: OpenPredict API

  2. Component Description: Python API to serve pre-computed set of drug-disease pair predictions from graphs embeddings

  3. GitHub Repository URL: https://github.com/MaastrichtU-IDS/translator-openpredict

  4. Component Framework: Knowledge Provider

  5. System requirements

    5.1. Specific OS and version if required: python 3.8

    5.2. CPU/Memory (for CI, TEST and PROD): 32 CPUs and 32 Go memory ?

    5.3. Disk size/IO throughput (for CI, TEST and PROD): 20 Go ?

    5.4. Firewall policies: does the team need access to infrastructure components? The NodeNormalization API https://nodenormalization-sri.renci.org

  6. External Dependencies (any components other than current one)

    6.1. External storage solution: Models and database are stored in /data/openpredict in the Docker container

  7. Docker application:

    7.1. Path to the Dockerfile: Dockerfile

    7.2. Docker build command:

    bash docker build ghcr.io/maastrichtu-ids/openpredict-api .

    7.3. Docker run command:

    Replace ${PERSISTENT_STORAGE} with the path to persistent storage on host:

    bash docker run -d -v ${PERSISTENT_STORAGE}:/data/openpredict -p 8808:8808 ghcr.io/maastrichtu-ids/openpredict-api

  8. Logs of the application

    9.2. Format of the logs: TODO

Acknowledgmentsโ€‹

Funded the the NIH NCATS Translator project

Owner

  • Name: Maastricht University IDS
  • Login: MaastrichtU-IDS
  • Kind: organization
  • Email: info-ids@maastrichtuniversity.nl
  • Location: Maastricht, Netherlands

Institute of Data Science at Maastricht University

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - email: r.celebi@maastrichtuniversity.nl
    given-names:  Remzi ร‡elebi
    affiliation: Institute of Data Science, Maastricht University
    orcid: https://orcid.org/0000-0001-7769-4272
  - given-names: Elif
    affiliation: Institute of Data Science, Maastricht University
    # email: elif@maastrichtuniversity.nl
    # orcid: https://orcid.org/0000-0000-0000-0000
  # - email: arif.yilmaz@maastrichtuniversity.nl
  #   given-names: Arif Yilmaz
  #   affiliation: Institute of Data Science, Maastricht University
    # orcid: https://orcid.org/0000-0000-0000-0000
title: "Translator OpenPredict"
repository-code: https://github.com/MaastrichtU-IDS/translator-openpredict
date-released: 2022-12-07
# url: https://pypi.org/project/openpredict
# doi: 10.48550/arXiv.2206.13787

GitHub Events

Total
  • Issues event: 1
  • Delete event: 1
  • Member event: 1
  • Issue comment event: 4
  • Push event: 6
  • Pull request event: 4
  • Fork event: 1
  • Create event: 2
Last Year
  • Issues event: 1
  • Delete event: 1
  • Member event: 1
  • Issue comment event: 4
  • Push event: 6
  • Pull request event: 4
  • Fork event: 1
  • Create event: 2

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 791
  • Total Committers: 8
  • Avg Commits per committer: 98.875
  • Development Distribution Score (DDS): 0.057
Top Committers
Name Email Commits
Vincent Emonet v****t@g****m 746
Remzi Celebi r****i@g****m 19
Pouyan Ahmadi p****i@g****u 8
elifozkn e****0@g****m 7
Arif Yilmaz a****l@g****m 4
Vincent Emonet v****t@p****m 3
Pouyan Ahmadi 7****0@u****m 3
Carlos Z 5****g@u****m 1
Committer Domains (Top 20 + Academic)
gmu.edu: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 34
  • Total pull requests: 29
  • Average time to close issues: 5 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 6
  • Total pull request authors: 7
  • Average comments per issue: 1.24
  • Average comments per pull request: 0.86
  • Merged pull requests: 15
  • Bot issues: 1
  • Bot pull requests: 10
Past Year
  • Issues: 3
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: about 23 hours
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 0.67
  • Average comments per pull request: 0.33
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • vemonet (19)
  • CaseyTa (8)
  • anas-elghafari (3)
  • cbizon (2)
  • capasfield (1)
  • github-actions[bot] (1)
Pull Request Authors
  • dependabot[bot] (13)
  • CaseyTa (7)
  • arifx (6)
  • elifozkn (3)
  • pahmadi8740 (3)
  • anas-elghafari (2)
  • vemonet (1)
Top Labels
Issue Labels
bug (15) api-query (10) enhancement (7) question (6) good first issue (2) embedding-request (2) translator (1)
Pull Request Labels
dependencies (13)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 19 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 8
  • Total maintainers: 1
pypi.org: openpredict

A package to help serve predictions of biomedical concepts associations as Translator Reasoner API.

  • Homepage: https://github.com/MaastrichtU-IDS/translator-openpredict
  • Documentation: https://github.com/MaastrichtU-IDS/translator-openpredict
  • License: MIT License Copyright (c) 2020 Vincent Emonet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 0.2.1
    published about 3 years ago
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 19 Last month
Rankings
Dependent packages count: 10.1%
Forks count: 13.3%
Stargazers count: 16.6%
Average: 17.6%
Dependent repos count: 21.6%
Downloads: 26.2%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/publish-docker.yml actions
  • actions/checkout v2 composite
  • docker/login-action v1 composite
.github/workflows/publish-package.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/scan-docker.yml actions
  • actions/checkout v2 composite
  • anchore/scan-action v2.0.2 composite
  • github/codeql-action/upload-sarif v1 composite
.github/workflows/test-integration.yml actions
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
  • actions/setup-python v4 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
  • iterative/setup-dvc v1 composite
  • vemonet/setup-spark v1 composite
  • warchant/setup-sonar-scanner v3 composite
.github/workflows/test-prod.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
Dockerfile docker
  • tiangolo/uvicorn-gunicorn-fastapi python3.8 build