Premium Feature — This feature is available in the Professional, Professional Plus, and Enterprise Editions.
Learn more or
contact LabKey.
Vocabulary properties can be used to attach metadata to data in LabKey Server. Example use cases:
- Attaching provenance information to assay data, such as "Instrument type" or "Original data source".
- Attaching provenance information to sample data such as "Clinic of origin", etc.
- Attaching any information that is not already part of the result data or samples.
Vocabulary properties can be attached to the following data objects in LabKey Server:
- Individual rows in a Sample Set
- Individual rows in the exp.Data schema (for example, Files and DataClass rows)
- Assay Runs
Vocabulary properties are defined and stored in a Vocabulary Domain.
The following examples show how to create a Vocabulary Domain and attached its properties to assay/sample data.
Create Vocabulary Domains
Reference Documentation:
Creating a vocabulary domain:
LABKEY.Domain.create({
kind: "Vocabulary",
domainDesign: {
name: "MyVocab",
fields: [{
name: "pH", rangeURI: "int"
},{
name: "instrument",
rangeURI: "int",
lookupSchema: "lists",
lookupQuery: "Instruments"
}]
}
});
Listing vocabulary domains (to find the property URI of one of the fields):
LABKEY.Domain.listDomains({
domainKinds: [ "Vocabulary" ],
includeProjectAndShared: false,
includeFields: true
});
Selecting a property and all properties attached to the row:
LABKEY.Query.selectRows({
schemaName: "samples",
queryName: "Samples",
columns: ["name", "urn:lsid:labkey.com:Vocabulary.Folder-3234:MyVocab2#pH", "Properties"]
})
Attaching Vocabulary Properties to Data
Reference Documentation:
Inserting a samples with vocabulary properties:
LABKEY.Query.insertRows({
schemaName: "samples",
queryName: "Samples",
rows: [{
Name: "testing",
"urn:lsid:labkey.com:Vocabulary.Folder-3234:MyVocab2#pH": 7.2
}]
});
Updating a property values:
LABKEY.Query.updateRows({
schemaName: "samples",
queryName: "test",
rows: [{
rowId: 319524,
"urn:lsid:labkey.com:Vocabulary.Folder-3234:MyVocab2#pH": 7.6
}]
});
Using saveRuns to create a new assay run run with properties:
LABKEY.Experiment.saveRuns({
assayId: 8753,
runs: [{
name: 'testing',
properties: {
'urn:lsid:labkey.com:Vocabulary.Folder-3234:ProcessParameters#flowRate': 3.2
},
materialOutputs: [{
id: 1092216
},{
// a new sample will be created when the run is saved
name: 'S-123',
sampleSet: {
name: 'Samples'
},
properties: {
'urn:lsid:labkey.com:Vocabulary.Folder-3234:ProcessParameters#flowRate': 3.2
}
}],
dataRows: []
}]
});
Another saveRuns example:
LABKEY.Experiment.saveRuns({
protocolName: LABKEY.Experiment.SAMPLE_DERIVATION_PROTOCOL,
runs: [{
name: 'two',
properties: {
// property URI from a Vocabulary
'urn:lsid:labkey.com:VocabularyDomain.Folder-123:MyVocab#SoftwareTool': 'hello'
},
materialInputs: [{
name: ‘ParentSampleA’,
sampleSet: {name: 'test'},
properties: {
// property name from the SampleSet
bar: 3,
// property URI from a Vocabulary
'urn:lsid:labkey.com:VocabularyDomain.Folder-123:MyVocab#SoftwareTool': 'hello',
}
}],
}]
});
SQL Queries for Vocabulary Properties
LabKey SQL Example:
SELECT
Samples.Name,
Samples."urn:lsid:labkey.com:Vocabulary.Folder-3234:MyVocab2#pH",
Samples."urn:lsid:labkey.com:Vocabulary.Folder-3234:MyVocab2#instrument",
Properties,
FROM Samples
Custom Grid Views
You can surface vocabulary properties in custom grid views as follows:
- Go to (Grid Views) > Customize Grid.
- Select Show Hidden Fields.
- Select Properties to show a nested grid off all properties or select individual fields to individual properties. See the screenshot below for examples. Note that rendering the nested Properties column may have performance impacts, as it is backed by a broad query.
Reference Docs