Skip to content

Commit 5a8633b

Browse files
authored
✨ Adopt QueryDB for rxrx (#44)
Signed-off-by: Lukas Heumos <[email protected]>
1 parent 96f9f9b commit 5a8633b

File tree

4 files changed

+93
-28
lines changed

4 files changed

+93
-28
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020
timeout-minutes: 30
2121

2222
steps:
23-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
2424
with:
2525
fetch-depth: 0
2626

27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2828
with:
2929
repository: laminlabs/lndocs
3030
ssh-key: ${{ secrets.READ_LNDOCS }}

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ fail_fast: false
22
default_language_version:
33
python: python3
44
default_stages:
5-
- commit
6-
- push
5+
- pre-commit
6+
- pre-push
77
minimum_pre_commit_version: 2.16.0
88
repos:
99
- repo: https://github.com/rbubley/mirrors-prettier

docs/rxrx.ipynb

Lines changed: 88 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"\n",
2323
"High numbers of fluorescent microscopy images characterize cellular phenotypes in vitro based on morphology and protein expression (5-10 stains) across a range of conditions.\n",
2424
"\n",
25-
"- In this guide, you'll see how to query some of these data using LaminDB.\n",
26-
"- If you'd like to transfer data into your own LaminDB instance, see the [transfer guide](inv:docs#transfer)."
25+
"In this guide, you'll see how to query some of these data using LaminDB.\n",
26+
"If you'd like to transfer data into your own LaminDB instance, see the [transfer guide](inv:docs#transfer)."
2727
]
2828
},
2929
{
@@ -32,21 +32,45 @@
3232
"metadata": {},
3333
"outputs": [],
3434
"source": [
35-
"# !pip install 'lamindb[bionty,jupyter,gcp,wetlab]' duckdb\n",
36-
"!lamin connect laminlabs/lamindata"
35+
"# !pip install 'lamindb[gcp]' duckdb\n",
36+
"!lamin init --modules bionty,wetlab --storage ./test-rxrx"
3737
]
3838
},
3939
{
4040
"cell_type": "code",
4141
"execution_count": null,
42-
"metadata": {},
42+
"metadata": {
43+
"tags": [
44+
"hide-output"
45+
]
46+
},
4347
"outputs": [],
4448
"source": [
4549
"import lamindb as ln\n",
4650
"import bionty as bt\n",
4751
"import wetlab as wl"
4852
]
4953
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"Create the central query object for this instance:"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {
65+
"tags": [
66+
"hide-output"
67+
]
68+
},
69+
"outputs": [],
70+
"source": [
71+
"lamindata_db = ln.QueryDB(\"laminlabs/lamindata\")"
72+
]
73+
},
5074
{
5175
"cell_type": "markdown",
5276
"metadata": {},
@@ -64,10 +88,14 @@
6488
{
6589
"cell_type": "code",
6690
"execution_count": null,
67-
"metadata": {},
91+
"metadata": {
92+
"tags": [
93+
"hide-output"
94+
]
95+
},
6896
"outputs": [],
6997
"source": [
70-
"df = wl.GeneticPerturbation.df()\n",
98+
"df = lamindata_db.genetic_perturbations.to_dataframe()\n",
7199
"df.shape"
72100
]
73101
},
@@ -81,10 +109,16 @@
81109
{
82110
"cell_type": "code",
83111
"execution_count": null,
84-
"metadata": {},
112+
"metadata": {
113+
"tags": [
114+
"hide-output"
115+
]
116+
},
85117
"outputs": [],
86118
"source": [
87-
"sirnas = wl.GeneticPerturbation.filter(system=\"siRNA\").lookup(return_field=\"name\")"
119+
"sirnas = lamindata_db.genetic_perturbations.filter(system=\"siRNA\").lookup(\n",
120+
" return_field=\"name\"\n",
121+
")"
88122
]
89123
},
90124
{
@@ -97,11 +131,15 @@
97131
{
98132
"cell_type": "code",
99133
"execution_count": null,
100-
"metadata": {},
134+
"metadata": {
135+
"tags": [
136+
"hide-output"
137+
]
138+
},
101139
"outputs": [],
102140
"source": [
103-
"cell_lines = bt.CellLine.lookup(return_field=\"abbr\")\n",
104-
"wells = wl.Well.lookup(return_field=\"name\")"
141+
"cell_lines = lamindata_db.cell_lines.lookup(return_field=\"abbr\")\n",
142+
"wells = lamindata_db.wells.lookup(return_field=\"name\")"
105143
]
106144
},
107145
{
@@ -135,7 +173,7 @@
135173
},
136174
"outputs": [],
137175
"source": [
138-
"collection = ln.Collection.get(\"Br2Z1lVSQBAkkbbt7ILu\")\n",
176+
"collection = lamindata_db.collections.get(\"Br2Z1lVSQBAkkbbt7ILu\")\n",
139177
"collection.view_lineage()\n",
140178
"collection.describe()"
141179
]
@@ -150,7 +188,11 @@
150188
{
151189
"cell_type": "code",
152190
"execution_count": null,
153-
"metadata": {},
191+
"metadata": {
192+
"tags": [
193+
"hide-output"
194+
]
195+
},
154196
"outputs": [],
155197
"source": [
156198
"collection.meta_artifact.load().head()"
@@ -189,7 +231,11 @@
189231
{
190232
"cell_type": "code",
191233
"execution_count": null,
192-
"metadata": {},
234+
"metadata": {
235+
"tags": [
236+
"hide-output"
237+
]
238+
},
193239
"outputs": [],
194240
"source": [
195241
"query = df[\n",
@@ -212,7 +258,11 @@
212258
{
213259
"cell_type": "code",
214260
"execution_count": null,
215-
"metadata": {},
261+
"metadata": {
262+
"tags": [
263+
"hide-output"
264+
]
265+
},
216266
"outputs": [],
217267
"source": [
218268
"collection.data_artifact.storage.root"
@@ -221,7 +271,11 @@
221271
{
222272
"cell_type": "code",
223273
"execution_count": null,
224-
"metadata": {},
274+
"metadata": {
275+
"tags": [
276+
"hide-output"
277+
]
278+
},
225279
"outputs": [],
226280
"source": [
227281
"images = [f\"{collection.data_artifact.storage.root}/{key}\" for key in query.path]\n",
@@ -238,7 +292,11 @@
238292
{
239293
"cell_type": "code",
240294
"execution_count": null,
241-
"metadata": {},
295+
"metadata": {
296+
"tags": [
297+
"hide-output"
298+
]
299+
},
242300
"outputs": [],
243301
"source": [
244302
"path = ln.UPath(images[1])\n",
@@ -248,7 +306,11 @@
248306
{
249307
"cell_type": "code",
250308
"execution_count": null,
251-
"metadata": {},
309+
"metadata": {
310+
"tags": [
311+
"hide-output"
312+
]
313+
},
252314
"outputs": [],
253315
"source": [
254316
"from IPython.display import Image\n",
@@ -273,22 +335,25 @@
273335
{
274336
"cell_type": "code",
275337
"execution_count": null,
276-
"metadata": {},
338+
"metadata": {
339+
"tags": [
340+
"hide-output"
341+
]
342+
},
277343
"outputs": [],
278344
"source": [
279345
"import duckdb\n",
280346
"\n",
281-
"features = ln.Feature.lookup(return_field=\"name\")\n",
347+
"features = lamindata_db.features.lookup(return_field=\"name\")\n",
282348
"\n",
283349
"filter = (\n",
284350
" f\"{features.cell_line} == '{cell_lines.hep_g2_cell}' and {features.sirna} ==\"\n",
285351
" f\" '{sirnas.s15652}' and {features.well} == '{wells.m15}' and \"\n",
286352
" f\"{features.plate} == '1' and {features.site} == '2'\"\n",
287353
")\n",
288354
"\n",
289-
"region = ln.setup.settings.storage.region\n",
290355
"parquet_data = duckdb.from_parquet(\n",
291-
" collection.meta_artifact.path.as_posix() + f\"?s3_region={region}\"\n",
356+
" collection.meta_artifact.path.as_posix() + \"?s3_region=us-east-1\"\n",
292357
")\n",
293358
"\n",
294359
"parquet_data.filter(filter)"

docs/vitessce.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"source": [
4242
"# pip install \"vitessce[all]>=3.5.0\"\n",
4343
"# pip install \"generate-tiff-offsets>=0.1.9\"\n",
44-
"# pip install \"lamindb[jupyter,bionty]\"\n",
44+
"# pip install lamindb\n",
4545
"!lamin connect laminlabs/lamin-dev # <-- replace with your instance"
4646
]
4747
},

0 commit comments

Comments
 (0)