Skip to content

Instantly share code, notes, and snippets.

@drobbins
Forked from agrueneberg/query.sparql
Last active December 11, 2015 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drobbins/4625146 to your computer and use it in GitHub Desktop.
Save drobbins/4625146 to your computer and use it in GitHub Desktop.
A sample federated query using the TCGA Roadmap.

This is an example federated query using the TCGA Roadmap. You may run the query at any SPARQL endpoint with SERVICE queries enables, such as this one here.

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX tcga:<http://purl.org/tcga/core#>
PREFIX tcgameta:<http://purl.org/tcga/metadata#>
PREFIX tcgaclin:<http://purl.org/tcga/clin#>
PREFIX tcgaclinProp:<http://purl.org/tcga/clin#property/>
SELECT ?patientId ?tumorTissueSite ?ageAtInitialDiagnosis ?gender ?race ?vitalStatus
WHERE {
SERVICE <http://agalpha.mathbiol.org:10035/repositories/tcga> {
?file tcga:platform ?platform .
?platform rdfs:label "mda_rppa_core" .
?file tcga:diseaseStudy ?diseaseStudy .
?diseaseStudy rdfs:label "gbm" .
?file rdfs:label ?name .
FILTER contains(?name, "Level_3")
MINUS {
?file rdfs:label ?name .
filter contains(?name, "Control")
}
BIND(STRBEFORE(?name, ".txt") AS ?nameWithoutExtension)
BIND(STRAFTER(?nameWithoutExtension, "mdanderson.org_GBM.MDA_RPPA_Core.protein_expression.Level_3.") AS ?sampleId)
}
SERVICE <http://agalpha.mathbiol.org:10035/repositories/tcga-metadata> {
?sample rdfs:label ?sampleId .
?sample tcgameta:barcode ?barcode .
BIND(SUBSTR(?barcode, 1, 12) AS ?patientId)
}
SERVICE <http://agalpha.mathbiol.org:10035/repositories/tcga-patient> {
?patient tcgaclinProp:bcr_patient_barcode ?patientId .
?patient tcgaclinProp:tumor_tissue_site ?tumorTissueSite .
?patient tcgaclinProp:age_at_initial_pathologic_diagnosis ?ageAtInitialDiagnosis .
?patient tcgaclinProp:gender ?gender .
?patient tcgaclinProp:race ?race .
?patient tcgaclinProp:vital_status ?vitalStatus .
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment