facs4/4 Jupyter Notebook lamindata

Analyze the dataset and save a result#

import lamindb as ln
import lnschema_bionty as lb

ln.track()
💡 loaded instance: testuser1/test-facs (lamindb 0.55.0)
💡 notebook imports: lamindb==0.55.0 lnschema_bionty==0.31.2 scanpy==1.9.5
💡 Transform(id='zzJzdgJ763Dyz8', name='Analyze the dataset and save a result', short_name='facs4', version='0', type=notebook, updated_at=2023-10-04 16:42:56, created_by_id='DzTjkKse')
💡 Run(id='XLzAFNslxDqKGQMq5Cm1', run_at=2023-10-04 16:42:56, transform_id='zzJzdgJ763Dyz8', created_by_id='DzTjkKse')
hello

within hello

ln.Dataset.filter().df()
name description version hash reference reference_type transform_id run_id file_id storage_id initial_version_id updated_at created_by_id
id
dwdXtuUm7KR2XuBNSbsv My versioned cytometry dataset None 1 VsTnnzHN63ovNESaJtlRUQ None None OWuTtS4SAponz8 E3HTifOWblJJ2zFrUEug dwdXtuUm7KR2XuBNSbsv None None 2023-10-04 16:42:27 DzTjkKse
dwdXtuUm7KR2XuBNSbsm My versioned cytometry dataset None 2 ZKQxIw0uAvtMtdZk8SAj None None SmQmhrhigFPLz8 Xw5xc4OteUjTU31pfcZC None None dwdXtuUm7KR2XuBNSbsv 2023-10-04 16:42:43 DzTjkKse
dataset = ln.Dataset.filter(name="My versioned cytometry dataset", version="2").one()
adata = dataset.load(join="inner")
hello

within hello

hello

hello

/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/site-packages/anndata/_core/anndata.py:1838: 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.file_id.cat.categories
Index(['GUHGDTFLeHzBjo4TKBwe', 'dwdXtuUm7KR2XuBNSbsv'], dtype='object')

By default, the intersection of features is used:

adata.var.index
Index(['CD8', 'CD27', 'Ccr7', 'Cd4', 'CD45RA', 'CD3'], dtype='object')

Let us create a plot:

markers = lb.CellMarker.lookup()
hello

import scanpy as sc

sc.pp.pca(adata)
sc.pl.pca(adata, color=markers.cd8.name, save="_cd8")
WARNING: saving figure to file figures/pca_cd8.pdf
https://d33wubrfki0l68.cloudfront.net/845a283e2e48ef295834ac32fc102ab8d2af3634/1f8b7/_images/1a5cd40184f54765d280e465188f785571825f3b3b6ae2676d241aa398b96edf.png
file = ln.File("./figures/pca_cd8.pdf", description="My result on CD8")

file.save()
file.view_flow()
hello

within hello

hello

within hello

hello

within hello

hello

within hello

hello

hello

hello

hello

hello

hello

within hello

hello

within hello

hello

within hello

hello

within hello

hello

hello

hello

hello

hello

hello

hello

within hello

hello

within hello

hello

within hello

hello

within hello

hello

hello

hello

hello

hello

within hello

hello

within hello

hello

within hello

hello

within hello

hello

hello

hello

hello

hello

hello

hello

within hello

hello

within hello

hello

within hello

hello

within hello

hello

hello

hello

hello

hello

hello

hello

hello

hello

https://d33wubrfki0l68.cloudfront.net/8baeb009bd9ce74d1030d9f1b9214271056c075b/8bed2/_images/1b5b20c74c202ba42d5aac1b2132a1507051cc923176608e8f47d8534c332083.svg

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 via the command line via:

lamin save <notebook_path>
# clean up test instance
!lamin delete --force test-facs
!rm -r test-flow
💡 deleting instance testuser1/test-facs
✅     deleted instance settings file: /home/runner/.lamin/instance--testuser1--test-facs.env
✅     instance cache deleted
✅     deleted '.lndb' sqlite file
❗     consider manually deleting your stored data: /home/runner/work/lamin-usecases/lamin-usecases/docs/test-facs
rm: cannot remove 'test-flow': No such file or directory