SPARQL end-point

GWAS Central provides access to a triple-store containing all nanopub resources (including all associated marker,  phenotype and result resources) through a SPARQL end-point.

The end-point is available at http://fuseki.gwascentral.org. The triple-store does not include all association data in GWAS Central, only the subset which are provided within nanopubs (all associations with a p-value ≤ 10-5) for Release 11 of the Study Database.

Example SPARQL queries of varying complexity are described at the bottom of the page.

 

The nanopub approach (see here for details) uses named graphs to provide context, so one or more graphs must be provided when querying the data using SPARQL.

Each nanopub represents its data in the context of four types of named graph specific to each data set. These types are described below.

 

The nanopub named graph

This named graph is a container for triples which point to the assertion, conditions and provenance named graphs described below.

SPARQL to get all triples in a single ‘nanopub’ named graph representing data set HGVRS17:

select *
from named <http://purl.org/gwas/nanopub/HGVRS17>
where {?s ?p ?o}

View results of query

 

The assertion named graph

This named graph is a container for triples which relate to the association results. An ‘as’ suffix is added to the nanopub URI to distinguish this from the nanopub named graph.

SPARQL to get all triples in an ‘assertion’ named graph representing data set HGVRS17:

select *
from named <http://purl.org/gwas/np/HGVRS17#as>
where { graph ?g {?s ?p ?o} }

View results from query

The conditions named graph

This named graph is a container for triples which relate to the conditions of the assertion, including the panels used and the organism. A ‘co’ suffix is added to the nanopub URI to distinguish this from the nanopub named graph.

SPARQL to get all triples in a ‘conditions’ named graph representing data set HGVRS17:

select *
from named <http://purl.org/gwas/np/HGVRS17#co>
where { graph ?g {?s ?p ?o} }

View results from query

The provenance named graph

This named graph is a container for triples which relate to the provenance of the assertion, including the contributors to the nanopub, linkouts to related publications and databases. A ‘co’ suffix is added to the nanopub URI to distinguish this from the nanopub named graph.

SPARQL to get all triples in a ‘provenance’ named graph representing data set HGVRS17:

select *
from named <http://purl.org/gwas/np/HGVRS17#pr>
where { graph ?g {?s ?p ?o} }

View results from query

Example SPARQL Queries

Construct an RDF graph of genes, their associated markers and GWAS Central phenotype resources when p-values ≤ 10-7, from nanopublications related to coronary artery disease:

PREFIX mesh: <http://bio2rdf.org/mesh:>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX gc:<http://purl.org/gwas/schema#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>

CONSTRUCT {
    ?phenotype rdf:type <http://example.com/CAD> ;
    <http://example.com/gene> ?gene;
    <http://example.com/annotation> ?annotation;
    <http://example.com/meshTerm> ?meshterm;
    <http://example.com/hpoTerm> ?hpoterm;
    <http://example.com/gene> ?gene.
    ?gene <http://example.com/marker> ?marker.
    ?marker <http://example.com/pvalue> ?pvalue.
}
WHERE
{
    GRAPH ?g
    {
        ?phenotype gc:meshAnnotation ?meshterm.
        optional {?phenotype gc:hpoAnnotation ?hpoterm}
        ?marker gc:associated ?phenotype ;
        gc:pvalue ?pvalue;
       gc:locatedInGene ?gene.
    }
    FILTER (xsd:float(?pvalue) <= 10e-7 && ?meshterm = mesh:D003324)
}

View results of query

Get all phenotype annotation terms and associated information from nanopublications where p-values ≤ 10-10:

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX gc:<http://purl.org/gwas/schema#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX obo:<http://www.obofoundry.org/ro/ro.owl#>
SELECT *
WHERE
{
    GRAPH ?g
    {
        ?phenotype gc:meshAnnotation ?meshterm .
        ?marker gc:associated ?phenotype ;
        gc:locatedInGene ?gene ;
        gc:pvalue ?pvalue;
       obo:hasSynonym ?ext_marker_id.
       optional {?phenotype gc:hpoAnnotation ?hpoterm }
    }
    FILTER (xsd:float(?pvalue) <= 1e-10)
}

View results from query

Get all triples in a specific nanopub:

prefix np150:<http://purl.org/gwas/np/HGVRS150#>
prefix npbase:<http://purl.org/gwas/np/>
select *
from named npbase:HGVRS150
from named np150:as from named np150:co
from named np150:pr where { graph ?g {?s ?p ?o} }

View results from query

 

Construct graph of all triples in a specific nanopub:

prefix np150:<http://purl.org/gwas/np/HGVRS150#>
prefix npbase:<http://purl.org/gwas/np/>
prefix marker:<http://purl.org/gwas/mkr/>
construct { ?s ?p ?o }
from named npbase:HGVRS150
from named np150:as
from named np150:co
from named np150:pr
where { graph ?g { ?s ?p ?o }  }

View results and graph from query (W3C validator tool)

 

Describe a particular marker and its associations

prefix owl:<http://www.w3.org/2002/07/owl#>
describe ?s
where {
graph ?g
 { ?s owl:sameAs ?o }
filter (?o = <http://www.ncbi.nlm.nih.gov/SNP/snp_ref.cgi?rs=rs3803662>)
}

View results from query