Skip to content

Commit e2f5082

Browse files
committed
Lineage docs
1 parent 0f2d9bb commit e2f5082

File tree

1 file changed

+60
-9
lines changed

1 file changed

+60
-9
lines changed
Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,61 @@
1+
# LabKey Experiment Lineage API
2+
3+
The LabKey Experiment Lineage API provides a powerful way to track and visualize relationships between
4+
different entities in your experimental data. This API allows you to:
5+
6+
1. **Query lineage relationships** between samples, materials, data, and other experimental entities
7+
1. **Traverse lineage graphs** in both upstream (parent) and downstream (child) directions
8+
9+
The lineage API represents relationships as a directed graph where:
10+
11+
- **Nodes** represent individual entities (samples, data objects, etc.)
12+
- **Edges** represent parent-child relationships between entities
13+
- Each node is uniquely identified by its **LSID** (Life Science Identifier)
14+
15+
### API Parameters
16+
17+
The Lineage API accepts the following parameters to control the scope and content of lineage queries:
18+
19+
#### Core Parameters
20+
21+
| Parameter | Type | Description |
22+
|------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------|
23+
| `lsids` | `List[str]` | List of Life Science Identifiers (LSIDs) for which to retrieve lineage information. These are the "seed" entities for the lineage query. |
24+
| `depth` | `int` | Maximum number of generations to traverse in the lineage graph. Default maximum is 100. |
25+
| `parents` | `bool` | Whether to include parent (upstream) relationships in the lineage query. Default is `True`. |
26+
| `children` | `bool` | Whether to include child (downstream) relationships in the lineage query. Default is `True`. |
27+
28+
#### Filtering Parameters
29+
The following filter parameters filter nodes in graph to only match against the corresponding filter(s). NOTE: Using
30+
these filters can produce **disconnected graphs**.
31+
32+
| Parameter | Type | Description |
33+
|---------------------|-------|-----------------------------------------------------------------------------------------------------------|
34+
| `exp_type` | `str` | Filter lineage by experiment type. Possible values: `ALL`, `Data`, `Material`, `ExperimentRun`, `Object`. |
35+
| `cpas_type` | `str` | Filter lineage by CPAS type (optional). |
36+
| `run_protocol_lsid` | `str` | Filter lineage to only include entities associated with a specific protocol (optional). |
37+
38+
#### Data Inclusion Parameters
39+
40+
| Parameter | Type | Description |
41+
|------------------------------|--------|-----------------------------------------------------------------------------------------------|
42+
| `include_properties` | `bool` | Whether to include entity properties in the response. Default is `False`. |
43+
| `include_inputs_and_outputs` | `bool` | Whether to include detailed input and output information for each entity. Default is `False`. |
44+
| `include_run_steps` | `bool` | Whether to include experiment run step information. Default is `False`. |
45+
46+
## Response Structure
47+
The Lineage API response includes:
48+
- **seed**: The LSID(s) of the provided seed node(s)
49+
- **nodes**: A dictionary of all nodes in the lineage graph, keyed by LSID
50+
- Each node contains:
51+
- **name**: Display name of the entity
52+
- **parents**: Array of objects representing parent relationships
53+
- **children**: Array of objects representing child relationships
54+
- Additional properties when requested via inclusion parameters
55+
56+
### Examples
57+
58+
```python
159
from collections import defaultdict
260

361
from labkey.api_wrapper import APIWrapper
@@ -142,22 +200,14 @@
142200
query_name = "Substances"
143201
entity_name = "Ocean Water"
144202

145-
# Fetch the LSID of the "seed" for the lineage request. In this case, we'll query for the "Ocean Water" entity in Substances.
203+
# Fetch the LSID of the "seed" for the lineage request
146204
result = api.query.select_rows(
147205
schema_name, query_name, columns="Name, LSID", filter_array=[QueryFilter("name", entity_name)]
148206
)
149207
seed_lsid = result["rows"][0]["LSID"]
150208

151-
# Lineage results includes the following:
152-
# "seed": The LSID of all furnished seed nodes. A string if only a single seed, otherwise, an array of strings.
153-
# "nodes": A dictionary of lineage node objects keyed by each node's LSID. Nodes are linked together by their "parents" and "children" edges.
154-
#
155-
# On each node the following properties allow for traversal of the flattened graph structure.
156-
# "parents": An array of objects representing edges in the graph from nodes that refer to this node.
157-
# "children": An aray of objects representing edges in the graph to nodes to which this node refers.
158209
lineage_result = api.experiment.lineage([seed_lsid], depth=10)
159210

160-
161211
###################
162212
# Traverse the lineage
163213
###################
@@ -231,3 +281,4 @@ def process_edges(edges, offset):
231281
# OC-2
232282
# OC-3
233283
###################
284+
```

0 commit comments

Comments
 (0)