HCLSIG/PharmaOntology/Queries

From W3C Wiki

SPARQL Queries

Q1. How many patients experienced side effects while taking Donepezil?

(results)

PREFIX indivo: <http://indivo.org/vocab/xml/documents#>
PREFIX trans: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT(?patient) ?patient_name ?encounter_date ?symptoms ?diagnosis ?drug_name ?prescription_start
WHERE {
    GRAPH <pchr> {
        ?patient foaf:name ?patient_name .
        ?encounter trans:patient ?patient ;
            trans:reportedSymptoms ?symptoms ;
            trans:workingDiagnosis ?diagnosis ;
            trans:dateOfEncounter ?encounter_date .
        ?drug trans:prescribedTo ?patient ;
            indivo:prescribedOn ?prescription_start ;
            trans:datePrescriptionEnded ?prescription_end ;
            trans:genericName ?drug_name .
        FILTER regex(?drug_name, "DONEPEZIL", "i") .
        FILTER (?prescription_start <= ?encounter_date && ?prescription_end >= ?encounter_date) .
    }
}


Q2. What are the diagnostic criteria for AD?

(results)

define input:inference "infer"
PREFIX tmo: <http://www.w3.org/2001/sw/hcls/ns/transmed/>
PREFIX iao: <http://purl.obolibrary.org/obo/>
PREFIX ro: <http://www.obofoundry.org/ro/ro.owl#>

SELECT DISTINCT ?type_label ?criterion_label
WHERE {
    [] a ?type ;
        a ?stated_type ;
        rdfs:label ?criterion_label ;
        iao:is_about <http://www4.wiwiss.fu-berlin.de/diseasome/resource/diseases/74> .
    ?stated_type rdfs:label ?type_label .
    ?stated_type rdfs:subClassOf ?type .
    FILTER (?type = tmo:TMO_0068) .
}
ORDER BY DESC(?type_label) ASC(?criterion_label)


Q3. Is Donepezil covered by Medicare D?

(results)

define input:inference "infer"
PREFIX tmo: <http://www.w3.org/2001/sw/hcls/ns/transmed/>
PREFIX medicare: <http://www4.wiwiss.fu-berlin.de/medicare/resource/medicare/>

SELECT ?label
WHERE {
    GRAPH <medicare> {
        ?medicare_drug a tmo:TMO_0001 .
        ?medicare_drug rdfs:label ?label .
        FILTER regex(?label, "donepezil", "i") .
    }
}


Q4. Have any of my AD patients been treated for other neurological conditions as this might impact their diagnosis?

(results)

PREFIX indivo: <http://indivo.org/vocab/xml/documents#>
PREFIX trans: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT(?patient) ?patient_name
WHERE {
    GRAPH <pchr> {
        ?patient foaf:name ?patient_name .
        [ 
            trans:patient ?patient ;
            trans:reportedSymptoms ?symptoms ;
        ]
        FILTER regex(?symptoms, "depression", "i") .
        #ICD9 of 331 - alzheimer disease
        ?patient trans:hasCondition [ trans:ICD9 "331" ; ] .
    }
}


Q5. Are there other clinical trials that my patient may participate in for AD which have a different mechanism of action than the patient's current drug because it caused side effects?

A5.1. 569 clinical trials which involve AD are known. 181 trials are enrolling by invitation or recruiting patients. (results)

PREFIX linkedct: <http://data.linkedct.org/resource/linkedct/> 
PREFIX drugbank: <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/> 

SELECT ?trial_status, count(*) 
WHERE { 
    ?trial ?type linkedct:trials . 
    ?trial linkedct:overall_status ?trial_status . 
    ?trial linkedct:condition ?condition . 
    ?condition linkedct:condition_name ?condition_name .
    FILTER regex(?condition_name, "alzheimer", "i") .
}

A5.2. 72 active clinical trials involve AD. (results)

PREFIX linkedct: <http://data.linkedct.org/resource/linkedct/> 
PREFIX drugbank: <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/> 

SELECT count(*)
WHERE {
    ?trial ?type linkedct:trials . 
    ?trial linkedct:overall_status ?trial_status . 
    ?trial linkedct:condition ?condition . 
    ?condition linkedct:condition_name ?condition_name .
    FILTER regex(?trial_status, "active", "i") .
    FILTER regex(?condition_name, "alzheimer", "i") .
}

A5.3. 2 drugs targeting AD with established mechanism of action are in clinical trials. (results)

PREFIX linkedct: <http://data.linkedct.org/resource/linkedct/> 
PREFIX drugbank: <http://www4.wiwiss.fu-berlin.de/drugbank/resource/drugbank/> 

