Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

DSuveges/OTAR_response_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

As the REST API of OpenTargets has been retired, this repository is no longer maintained.

OTAR parser

Codacy Badge Build Status Codacy Badge

This module is an extension of the Python client for the Open Targets REST API that parses the result object. The module has a simple command line interface to demonstrate its functionality by displaying summaries of the overall association scores extracted from the returned response object.

Requirements

  • Python 3.6+
  • Opentargets REST API wrapper v3.1.16 (see installation instruction here)
  • Pandas

Installation using pip

Once the desired Python 3 virtual environment is activated, the parser and its dependencies can be directly installed from github using pip:

pip install git+https://github.com/DSuveges/OTAR_response_parser

Usage

This is a Python module that takes opentargets.conn.IterableResult object as an input, but for demonstrative purposes, it is shipped with a simple command line interface as well. If the module is installed via pip, this command line tool gets also installed and added to the path.

The command line interface

Display command line help message:

OTAR_result_parser -h

Expected output:

usage: OTAR_result_parser [-h] [-t TARGET] [-d DISEASE] [-v]

A small command line tool to demonstrate the capabilities of the Opentargets
parser module. At this stage it shows statistics of the association scores in
a result set of a target or disease specific query.

optional arguments:
  -h, --help            show this help message and exit
  -t TARGET, --target TARGET
                        Specify target ID. eg. ENSG00000197386.
  -d DISEASE, --disease DISEASE
                        Specify disease ID. eg. Orphanet_399
  -v, --verbose         Prints out extra information

Parsing result object for a target query:

OTAR_result_parser -t ENSG00000197386

Expected output:

[Info] ENSG00000197386 as target ID returned the following associations:
Assoc #0 - Target ID: ENSG00000197386, disease ID: EFO_0000618, association score: 1.0
Assoc #1 - Target ID: ENSG00000197386, disease ID: Orphanet_71859, association score: 1.0
...
Assoc #791 - Target ID: ENSG00000197386, disease ID: EFO_0003758, association score: 0.004
Assoc #792 - Target ID: ENSG00000197386, disease ID: EFO_0003756, association score: 0.004

[Info] Association score stats for the target based query for ENSG00000197386:
    The maximum of the association_score.overall values: 1.0
    The minimum of the association_score.overall values: 0.004
    The average of the association_score.overall values: 0.2269340041521952
    The standard error of the association_score.overall values: 0.1754745344039146

Parsing result object for a disease query:

OTAR_result_parser -d Orphanet_399

Expected output:

[Info] Orphanet_399 as disease ID returned the following associations:
Assoc #0 - Target ID: ENSG00000165646, disease ID: Orphanet_399, association score: 1.0
Assoc #1 - Target ID: ENSG00000198785, disease ID: Orphanet_399, association score: 1.0
...
Assoc #798 - Target ID: ENSG00000101966, disease ID: Orphanet_399, association score: 0.004
Assoc #799 - Target ID: ENSG00000006128, disease ID: Orphanet_399, association score: 0.004

[Info] Association score stats for the disease based query for Orphanet_399:
    The maximum of the association_score.overall values: 1.0
    The minimum of the association_score.overall values: 0.004
    The average of the association_score.overall values: 0.08275577839514175
    The standard error of the association_score.overall values: 0.1508110393500087

If both target and disease query is requested at the same time, at first the disease/trait table is printed out for the target and disease based search; then the association score statistics for the target and disease based query.

Application interface

from opentargets import OpenTargetsClient
from OTAR_result_parser.OTAR_result_parser import OTAR_result_parser

# Get association for a gene for example:
geneID = 'ENSG00000197386'

# Fetch data from OpenTargets:
client = OpenTargetsClient()
otar_results = client.filter_associations()
x = otar_results.filter(target=geneID)

# Initialize parser object:
OT_parser = OTAR_result_parser(x, verbose=True)

Get the average of the overall association scores:

OT_parser.get_association_score_mean()

Get the lowest overall association score:

OT_parser.get_association_score_min()

Get the highest overall association score:

OT_parser.get_association_score_max()

Get the standard deviation of the overall association scores:

OT_parser.get_association_score_std()

Get the number of associations in the returned dataset:

len(OT_parser)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages