Wiki source code of 3 Try it yourself!

Version 9.1 by maaike on 2022/07/05 20:37

Show last authors
1 == User examples ==
2
3
4 1. How many datasets used human subjects?
5 1. Find datasets with male adult subjects
6 1. Find datasets that contain NIfTI files
7 1. Find the software that can be used to open .smr file formats?
8
9 [[Log in to your EBRAINS account and try running the examples yourself!>>https://lab.ch.ebrains.eu/hub/user-redirect/lab/tree/shared/Practical%20Guide%20to%20Using%20the%20EBRAINS%20Knowledge%20Graph%20in%20(your)%20Research%20-%20User%20Examples/query.ipynb]]
10
11 === Example 1 - How many datasets used human subjects? ===
12
13 ==== **Search UI** ====
14
15 In the filter function, select "Homo Sapiens" under species. This filters the available datasets in the Knowledge Graph for human subjects only.
16
17 [[[[image:HumanData.png]]>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapien&category=Dataset&species[0]=Homo%20sapiens]]
18
19 [[https:~~/~~/search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapien&category=Dataset&species[0]=Homo%20sapiens>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapien&category=Dataset&species[0]=Homo%20sapiens]]
20
21 ==== **Query Builder** ====
22
23 To search for datasets containing human subjects only, you can first declare the id (to get the involved instances) as well as a link to the "studied specimen" (you can add a type filter and restrict it to "Subject" and "Subject group" only since we are not interested in "Tissue samples" and "Tissue sample collections" in this moment). From "studied specimen", we're interested in the "Species" (here you can - again add a type filter to exclude "Strain" since this is irrelevant for human subjects). For the "Species", we want the "label" to contain "homo sapiens" which is why we add a filter "contains" with the value "homo sapiens".  We might want to simplify the deeply nested structure by "flattening" both, the "Studied specimen" as well as the "Species". Once we go to the "execute query" section (the play button on the left) and we run the query, we can see the total number of dataset versions.
24 \\Please note that this number can differ from the one you figured out in the search UI. The reason for this is, that the search UI does only count the newest dataset version whilst the query also returns older dataset versions.
25
26 {{code language="json" layout="LINENUMBERS"}}
27 {
28 "@context": {
29 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
30 "query": "https://schema.hbp.eu/myQuery/",
31 "propertyName": {
32 "@id": "propertyName",
33 "@type": "@id"
34 },
35 "path": {
36 "@id": "path",
37 "@type": "@id"
38 }
39 },
40 "meta": {
41 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
42 "responseVocab": "https://schema.hbp.eu/myQuery/"
43 },
44 "structure": [
45 {
46 "propertyName": "query:id",
47 "path": "@id"
48 },
49 {
50 "propertyName": "query:studiedSpecimen",
51 "required": true,
52 "filter": {
53 "op": "CONTAINS",
54 "value": "Homo sapiens"
55 },
56 "path": [
57 {
58 "@id": "https://openminds.ebrains.eu/vocab/studiedSpecimen",
59 "typeFilter": [
60 {
61 "@id": "https://openminds.ebrains.eu/core/Subject"
62 },
63 {
64 "@id": "https://openminds.ebrains.eu/core/SubjectGroup"
65 }
66 ]
67 },
68 {
69 "@id": "https://openminds.ebrains.eu/vocab/species",
70 "typeFilter": [
71 {
72 "@id": "https://openminds.ebrains.eu/controlledTerms/Species"
73 }
74 ]
75 },
76 "https://openminds.ebrains.eu/vocab/name"
77 ]
78 }
79 ]
80 }
81 {{/code}}
82
83 === Example 2 - Find datasets with male adult subjects ===
84
85 ==== **Search UI** ====
86
87 All the metadata in the knowledge graph is represented by nodes and their relationships by the edges. Most of the "basic" metadata is visualised in the Search UI to make it easy for the user to find datasets that fit certain criteria without needing to know how to navigate and traverse a graph structure. When searching for "male adult" subjects in the search UI, we find datasets that have these keywords in any of the text summarised on the dataset card (it is a 'fuzzy search' : [[https:~~/~~/search.kg.ebrains.eu/?category=Dataset&q=male%20and%20adult>>https://search.kg.ebrains.eu/?category=Dataset&q=male%20and%20adult]]). To ensure we only look for the any specimen (subjects or samples) originating from male adult mice, we need to write a query and extract the metadata programmatically.
88
89 ==== **Query Builder** ====
90
91 For dataset versions that use male adult subjects, we can filter datasets using these 2 properties. The easiest way is to add a required filter to biological sex that is "EQUAL" to "male" and the age category "EQUAL" to "adult". By selecting the filter "EQUAL" instead of "CONTAINS", we ensure that only datasets with adult animals are found. If we want to be more general and include all subjects from the onset of sexual maturity, we can use "CONTAINS" instead as this will include subjects with the age category "prime adult", "young adult" and "late adult" as well.
92
93 {{code language="json" layout="LINENUMBERS"}}
94 {
95 "@context": {
96 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
97 "query": "https://schema.hbp.eu/myQuery/",
98 "propertyName": {
99 "@id": "propertyName",
100 "@type": "@id"
101 },
102 "path": {
103 "@id": "path",
104 "@type": "@id"
105 }
106 },
107 "meta": {
108 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
109 "responseVocab": "https://schema.hbp.eu/myQuery/"
110 },
111 "structure": [
112 {
113 "propertyName": "query:id",
114 "path": "@id"
115 },
116 {
117 "propertyName": "query:shortName",
118 "path": "https://openminds.ebrains.eu/vocab/shortName"
119 },
120 {
121 "propertyName": "query:studiedSpecimen",
122 "path": "https://openminds.ebrains.eu/vocab/studiedSpecimen",
123 "required": true,
124 "structure": [
125 {
126 "propertyName": "query:id",
127 "path": "@id"
128 },
129 {
130 "propertyName": "query:biologicalSex",
131 "path": "https://openminds.ebrains.eu/vocab/biologicalSex",
132 "required": true,
133 "structure": {
134 "propertyName": "query:name",
135 "path": "https://openminds.ebrains.eu/vocab/name",
136 "required": true,
137 "filter": {
138 "op": "EQUALS",
139 "value": "male"
140 }
141 }
142 },
143 {
144 "propertyName": "query:studiedState",
145 "path": "https://openminds.ebrains.eu/vocab/studiedState",
146 "required": true,
147 "structure": {
148 "propertyName": "query:ageCategory",
149 "path": "https://openminds.ebrains.eu/vocab/ageCategory",
150 "required": true,
151 "structure": {
152 "propertyName": "query:name",
153 "path": "https://openminds.ebrains.eu/vocab/name",
154 "required": true,
155 "filter": {
156 "op": "EQUALS",
157 "value": "adult"
158 }
159 }
160 }
161 }
162 ]
163 }
164 ]
165 }
166 {{/code}}
167
168 === Example 3 - Find datasets that contain NIfTI files ===
169
170 ==== **Search UI** ====
171
172 Files are organised based on their file format (i.e. file extension) and the software that could be used to open these files. In openMINDS this is captured with the content type. In the filter function, select "application/vnd.nifti.1" under content types to select all the dataset with a NIfTI 1 file format.
173
174 [[[[image:ContentTypes.png]]>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_contentTypes[0]=application%2Fvnd.nifti.1]]
175
176 [[https:~~/~~/search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_contentTypes[0]=application%2Fvnd.nifti.1>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_contentTypes[0]=application%2Fvnd.nifti.1]]
177
178 ==== **Query Builder** ====
179
180 To find datasets with a particular file format in it, we can either write a query for 1) the file extension or 2) based on the content type. The difference between the two approaches is that the first approach just looks at the file extension without considering the what type of file format it is and what software can be used to open it. For example, both nifti 1 and nifti 2 files have the same extension. The nifti 2 format is an update of nifti 1 and will not be recognised as a valid nifti 1 format. This is important when considering what program to use when opening the files. To be able to differentiate, we describe the files with content types that tell the user what type of file format it is and we have linked a number of software applications to that content type to facilitate reuse of the data.
181
182 **Query datasets based on file extension**
183
184 We can restrict the search results with a filter using a required field. In this particular case a filter that "ENDS_WITH" a value (e.g. .nii.gz) could be used. We can use .nii for normal nifti files or .nii.gz for compressed nifty files.
185
186 {{code language="json" layout="LINENUMBERS"}}
187 {
188 "@context": {
189 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
190 "query": "https://schema.hbp.eu/myQuery/",
191 "propertyName": {
192 "@id": "propertyName",
193 "@type": "@id"
194 },
195 "path": {
196 "@id": "path",
197 "@type": "@id"
198 }
199 },
200 "meta": {
201 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
202 "responseVocab": "https://schema.hbp.eu/myQuery/"
203 },
204 "structure": [
205 {
206 "propertyName": "query:shortName",
207 "path": "https://openminds.ebrains.eu/vocab/shortName"
208 },
209 {
210 "propertyName": "query:id",
211 "path": "@id"
212 },
213 {
214 "propertyName": "query:repository",
215 "path": "https://openminds.ebrains.eu/vocab/repository",
216 "required": true,
217 "structure": {
218 "propertyName": "query:fileRepository",
219 "path": {
220 "@id": "https://openminds.ebrains.eu/vocab/fileRepository",
221 "reverse": true
222 },
223 "required": true,
224 "structure": {
225 "propertyName": "query:name",
226 "path": "https://openminds.ebrains.eu/vocab/name",
227 "required": true,
228 "filter": {
229 "op": "ENDS_WITH",
230 "value": ".nii.gz"
231 }
232 }
233 }
234 }
235 ]
236 }
237 {{/code}}
238
239 **Query datasets based on content type**
240
241 To find datasets using the content type structure, we can use a filter that "CONTAINS" a value (e.g. nifti). We are now not distinguishing between nifti 1 or nifti 2 files, but select all files that are classified as "nifti". If you want to narrow down the results further, you could replace "nifti" by "nifti.1" or "nifti.2".
242
243 {{code language="json" layout="LINENUMBERS"}}
244 {
245 "@context": {
246 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
247 "query": "https://schema.hbp.eu/myQuery/",
248 "propertyName": {
249 "@id": "propertyName",
250 "@type": "@id"
251 },
252 "path": {
253 "@id": "path",
254 "@type": "@id"
255 }
256 },
257 "meta": {
258 "type": "https://openminds.ebrains.eu/core/DatasetVersion",
259 "responseVocab": "https://schema.hbp.eu/myQuery/"
260 },
261 "structure": [
262 {
263 "propertyName": "query:shortName",
264 "path": "https://openminds.ebrains.eu/vocab/shortName"
265 },
266 {
267 "propertyName": "query:id",
268 "path": "@id"
269 },
270 {
271 "propertyName": "query:repository",
272 "path": "https://openminds.ebrains.eu/vocab/repository",
273 "required": true,
274 "structure": {
275 "propertyName": "query:contentTypePattern",
276 "path": "https://openminds.ebrains.eu/vocab/contentTypePattern",
277 "required": true,
278 "structure": {
279 "propertyName": "query:contentType",
280 "path": "https://openminds.ebrains.eu/vocab/contentType",
281 "required": true,
282 "structure": {
283 "propertyName": "query:name",
284 "path": "https://openminds.ebrains.eu/vocab/name",
285 "required": true,
286 "filter": {
287 "op": "CONTAINS",
288 "value": "nifti"
289 }
290 }
291 }
292 }
293 }
294 ]
295 }
296 {{/code}}
297
298 === (% id="cke_bm_3314S" style="display:none" %) (%%)Example 4 - Find the software that can be used to open .smr file formats? ===
299
300 ==== **Search UI** ====
301
302 To find software that can open a particular file format like the Spike2 file format (.smr), we can select the category "software" and then filter based on "input format". We select "application/vnd.spike2.sonpy.son" to ensure we only get software for this file format.
303
304 [[[[image:SoftwareSearch.png||alt="Software Search"]]>>https://search.kg.ebrains.eu/?category=Software&inputFormats[0]=application%2Fvnd.spike2.sonpy.so]]
305
306 [[https:~~/~~/search.kg.ebrains.eu/?category=Software&inputFormats[0]=application%2Fvnd.spike2.sonpy.son>>https://search.kg.ebrains.eu/?category=Software&inputFormats[0]=application%2Fvnd.spike2.sonpy.son]]
307
308
309 ==== **Query Builder** ====
310
311 For this question, we will execute the query against the "softwareVersion data structure. We ask for the name, version and input type of the software. We further refine our query by restricting the result to software that can open files with the file extension ".smr". We get the same 3 software types as in the search, and we immediately see that one of the software types has multiple versions that can open this kind of files.
312
313 {{code language="json" layout="LINENUMBERS"}}
314 {
315 "@context": {
316 "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
317 "query": "https://schema.hbp.eu/myQuery/",
318 "propertyName": {
319 "@id": "propertyName",
320 "@type": "@id"
321 },
322 "path": {
323 "@id": "path",
324 "@type": "@id"
325 }
326 },
327 "meta": {
328 "type": "https://openminds.ebrains.eu/core/SoftwareVersion",
329 "responseVocab": "https://schema.hbp.eu/myQuery/"
330 },
331 "structure": [
332 {
333 "propertyName": "query:id",
334 "path": "@id"
335 },
336 {
337 "propertyName": "query:shortName",
338 "path": "https://openminds.ebrains.eu/vocab/shortName"
339 },
340 {
341 "propertyName": "query:versionIdentifier",
342 "path": "https://openminds.ebrains.eu/vocab/versionIdentifier"
343 },
344 {
345 "propertyName": "query:inputFormat",
346 "path": "https://openminds.ebrains.eu/vocab/inputFormat",
347 "required": true,
348 "structure": [
349 {
350 "propertyName": "query:name",
351 "path": "https://openminds.ebrains.eu/vocab/name"
352 },
353 {
354 "propertyName": "query:fileExtension",
355 "path": "https://openminds.ebrains.eu/vocab/fileExtension",
356 "required": true,
357 "filter": {
358 "op": "CONTAINS",
359 "value": ".smr"
360 }
361 }
362 ]
363 }
364 ]
365 }
366 {{/code}}
367
368
369