Skip to content

Examples

amr4 edited this page Jun 28, 2016 · 4 revisions

See examples of API usage for:


Functional Gene Networks

Get network for a given tissue and gene

http://giant-api.princeton.edu/networks/osteoblast/LEF1

See tissues below for a list of valid tissues, and genes for a list of valid genes.

Get network for multiple genes

http://giant-api.princeton.edu/networks/brain/park2+park7

Optionally enumerate gene names for more compact graph representation:

http://giant-api.princeton.edu/networks/brain/park2+park7?enum=1

Get network for multiple genes (command line)

$ curl giant-api.princeton.edu/networks/brain/park2+park7
[
    {
        "source": "NDUFA1",
        "target": "NDUFA4",
        "weight": 0.8009668759023012
    },
    {
        "source": "NDUFA1",
        "target": "TBCA",
        "weight": 0.3142691606402427
    },
    {
        "source": "NDUFA1",
        "target": "UQCRH",
        "weight": 0.8241241833240858
    },
    ...
]

Same example using POST syntax and enumerated gene names:

$ curl giant-api.princeton.edu/networks -d tissue=brain      \
                                        -d genes=park2,park7 \
                                        -d enum=true
{
    "nodes": [
        {
            "name": "NDUFA1"
        },
        {
            "name": "NDUFA4"
        },
        {
            "name": "TBCA"
        },
        ...
    ],
    "edges": [
        {
            "source": 0,
            "target": 1,
            "weight": 0.8009668759023012
        },
        {
            "source": 0,
            "target": 2,
            "weight": 0.3142691606402427
        },
        {
            "source": 0,
            "target": 3,
            "weight": 0.8241241833240858
        },
        ...
    ]
}

Get network for multiple genes (modified graph options)

Predict functional relationships for BRCA1 and BRCA2 using the global network (i.e., not tissue specific) and also specify:

  1. number of genes to be returned in the JSON response
  2. prior probability of having a functional relationship between gene pairs
  3. enum option for more compact graph representation.
$ curl giant-api.princeton.edu/networks -d tissue=global     \
                                        -d genes=brca1,brca2 \
                                        -d num_genes=10      \
                                        -d prior=0.15        \
                                        -d enum=true
{
    "nodes": [
        {
            "name": "TP53BP1"
        },
        {
            "name": "ACACA"
        },
        {
            "name": "BRAP"
        },
        ...
    ],
    "edges": [
        {
            "source": 0,
            "target": 1,
            "weight": 0.24166657087771248
        },
        {
            "source": 0,
            "target": 2,
            "weight": 0.13069679725976338
        },
        {
            "source": 0,
            "target": 3,
            "weight": 0.24443552437697139
        },
        ...
    ]
}

Same example using the web API:

http://giant-api.princeton.edu/networks/global/BRCA1+BRCA2?num_genes=10&prior=0.15&enum=1


Network Visualization

D3


[ Demo | Gist ]

When enum=true is used, the structure of the JSON response returned by the API makes it easy to construct network graphs using the D3 visualization library. A sample graph using the force layout is given above, which makes predictions for the PARK2 gene in the brain tissue.

BioJS


[ Demo | GitHub | NPM ]

GIANT BioJS uses API calls to query gene network data, which is then plotted. This is similar to the preceding D3 example except additional controls are available in the BioJS module such as (i) filtering for the number of genes displayed, (ii) filtering for a minimum relationship confidence between gene pairs, and (iii) displaying datasets that most strongly support the predicted functional relationship.


NetWAS Analysis

Initialize a new NetWAS job

A sample input GWAS file aloof_vegas.txt can be downloaded here. Assuming aloof_vegas.txt is in the current working directory:

$ curl http://giant-api.princeton.edu/netwas/jobs \
       -F gwas_file="@aloof_vegas.txt"            \
       -F gwas_format="vegas"                     \
       -F tissue="api-demo"                       \
       -F p_value=0.01
{
    "id": "3a3ef256-1183-44bd-9337-538ab41c333a",
    "created": "2015-11-09T17:25:10.181923Z",
    ...
    "status": "not_started"
}

Start a NetWAS job

Referencing the same job created in the previous example with ID 3a3ef256-1183-44bd-9337-538ab41c333a:

$ curl -X POST http://giant-api.princeton.edu/netwas/jobs/3a3ef256-1183-44bd-9337-538ab41c333a/start
{
    "id": "3a3ef256-1183-44bd-9337-538ab41c333a",
    ...
    "log_file": null,
    "results_file": null,
    "status": "queued"
}

Check progress of a NetWAS job

Referencing the same job started in the previous example:

$ curl http://giant-api.princeton.edu/netwas/jobs/3a3ef256-1183-44bd-9337-538ab41c333a
{
    "id": "3a3ef256-1183-44bd-9337-538ab41c333a",
    ...
    "log_file": "http://giant-api.princeton.edu/media/results/.../log.txt",
    "results_file": null,
    "status": "running"
}

See results of a NetWAS job (web API)

Referencing the same job started in the previous example:

Job status http://giant-api.princeton.edu/netwas/jobs/3a3ef256-1183-44bd-9337-538ab41c333a
Log file http://giant-api.princeton.edu/media/.../log.txt
Results file http://giant-api.princeton.edu/media/.../results.txt

Helper Functions

Get list of supported tissues

http://giant-api.princeton.edu/tissues

Optionally request raw JSON response:

http://giant-api.princeton.edu/tissues?format=json

Get list of supported tissues (command line)

$ curl giant-api.princeton.edu/tissues?container=object
{
   "nervous_system": null,
   "cornea": null,
   "skin": null,
   "artery": null,
   "t_lymphocyte": null,
   ...
}

Same example using POST syntax and a modified print format:

$ curl giant-api.princeton.edu/tissues -d case=t
[
    "Adipose Tissue",
    "Adrenal Cortex",
    "Adrenal Gland",
    "Amygdala",
    "Aorta",
    ...
]

Validate a list of tissues

[http://giant-api.princeton.edu/tissues/check/LUng+cardiac mUSCle+hearTT?verbose=1](http://giant-api.princeton.edu/tissues/check/LUng+cardiac mUSCle+hearTT?verbose=1)

Validate a list of tissues (command line)

$ curl giant-api.princeton.edu/tissues/check -d tissue=liver,retiina,muscle
[
    "liver",
    null,
    "muscle"
]

Get list of genes in GIANT universe

$ curl giant-api.princeton.edu/genes
[
    "A1BG",
    "A1CF",
    "A2M",
    "A2ML1",
    "A3GALT2",
    ...
]

Validate a list of genes (web API)

http://giant-api.princeton.edu/genes/check/brca1+BRCA2+brca3

Validate a list of genes

$ curl giant-api.princeton.edu/genes/check -d gene=ABCD,C10ORF10,ba395l14.13 \
                                           -d verbose=1
[
    {
        "entrez_id": null,
        "query_name": "ABCD",
        "standard_name": null,
        "systematic_name": null,
        "valid": false
    },
    {
        "entrez_id": 11067,
        "query_name": "C10ORF10",
        "standard_name": "C10orf10",
        "systematic_name": "C10orf10",
        "valid": true
    },
    {
        "entrez_id": 284967,
        "query_name": "ba395l14.13",
        "standard_name": "bA395L14.13",
        "systematic_name": "bA395L14.13",
        "valid": true
    }
]