Cohorts

A cohort object is a record of type DatabaseQuery that is used to represent a subset of data from a database defined by filters and/or query. The DatabaseQuery record is mainly used to store cohorts of samples based on filters set by users in dashboards. The user needs to have access to the database referenced in the record's details to be able to explore data of the cohort.

DatabaseQuery record:

  • has type DatabaseQuery

  • has a reference to a dataset

  • has a reference to a dataset's schema

  • can be created through the visualization UI as a closed record

  • can store filters in details

  • has automatically generated SQL query based on filters stored in details as sql

  • has details in the following form

{
"dataset": "record-xxxx",
"dashboard": {
"file": {
"$dnanexus_link": "file-xxxx"
},
"name": "Dashboard Name"
},
"filters": {
"sex": {
"condition": "in",
"type": "categorical_single_origin",
"values": [0]
},
"age": {
"condition": "between",
"type": "integer",
"values": [45, 65]
},
"logic": "and"
},
"fields": {
"field_as_tiles": {
"dataQuery": {
"fields": {
"sex": "sample$sex",
"stat": "count",
"id": "sample$sex",
"options": {
"title": "Sex",
"type": "RowChart"
}
}
},
"dataQuery": {
"fields": {
"age": "sample$age",
"stat": "histogram",
"id": "sample$age",
"options": {
"title": "Age",
"type": "PlotHistogram"
}
}
}
}
},
"layouts": {
"field_as_tiles": {
"md": [{
"h": 1,
"i": "sample$sex",
"moved": false,
"static": false,
"w": 1,
"x": 0,
"y": 0
},
{
"h": 1,
"i": "sample$age",
"moved": false,
"static": false,
"w": 1,
"x": 1,
"y": 0
}]
}
},
"schema": "dataset-schema",
"sql": "SELECT DISTINCT sample.sample_id FROM database_xxxx__pheno.sample
JOIN database_yyyy__geno.genotype ON sample.sample_id = genotype.g_sample_id
WHERE sample.sex = 'F' AND sample.age BETWEEN 45 AND 65"
}