Analyze the collection and save a result¶
import lamindb as ln
import bionty as bt
ln.track("zzJzdgJ763Dy0000")
→ connected lamindb: testuser1/test-facs
! creating spaces manually on sqlite databases is possible for demo purposes, but does *not* affect access permissions
→ created Transform('zzJzdgJ763Dy0000'), started new Run('FcDufflA...') at 2025-09-10 09:02:22 UTC
→ notebook imports: bionty==1.7a1 lamindb==1.11a1 scanpy==1.11.4
ln.Collection.to_dataframe()
Show code cell output
uid | key | description | hash | reference | reference_type | space_id | meta_artifact_id | version | is_latest | run_id | created_at | created_by_id | _aux | branch_id | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||
2 | v9w35huBFEcJBp0d0001 | My versioned cytometry collection | None | eNSQbRNsjg278G1RwXmqCw | None | None | 1 | None | 2 | True | 2 | 2025-09-10 09:02:14.240000+00:00 | 1 | None | 1 |
1 | v9w35huBFEcJBp0d0000 | My versioned cytometry collection | None | jZ8YvUdZGRwPgfoBQbOg_Q | None | None | 1 | None | 1 | False | 1 | 2025-09-10 09:02:04.377000+00:00 | 1 | None | 1 |
collection = ln.Collection.get(key="My versioned cytometry collection", version="2")
adata = collection.load(join="inner")
Show code cell output
! creating spaces manually on sqlite databases is possible for demo purposes, but does *not* affect access permissions
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/site-packages/anndata/_core/anndata.py:1774: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.
utils.warn_names_duplicates("obs")
The AnnData
has the reference to the individual files in the .obs
annotations:
adata.obs.artifact_uid.cat.categories
Show code cell output
Index(['BUrhruYi8Gw3rCVR0000', 'd1MS9a3t7v4yzBTB0000'], dtype='object')
By default, the intersection of features is used:
adata.var.index
Show code cell output
Index(['CD8', 'CD27', 'Ccr7', 'Cd4', 'CD45RA', 'CD3'], dtype='object')
Let us create a plot:
markers = bt.CellMarker.lookup()
import scanpy as sc
sc.pp.pca(adata)
sc.pl.pca(adata, color=markers.cd8.name, save="_cd8")
Show code cell output
WARNING: saving figure to file figures/pca_cd8.pdf

artifact = ln.Artifact("./figures/pca_cd8.pdf", description="My result on CD8").save()
artifact.view_lineage()
! creating spaces manually on sqlite databases is possible for demo purposes, but does *not* affect access permissions
Given the image is part of the notebook, there isn’t an actual need to save it and you can also rely on the report that you’ll create when saving the notebook:
ln.finish()
# clean up test instance
!rm -r test-flow
!lamin delete --force test-facs
Show code cell output
rm: cannot remove 'test-flow': No such file or directory
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ '/home/runner/work/lamin-usecases/lamin-usecases/docs/test-facs/.lamindb' │
│ contains 3 objects - delete them prior to deleting the storage location │
╰──────────────────────────────────────────────────────────────────────────────╯