Vocabulary properties can be used to define a dictionary of terms for use in annotating experiment and sample data. These "ad-hoc" terms can capture metadata of interest not known at the time of assay or sample type definition and not present in the data file. Example use cases:
There are three APIs for defining Vocabulary properties:
Reference Documentation:
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({
requiredVersion: 17.1,
schemaName: "samples",
queryName: "Samples",
columns: ["name", "urn:lsid:labkey.com:Vocabulary.Folder-3234:MyVocab2#pH", "Properties"]
})
The response will include a nested JSON object containing all of the property values. For example,
{
"rows": [
{
"data": {
"Name": {
"url": "/labkey/VocabularyTest/experiment-showMaterial.view?rowId=1104302",
"value": "testing"
},
"Properties": {
"urn:lsid:labkey$Pcom:Vocabulary$PFolder-3234:MyVocab2#pH": {
"value": 7.2
}
}
}
},
{
"data": {
"Name": {
"url": "/labkey/VocabularyTest/experiment-showMaterial.view?rowId=1093855",
"value": "other"
},
"Properties": {
"urn:lsid:labkey$Pcom:Vocabulary$PFolder-3234:MyVocab2#pH": {
"value": 6.7
},
"urn:lsid:labkey$Pcom:Vocabulary$PFolder-3234:MyVocab2#instrument": {
"url": "/labkey/VocabularyTest/list-details.view?listId=1&pk=1",
"displayValue": "HPLC",
"value": 1
}
}
}
}
]
}
Reference Documentation:
Inserting 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 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 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 Sample Type
bar: 3,
// property URI from a Vocabulary
'urn:lsid:labkey.com:VocabularyDomain.Folder-123:MyVocab#SoftwareTool': 'hello',
}
}],
}]
});
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
You can surface vocabulary properties in custom grid views as follows: