Changes for page 3 Try it yourself!

Last modified by maaike on 2022/07/06 10:08

From version 2.2
edited by maaike
on 2022/06/28 09:44
Change comment: There is no comment for this version
To version 8.2
edited by maaike
on 2022/07/05 20:33
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Try it yourself!
1 +3 Try it yourself!
Content
... ... @@ -6,29 +6,92 @@
6 6  1. Find datasets that contain NIfTI files
7 7  1. Find the software that can be used to open .smr file formats?
8 8  
9 -=== ===
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 10  
11 -==== Example 1 - How many datasets used human subjects? ====
11 +=== Example 1 - How many datasets used human subjects? ===
12 12  
13 -**Search UI**
13 +==== **Search UI** ====
14 14  
15 15  In the filter function, select "Homo Sapiens" under species. This filters the available datasets in the Knowledge Graph for human subjects only.
16 16  
17 -[[https:~~/~~/search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapiens>>https://search.kg.ebrains.eu/?facet_type[0]=Dataset&facet_Dataset_speciesFilter[0]=Homo%20sapiens]]
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 18  
19 -**Query Builder**
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 20  
21 +==== **Query Builder** ====
21 21  
22 -==== Example 2 - Find datasets with male adult subjects ====
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.
23 23  
24 -**Search UI**
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}}
25 25  
26 -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.
83 +=== Example 2 - Find datasets with male adult subjects ===
27 27  
28 -**Query Builder**
85 +==== **Search UI** ====
29 29  
30 -{{code language="python"}}
31 -query = {
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 +{
32 32   "@context": {
33 33   "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
34 34   "query": "https://schema.hbp.eu/myQuery/",
... ... @@ -102,9 +102,9 @@
102 102  }
103 103  {{/code}}
104 104  
105 -==== Example 3 - Find datasets that contain NIfTI files ====
168 +=== Example 3 - Find datasets that contain NIfTI files ===
106 106  
107 -**Search UI**
170 +==== **Search UI** ====
108 108  
109 109  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.
110 110  
... ... @@ -112,6 +112,192 @@
112 112  
113 113  [[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]]
114 114  
115 -**Query Builder**
178 +==== **Query Builder** ====
116 116  
117 -
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 +{{code language="json" layout="LINENUMBERS"}}
312 +{
313 + "@context": {
314 + "@vocab": "https://core.kg.ebrains.eu/vocab/query/",
315 + "query": "https://schema.hbp.eu/myQuery/",
316 + "propertyName": {
317 + "@id": "propertyName",
318 + "@type": "@id"
319 + },
320 + "path": {
321 + "@id": "path",
322 + "@type": "@id"
323 + }
324 + },
325 + "meta": {
326 + "type": "https://openminds.ebrains.eu/core/SoftwareVersion",
327 + "responseVocab": "https://schema.hbp.eu/myQuery/"
328 + },
329 + "structure": [
330 + {
331 + "propertyName": "query:id",
332 + "path": "@id"
333 + },
334 + {
335 + "propertyName": "query:shortName",
336 + "path": "https://openminds.ebrains.eu/vocab/shortName"
337 + },
338 + {
339 + "propertyName": "query:versionIdentifier",
340 + "path": "https://openminds.ebrains.eu/vocab/versionIdentifier"
341 + },
342 + {
343 + "propertyName": "query:inputFormat",
344 + "path": "https://openminds.ebrains.eu/vocab/inputFormat",
345 + "required": true,
346 + "structure": [
347 + {
348 + "propertyName": "query:name",
349 + "path": "https://openminds.ebrains.eu/vocab/name"
350 + },
351 + {
352 + "propertyName": "query:fileExtension",
353 + "path": "https://openminds.ebrains.eu/vocab/fileExtension",
354 + "required": true,
355 + "filter": {
356 + "op": "CONTAINS",
357 + "value": ".smr"
358 + }
359 + }
360 + ]
361 + }
362 + ]
363 +}
364 +{{/code}}
365 +
366 +
HumanData.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.maaike
Size
... ... @@ -1,0 +1,1 @@
1 +400.8 KB
Content
SoftwareSearch.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.maaike
Size
... ... @@ -1,0 +1,1 @@
1 +203.7 KB
Content