Commit 1b55ee36 authored by Vasundra Touré's avatar Vasundra Touré
Browse files

git added statistics queries

parent b1fe74b9
# Queries
A list of SPARQL queries to facilitate the exploration of data following the SPHN RDF schema.
\ No newline at end of file
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX sphn:<https://biomedit.ch/rdf/sphn-ontology/sphn#>
PREFIX resource:<https://biomedit.ch/rdf/sphn-resource/>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX psss:<https://biomedit.ch/rdf/sphn-ontology/psss#>
PREFIX spo:<https://biomedit.ch/rdf/sphn-ontology/spo#>
PREFIX frailty:<https://biomedit.ch/rdf/sphn-ontology/frailty#>
SELECT ?concept (COUNT(?resource) AS ?sphn_concepts_resources)
(count(distinct ?subject) as ?subject_cnt)
(count(distinct ?case) as ?case_cnt)
(count(distinct ?provider) as ?provider_cnt)
WHERE {
{ ?concept rdfs:subClassOf+ sphn:SPHNConcept } UNION { ?concept rdfs:subClassOf+ psss:SPHNConcept } UNION { ?concept rdfs:subClassOf+ spo:SPHNConcept } UNION { ?concept rdfs:subClassOf+ frailty:SPHNConcept } .
?resource a ?concept .
optional {?resource sphn:hasDataProviderInstitute ?provider}
optional {?resource sphn:hasSubjectPseudoIdentifier ?subject}
optional {?resource sphn:hasAdministrativeCase ?case}
FILTER NOT EXISTS {?concept rdfs:subClassOf sphn:ValueSet}
} group by ?concept order by desc(?sphn_concepts_resources)
#Counts the number of SPHN concepts
\ No newline at end of file
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX sphn:<https://biomedit.ch/rdf/sphn-ontology/sphn#>
PREFIX resource:<https://biomedit.ch/rdf/sphn-resource/>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX psss:<https://biomedit.ch/rdf/sphn-ontology/psss#>
PREFIX spo:<https://biomedit.ch/rdf/sphn-ontology/spo#>
PREFIX frailty:<https://biomedit.ch/rdf/sphn-ontology/frailty#>
SELECT ?concept ?attribute ?range (COUNT(distinct ?value) AS ?sphn_objects_count)
(MIN(?value) AS ?min_value) (MAX(?value) AS ?max_value) (AVG(?value) AS ?avg_value)
WHERE {
optional { ?attribute rdfs:range ?range }
{ ?concept rdfs:subClassOf+ sphn:SPHNConcept } UNION { ?concept rdfs:subClassOf+ psss:SPHNConcept } UNION { ?concept rdfs:subClassOf+ spo:SPHNConcept } UNION { ?concept rdfs:subClassOf+ frailty:SPHNConcept } .
{ ?attribute rdfs:subPropertyOf sphn:SPHNAttributeDatatype } UNION { ?attribute rdfs:subPropertyOf spo:SPHNAttributeDatatype } UNION { ?attribute rdfs:subPropertyOf psss:SPHNAttributeDatatype } .
?resource a ?concept .
?resource ?attribute ?value.
} group by ?concept ?attribute ?range
order by ?concept ?attribute ?range
#Shows all the data attributes used for every particular concept and how many objects are linked to, with their min, max...
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX sphn:<https://biomedit.ch/rdf/sphn-ontology/sphn#>
PREFIX resource:<https://biomedit.ch/rdf/sphn-resource/>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX psss:<https://biomedit.ch/rdf/sphn-ontology/psss#>
PREFIX spo:<https://biomedit.ch/rdf/sphn-ontology/spo#>
PREFIX frailty:<https://biomedit.ch/rdf/sphn-ontology/frailty#>
SELECT distinct (?concept as ?sphn_concepts_not_in_use)
WHERE {
{ ?concept rdfs:subClassOf+ sphn:SPHNConcept } UNION { ?concept rdfs:subClassOf+ psss:SPHNConcept } UNION { ?concept rdfs:subClassOf+ spo:SPHNConcept } UNION { ?concept rdfs:subClassOf+ frailty:SPHNConcept } .
filter not exists { ?resource a ?concept } .
}
#Lists all SPHN concepts that are not used in the given resource folder
\ No newline at end of file
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX sphn:<https://biomedit.ch/rdf/sphn-ontology/sphn#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
SELECT distinct ?non_sphn_concept
WHERE {
?_ a ?non_sphn_concept .
filter (?non_sphn_concept not in (rdfs:Datatype, owl:ObjectProperty, owl:DatatypeProperty, owl:NamedIndividual, owl:AnnotationProperty, sh:NodeShape, owl:Ontology, owl:Class))
filter not exists { ?non_sphn_concept rdfs:subClassOf+ sphn:SPHNConcept. }
}
#Expected: This lists all classes that are not part of SPHN ontology. Should be empty.
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX sphn:<https://biomedit.ch/rdf/sphn-ontology/sphn#>
PREFIX resource:<https://biomedit.ch/rdf/sphn-resource/>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX shacl:<http://www.w3.org/ns/shacl#>
PREFIX dct:<http://purl.org/dc/terms/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT distinct ?non_sphn_attribute
WHERE {
?subject ?non_sphn_attribute ?predicate .
filter (?non_sphn_attribute not in (dc:description, dc:title, dct:license, owl:sameAs, owl:versionIRI, owl:imports, owl:unionOf, owl:oneOf, owl:equivalentClass, rdf:type, rdf:first, rdf:rest, rdfs:label, rdfs:domain, rdfs:range, rdfs:comment, rdfs:isDefinedBy, rdfs:subClassOf, rdfs:subPropertyOf, shacl:closed, shacl:ignoredProperties, shacl:targetClass, shacl:property, shacl:pattern, shacl:path, shacl:nodeKind, shacl:minCount, shacl:maxCount, shacl:datatype, shacl:class, shacl:or, skos:note))
filter not exists { ?non_sphn_attribute rdfs:subPropertyOf+ sphn:SPHNAttributeDatatype . }
filter not exists { ?non_sphn_attribute rdfs:subPropertyOf+ sphn:SPHNAttributeObject . }
}
# Expected: This lists all properties (data + object) that are not part of SPHN ontology. Should be empty.
PREFIX sphn: <https://biomedit.ch/rdf/sphn-ontology/sphn#>
SELECT (count(distinct ?patient) as ?nbPatients)
WHERE { ?s sphn:hasSubjectPseudoIdentifier ?patient . }
\ No newline at end of file
PREFIX sphn: <https://biomedit.ch/rdf/sphn-ontology/sphn#>
SELECT (count(distinct ?provider) as ?nbProviders)
WHERE { ?s sphn:hasDataProviderInstitute ?provider . }
\ No newline at end of file
PREFIX sphn:<https://biomedit.ch/rdf/sphn-ontology/sphn#>
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT ?dataProvider ?dataProviderName (COUNT(?patient) AS ?nbOfPatients)
WHERE {
?patient a sphn:SubjectPseudoIdentifier .
?dataProvider a sphn:DataProviderInstitute .
?patient sphn:hasDataProviderInstitute ?dataProvider .
?dataProvider sphn:hasDataProviderInstituteCode/sphn:hasCodeName ?dataProviderName .
} GROUP BY ?dataProvider ?dataProviderName
#The number of patients for each data provider (hospital)
# Statistics queries
Some queries for generating statistics about data.
Note: a few queries takes into account some project specific ontologies (e.g. PSSS, SPO, SNFR).
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment