Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating queries #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions queries/HippocampusVolumeAgeGender.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix fsl: <http://purl.org/nidash/fsl#>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix onli: <http://neurolog.unice.fr/ontoneurolog/v3.0/instrument.owl#>
prefix freesurfer: <https://surfer.nmr.mgh.harvard.edu/>
prefix dx: <http://ncitt.ncit.nih.gov/Diagnosis>
prefix ants: <http://stnava.github.io/ANTs/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ncicb: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ilx: <http://uri.interlex.org/> .

Expand All @@ -32,22 +26,20 @@ where {
OPTIONAL {?measure nidm:isAbout ?federatedLabel }.
OPTIONAL {?measure nidm:hasLaterality ?laterality }.
?as_activity prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .




# find age data element uuid
{?age_measure a nidm:PersonalDataElement ;
nidm:isAbout ilx:ilx_0100400 ;
nidm:sourceVariable "AGE_AT_SCAN" .
}
# find sex data element uuid
{?sex_measure a nidm:PersonalDataElement ;
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> .
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> . #Biological sex
}
?as_entity prov:wasGeneratedBy ?as_activity ;
?age_measure ?Age ;
?sex_measure ?GenderCoded .

bind(IF((?GenderCoded ="1" || ?GenderCoded ="Male"^^xsd:string), "Male"^^xsd:string,"Female"^^xsd:string) as ?Gender) .
FILTER (?federatedLabel = <http://purl.obolibrary.org/obo/UBERON_0001954>)
FILTER (?federatedLabel = <http://purl.obolibrary.org/obo/UBERON_0001954>) #Hippocampus
}
37 changes: 37 additions & 0 deletions queries/ID_sex_age.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix fs: <https://surfer.nmr.mgh.harvard.edu/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix ilx: <http://uri.interlex.org/>

select distinct ?ID ?Sex ?Age
where {

?tool_act a prov:Activity ;
prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?as_activity prov:qualifiedAssociation [prov:agent ?agent] ;
dct:isPartOf/dct:isPartOf [dctypes:title ?study] .
?agent ndar:src_subject_id ?ID .

# find sex data element uuid
{?sex_measure a nidm:PersonalDataElement ;
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> . #Biological sex
#nidm:isAbout <http://id.nlm.nih.gov/mesh/2018/M0446358> . #Genetic sex
}

# find age data element uuid
{?age_measure a nidm:PersonalDataElement ;
nidm:isAbout ilx:ilx_0100400 .
}

?as_entity prov:wasGeneratedBy ?as_activity ;
?sex_measure ?SexCoded ;
?age_measure ?Age.
bind(IF((?SexCoded ="M" || ?SexCoded ="Male"^^xsd:string), "Male"^^xsd:string,"Female"^^xsd:string) as ?Sex) .
#filter (?Sex = "Male"^^xsd:string) .
}
ORDER BY ?ID
81 changes: 81 additions & 0 deletions queries/Thickness.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
## The main issue was that the measures (for left, right, and mean) were coming from different stats collections
## (nidm:FSStatsCollection) associated with different activitities (prov:Acitivity). The previous code
## was assuming that the measurements were coming from the same collection and activity. I also fixed other
## minor issues for effeciency (e.g., removing unnecessary transitive subclass searches) and made the code
## simpler to follow. - Fahim

prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix fs: <https://surfer.nmr.mgh.harvard.edu/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix ilx: <http://uri.interlex.org/>

SELECT DISTINCT
?ID ?Sex ?Age
?measure_left_label ?measure_left_value
?measure_right_label ?measure_right_value
?measure_mean_label ?measure_mean_value

WHERE
{
# Gather the activity types for each type of measure associated with a given subject
?measure_left_activity prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?measure_right_activity prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?measure_mean_activity prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .

# Gather the stats collections (nidm:FSStatsCollection) generated by each acitivity type above,
# and allocate the variables for measurement types and values to be identified.
?left_stats_collection a nidm:FSStatsCollection;
prov:wasGeneratedBy ?measure_left_activity;
?measure_left ?measure_left_value.

?right_stats_collection a nidm:FSStatsCollection;
prov:wasGeneratedBy ?measure_right_activity;
?measure_right ?measure_right_value.

?left_stats_collection a nidm:FSStatsCollection;
prov:wasGeneratedBy ?measure_mean_activity;
?measure_mean ?measure_mean_value.

# Set the mesurement type identified based on the specific values for each data element
?measure_left a fs:DataElement;
rdfs:label ?measure_left_label;
fs:measure 'ThickAvg' ;
fs:structure 'superiortemporal' ;
nidm:hasLaterality 'Left'.

?measure_right a fs:DataElement;
rdfs:label ?measure_right_label;
fs:measure 'ThickAvg' ;
fs:structure 'superiortemporal' ;
nidm:hasLaterality 'Right'.

?measure_mean a fs:DataElement ;
rdfs:label ?measure_mean_label;
fs:measure 'MeanThickness' ;
fs:structure 'Cortex' .


?as_activity prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .

# find sex data element uuid
{?sex_measure a nidm:PersonalDataElement ;
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> . #Biological sex
#nidm:isAbout <http://id.nlm.nih.gov/mesh/2018/M0446358> . #Genetic sex
}

# find age data element uuid
{?age_measure a nidm:PersonalDataElement ;
nidm:isAbout ilx:ilx_0100400 .
}

?as_entity prov:wasGeneratedBy ?as_activity ;
?sex_measure ?SexCoded ;
?age_measure ?Age.
bind(IF((?SexCoded ="M" || ?SexCoded ="Male"^^xsd:string), "Male"^^xsd:string,"Female"^^xsd:string) as ?Sex) .
}
ORDER BY ?ID
60 changes: 60 additions & 0 deletions queries/Volumetrics.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix fs: <https://surfer.nmr.mgh.harvard.edu/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix ilx: <http://uri.interlex.org/>

select distinct ?ID ?Sex ?Age ?left_hipp_vol_softwareLabel ?left_hipp_vol
?right_hipp_vol_softwareLabel ?right_hipp_vol ?eICV_softwareLabel ?eICV
where {
# tool initialization
?tool_act a prov:Activity ;
prov:qualifiedAssociation [prov:agent [nidm:NIDM_0000164 ?tool]] .
?tool_act prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .

# Left Hippocampus Volume
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure_left_hipp_vol ?left_hipp_vol .
?measure_left_hipp_vol a/rdfs:subClassOf* nidm:DataElement ;
rdfs:label ?left_hipp_vol_softwareLabel;
fs:measure 'Volume_mm3';
fs:structure 'Left-Hippocampus'.
# Right Hippocampus Volume
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure_right_hipp_vol ?right_hipp_vol .
?measure_right_hipp_vol a/rdfs:subClassOf* nidm:DataElement ;
rdfs:label ?right_hipp_vol_softwareLabel;
fs:measure 'Volume_mm3';
fs:structure 'Right-Hippocampus'.
# estimated Intracarnial Volume
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure_eICV ?eICV .
?measure_eICV a/rdfs:subClassOf* nidm:DataElement ;
rdfs:label ?eICV_softwareLabel;
fs:measure 'eTIV';
fs:structure 'EstimatedTotalIntraCranialVol'.
?as_activity prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .

# find sex data element uuid
{?sex_measure a nidm:PersonalDataElement ;
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> . #Biological sex
#nidm:isAbout <http://id.nlm.nih.gov/mesh/2018/M0446358> . #Genetic sex
}

# find age data element uuid
{?age_measure a nidm:PersonalDataElement ;
nidm:isAbout ilx:ilx_0100400 .
}

?as_entity prov:wasGeneratedBy ?as_activity ;
?sex_measure ?SexCoded ;
?age_measure ?Age.
bind(IF((?SexCoded ="M" || ?SexCoded ="Male"^^xsd:string), "Male"^^xsd:string,"Female"^^xsd:string) as ?Sex) .
#filter (?Sex = "Male"^^xsd:string) .
}

ORDER BY ?ID
Comment on lines +59 to +60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ORDER BY ?ID
ORDER BY ?ID

29 changes: 29 additions & 0 deletions queries/all_brain_measures.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This query simply returns the brain measurements without dependencies on other
# demographics/assessment measures.

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select distinct ?ID ?tool ?softwareLabel ?federatedLabel ?laterality ?volume
where {
?tool_act a prov:Activity ;
prov:qualifiedAssociation [prov:agent [nidm:NIDM_0000164 ?tool]] .
?tool_act prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?tool_entity prov:wasGeneratedBy ?tool_act ;
?measure ?volume .

?measure a/rdfs:subClassOf* nidm:DataElement ;
rdfs:label ?softwareLabel;
nidm:measureOf <http://uri.interlex.org/base/ilx_0112559> ; #Volume
nidm:datumType <http://uri.interlex.org/base/ilx_0738276> . #Volume
#nidm:measureOf <http://uri.interlex.org/base/ilx_0111689> . #Thickness
#nidm:measureOf <http://purl.obolibrary.org/obo/PATO_0001323> . #Surface Area
OPTIONAL {?measure nidm:isAbout ?federatedLabel }.
OPTIONAL {?measure nidm:hasLaterality ?laterality }.
}
ORDER BY ?ID ?softwareLabel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be sufficient to become consistent across runs? may be add more into the mix here, e.g.

Suggested change
ORDER BY ?ID ?softwareLabel
ORDER BY ?ID ?softwareLabel ?tool @federatedLabel

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of adding a study name to differentiate the output and aid referencing sourced tools/data, is there such a label?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno... I just see above that you are selecting only select distinct ?ID ?tool ?softwareLabel ?federatedLabel ?laterality ?volume . IMHO better that to start with, get some samples from the "lake", and see then if things change when others to run the queries

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran it against the ReproLake_dev and it looks a bit cleaner with tools as the second ordering:

ORDER BY ?ID ?tool ?softwareLabel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so let's add those

8 changes: 3 additions & 5 deletions queries/dwi_count.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ prefix ncit: <http://ncitt.ncit.nih.gov/>

select distinct (count(?entity) as ?dwi_count)
where {




?entity prov:wasGeneratedBy ?activity ;
nidm:hadImageContrastType nidm:DiffusionWeighted .


}
43 changes: 14 additions & 29 deletions queries/female_subj_IDs.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,27 @@ prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix fsl: <http://purl.org/nidash/fsl#>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix onli: <http://neurolog.unice.fr/ontoneurolog/v3.0/instrument.owl#>
prefix freesurfer: <https://surfer.nmr.mgh.harvard.edu/>
prefix dx: <http://ncitt.ncit.nih.gov/Diagnosis>
prefix ants: <http://stnava.github.io/ANTs/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix ncicb: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
prefix ncit: <http://ncitt.ncit.nih.gov/>

select distinct ?ID ?Gender
where {


?tool_act a prov:Activity ;

prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .

?as_activity prov:qualifiedAssociation [prov:agent ?agent] ;
dct:isPartOf/dct:isPartOf [dctypes:title ?study] .
?agent ndar:src_subject_id ?ID .


# find sex data element uuid
{?sex_measure a nidm:PersonalDataElement ;
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> .
}


where {
?tool_act a prov:Activity ;
prov:qualifiedAssociation [prov:agent [ndar:src_subject_id ?ID]] .
?as_activity prov:qualifiedAssociation [prov:agent ?agent] ;
dct:isPartOf/dct:isPartOf [dctypes:title ?study] .
?agent ndar:src_subject_id ?ID .

# find sex data element uuid
{?sex_measure a nidm:PersonalDataElement ;
nidm:isAbout <http://uri.interlex.org/base/ilx_0101292> .
}

?as_entity prov:wasGeneratedBy ?as_activity ;

?sex_measure ?GenderCoded .
?sex_measure ?GenderCoded .


bind(IF((?GenderCoded ="1" || ?GenderCoded ="Male"^^xsd:string), "Male"^^xsd:string,"Female"^^xsd:string) as ?Gender) .
bind(IF((?GenderCoded ="1" || ?GenderCoded ="Male"^^xsd:string), "Male"^^xsd:string,"Female"^^xsd:string) as ?Gender) .
filter (?Gender = "Female"^^xsd:string) .

}
18 changes: 4 additions & 14 deletions queries/flowweighted_count.sparql
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix ndar: <https://ndar.nih.gov/api/datadictionary/v2/dataelement/>
prefix fsl: <http://purl.org/nidash/fsl#>
prefix nidm: <http://purl.org/nidash/nidm#>
prefix onli: <http://neurolog.unice.fr/ontoneurolog/v3.0/instrument.owl#>
prefix freesurfer: <https://surfer.nmr.mgh.harvard.edu/>
prefix dx: <http://ncitt.ncit.nih.gov/Diagnosis>
prefix ants: <http://stnava.github.io/ANTs/>
prefix dct: <http://purl.org/dc/terms/>
prefix dctypes: <http://purl.org/dc/dcmitype/>
prefix ncicb: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
prefix ncit: <http://ncitt.ncit.nih.gov/>

select distinct (count(?as_entity) as ?flowweighted_count)
where {


?as_activity prov:qualifiedAssociation [prov:agent ?agent] ;
where {
?as_activity prov:qualifiedAssociation [prov:agent ?agent] ;
dct:isPartOf/dct:isPartOf [dctypes:title ?study] .
?agent ndar:src_subject_id ?ID .


?as_entity prov:wasGeneratedBy ?as_activity ;
nidm:hadImageContrastType nidm:FlowWeighted ;
nidm:Task ?task .
nidm:hadImageContrastType nidm:FlowWeighted ;
nidm:Task ?task .
}
4 changes: 2 additions & 2 deletions queries/get_volumes.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ WHERE

?measure a measurement_datum:;
rdfs:label ?label;
isAbout: ?structure; #<http://purl.obolibrary.org/obo/UBERON_0001873>;
isAbout: ?structure; #<http://purl.obolibrary.org/obo/UBERON_0001873>; #caudate nucleus
hasMeasurementType: ilx:0112559;
hasUnit: "mm^3" ;
hasDatumType: ?datum_uri .

#FILTER (?structure = <http://purl.obolibrary.org/obo/UBERON_0001873>) .
#FILTER (?structure = <http://purl.obolibrary.org/obo/UBERON_0001873>) . #caudate nucleus
}
Loading