SELECT ?name ?moa
WHERE {
    ?trial ?type linkedct:trials . 
    ?trial linkedct:overall_status ?trial_status . 
    ?trial linkedct:condition ?condition . 
    ?condition linkedct:condition_name ?condition_name .
    ?trial linkedct:intervention ?ldrug .
    ?ldrug linkedct:intervention_name ?name .
    ?ddrug owl:sameAs ?ldrug .
    ?ddrug drugbank:mechanismOfAction ?moa .
    FILTER regex(?trial_status, "active", "i") .
    FILTER regex(?condition_name, "alzheimer", "i") .
}


Q6. Are there any AD patients without the APOE4 allele as these would be good candidates for the clinical trial involving Bapineuzumab?

(new results on data)

PREFIX trans: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf:  <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?name ?patient
WHERE {
  graph <pchr_new> {

    ?patient 
      foaf:name  ?name;
      trans:hasCondition [ 
        trans:diagnosedWith trans:alzheimers_disease 
      ]
    .

    FILTER ( 
      !bif:exists(( 

         SELECT ?result
         WHERE {
           ?encounter 
             trans:patient ?patient ;
             trans:test [ a ?test ;  
                          trans:result ?result ] .
           ?result
             trans:feature trans:variant_APOE4 ;
             trans:present true . 
         }
    )))
 }
}

(old results)

PREFIX trans: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf:  <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?name ?patient
WHERE {
   ?patient
      trans:hasCondition [
         trans:diagnosedWith trans:alzheimers_disease
      ];
      foaf:name ?name .
   OPTIONAL {
      ?encounter trans:test [
         a ?testname ;
         trans:result ?result
      ] .
      ?result
            trans:feature trans:variant_APOE4 ;
            trans:present true .
   }
   FILTER (!bound(?result)) .
}

Q7. What active trials are ongoing that would be a good fit for Patient 2?

(results)

PREFIX linkedct: <http://data.linkedct.org/resource/linkedct/>
PREFIX trans: <tag:eric@w3.org:2009/tmo/translator#>

SELECT DISTINCT(?trial) ?trial_condition_name ?trial_title 
WHERE {
    ?trial linkedct:brief_title ?trial_title .
    ?trial linkedct:overall_status ?status .
    FILTER regex(?status, "Active") .
    ?trial linkedct:condition ?trial_condition .
    ?trial_condition linkedct:condition_name ?trial_condition_name .
    FILTER (
        regex(?trial_condition_name, "alzheimer", "i") 
        || regex(?trial_condition_name, "anxiety", "i")
        || regex(?trial_condition_name, "hypercholesterolaemia", "i")
        || regex(?trial_condition_name, "depression", "i")
        || regex(?trial_condition_name, "mild cognitive impairement", "i")
        || regex(?trial_condition_name, "myocardial infarction", "i")
    ) .
}


Q8. Do I have suitable patients for an AD trial where they are looking for females who are aged over 55 years, have the APOE variant, and low ADAS COG scores?

(results)

PREFIX indivo: <http://indivo.org/vocab/xml/documents#>
PREFIX trans: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT(?patient_name) ?dob ?gender
WHERE {
    GRAPH <pchr> {
    ?patient foaf:name ?patient_name .
    ?patient trans:demographics ?demographics .
    # female
    ?demographics indivo:gender ?gender .
    FILTER ( ?gender = "Female" ) .
    # age > 55 ; would have been born in 1954
    ?demographics indivo:dateOfBirth ?dob .
    FILTER ( ?dob < "1954-01-01" )
    # apoe variant
    [] trans:patient ?patient ;
        trans:test [ trans:result [ trans:variant_Synonyms ?synonyms ] ] .
    FILTER regex(?synonyms, "APOE4") .
    # low ADAS COG score: Alzheimer's Disease Assessment Scale-cognitive subscale
    # trans:testName "Alzheimer's Disease Assessment Scale-cognitive subscale" ;
    #[] trans:patient ?patient ;
    #    trans:test [ trans:CPT "97532" ; trans:result [ ?p ?stuff] ] .
}


Q9. What genes are associated with or implicated in AD?

(results)

PREFIX diseasome: <http://www4.wiwiss.fu-berlin.de/diseasome/resource/diseasome/>
PREFIX pharmgkb: <http://bio2rdf.org/pharmgkb:>

SELECT DISTINCT(?gene_name)
WHERE {
    {
        GRAPH <diseasome> {
            ?disease rdfs:label ?disease_name .
            FILTER regex(?disease_name, "alzheimer", "i") .
            ?disease diseasome:associatedGene ?gene .
            ?gene rdfs:label ?gene_name .
        }
    } UNION { 
        GRAPH <pharmgkb> {
            ?association rdf:type pharmgkb:Association .
            ?association  pharmgkb:disease ?disease .
            ?disease rdfs:label ?disease_name .
            FILTER regex(?disease_name, "alzheimer", "i") .
            ?association pharmgkb:gene ?gene .
            ?gene dc:identifier ?gene_name .
        }
    }
}
ORDER BY ASC(?gene_name)


Q10. What biomarkers are associated with or implicated in AD?

(results)

PREFIX pharmgkb: <http://bio2rdf.org/pharmgkb:>

SELECT DISTINCT(?variant) ?gene_name ?description
WHERE {
    GRAPH <pharmgkb> {
        ?association a pharmgkb:DrugGeneVariantInteraction .
        ?association pharmgkb:description ?description .
        ?association pharmgkb:disease ?disease .
        ?association pharmgkb:variant ?variant .
        ?disease rdfs:label ?disease_name .
        FILTER regex(?disease_name, "alzheimer", "i") .
        ?association pharmgkb:gene ?gene .
        ?gene dc:identifier ?gene_name .
    }
}
ORDER BY ASC(?gene_name)


Q11. An APOE variant is strongly correlated with AD predisposition. Are there drug classes and drugs that target APOE?

(results)

PREFIX pharmgkb: <http://bio2rdf.org/pharmgkb:>

SELECT DISTINCT ?drug_name
WHERE {
    GRAPH <pharmgkb> {
        ?association rdf:type pharmgkb:DrugGeneVariantInteraction .
        ?association pharmgkb:description ?description .
        ?association pharmgkb:disease ?disease .
        ?association pharmgkb:variant ?variant .
        ?disease rdfs:label ?disease_name .
        FILTER regex(?disease_name, "alzheimer", "i") .
        ?association pharmgkb:gene ?gene .
        ?gene dc:identifier "APOE" .
        ?a2 a pharmgkb:Association .   
        ?a2 pharmgkb:gene ?gene .
        ?a2 pharmgkb:disease ?d2 . 
        ?d2 rdfs:label ?disease2_name .
        FILTER regex(?disease2_name, "alzheimer", "i") .
        ?a2 pharmgkb:drug ?drug .
        ?drug rdfs:label ?drug_name .
    }
}
ORDER BY ASC(?drug_name)


Q12. Which existing marketed drugs might potentially be re-purposed for AD because they are known to modulate genes that are implicated in the disease?

(results)

PREFIX pharmgkb: <http://bio2rdf.org/pharmgkb:>

SELECT DISTINCT ?drug_name ?disease2_name
WHERE {
    GRAPH <pharmgkb> {
        ?association rdf:type pharmgkb:DrugGeneVariantInteraction .
        ?association pharmgkb:description ?description .
        ?association pharmgkb:disease <http://bio2rdf.org/pharmgkb:1aa122e7b0687fa04b895ee82d6b6476> .
        ?association pharmgkb:variant ?variant .
        ?association pharmgkb:gene ?gene .
        ?gene dc:identifier ?gene_name .
        ?a2 a pharmgkb:Association .   
        ?a2 pharmgkb:gene ?gene .
        ?a2 pharmgkb:disease ?d2 . 
        ?d2 rdfs:label ?disease2_name .
        ?a2 pharmgkb:drug ?drug .
        ?drug rdfs:label ?drug_name .
    }
}
ORDER BY ASC(?drug_name) ASC(?disease2_name)


Patient Queries

Q13. What are the results of Georg Steffen Möller's lipid panel?

(results)

PREFIX tmo: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?date ?value ?units ?referrer ?referred_to ?clinic
WHERE {
    ?patient foaf:name "Georg Steffen Möller" .
    ?encounter tmo:patient ?patient ;
        tmo:dateOfEncounter ?date ;
        tmo:test ?referral .
    ?referral tmo:physicianNotes ?notes ;
        tmo:testType tmo:Laboratory ;
        tmo:testName "Lipid panel" ;
        tmo:CPT ?cpt ;
        tmo:referredTo ?referred_to ;
        tmo:referredClinic ?clinic ;
        tmo:referredBy ?referrer ;
        tmo:testSet ?panel .
    ?panel a tmo:LipidPanel ;
        tmo:testCode ?code .
    ?code tmo:description "Low-density lipoprotein" ;
        tmo:value ?value ;
        tmo:units ?units .
}


Q14. What is Monica Mary Mall's platelet count over time?

(results)

PREFIX tmo: <tag:eric@w3.org:2009/tmo/translator#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?date ?value ?units 
WHERE {
    ?encounter tmo:patient [ foaf:name "Monica Mary Mall" ] ;
        tmo:dateOfEncounter ?date ;
        tmo:test [
            tmo:testSet [
                tmo:testCode [
                    tmo:description "Platelet Count" ;
                    tmo:value ?value ;
                    tmo:units ?units
                ]
            ]
        ]
}
ORDER BY DESC(?date)