Skip to content

Commit b2362a2

Browse files
committed
Update aggregations.md
1 parent f80eba1 commit b2362a2

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

docs/aggregations.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,81 @@ description: >-
196196
property: biosample.sample_origin_detail.id
197197
```
198198
199+
Aggregation concepts can have additional modifiers:
200+
201+
* `filters` - to limit the aggregation to a subset of the data, e.g. to a selection of disease codes
202+
- the usual filter definitions apply; _i.e._ if an ontology term is used as filter value the count will include all records with this term or any of its child terms (unless the filter's `includeDescendantTerms` flag is set to `False`)
203+
* `splits` - to partition continuous data such as age values, followup times or other numeric measurements into countable bins
204+
- Note: `splits` are upper & exclusive boundaries of bins, following established practices (_cf._ `$split` use in [MongoDB aggregation pipelines](https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/))
205+
206+
* a `sorted` flag, to indicate that the aggregation results are returned in a
207+
pre-sorted order with some inherent meaning (e.g. age bins)
208+
* a `format` property to indicate the format of the values, e.g. for age splits provided in ISO8601 duration format
209+
210+
#### `filters` Example
211+
212+
```yaml
213+
selectedDiseases:
214+
id: selectedDiseases
215+
label: Selected Diagnostic Classes (by NCIT)
216+
property: individual.diseases.disease_code.id
217+
filters:
218+
- id: NCIT:C2919
219+
label: Prostate Adenocarcinoma
220+
- id: NCIT:C4017
221+
label: Breast Ductal Carcinoma
222+
- id: NCIT:C3512
223+
label: Lung Adenocarcinoma
224+
```
225+
226+
#### `splits` Example
227+
228+
```yaml
229+
ageAtSampleCollection:
230+
id: ageAtSampleCollection
231+
label: Age at sample collection
232+
description: >-
233+
Age at diagnosis (sample collection...)
234+
property: biosample.collection_moment
235+
format: iso8601duration
236+
splits:
237+
- value: P18Y
238+
label: < 18 years
239+
- value: P65Y
240+
label: < 65 years
241+
- value: P120Y
242+
label: 65+ years
243+
sorted: True
244+
```
245+
246+
## Requesting Aggregations
247+
248+
To request specific aggregations, clients can use the `aggregators` query parameter which itself is an array of arrays of concepts.
249+
250+
=== "POST Request Example"
251+
252+
```json
253+
"aggregators": [
254+
[
255+
{"id": "sampleOriginDetails"}
256+
],
257+
[
258+
{"id": "selectedDiseases"},
259+
{"id": "sexAtBirth"}
260+
]
261+
]
262+
```
263+
264+
=== "GET Request Example"
265+
266+
The **non normative** `GET` example uses a standard comma concatenation for
267+
the outer `aggregators` list and a double colon `::` to separate `id` values
268+
of intersecting concepts.
269+
270+
```
271+
?aggregators=sampleOriginDetails,selectedDiseases::sexAtBirth
272+
```
273+
199274

200275

201276

0 commit comments

Comments
 (0)