scrna3/6 Jupyter Notebook lamindata

Query artifacts

Here, we’ll query artifacts and inspect their metadata.

This guide can be skipped if you are only interested in how to leverage the overall collection.

import lamindb as ln
import bionty as bt

ln.track("agayZTonayqA")
Hide code cell output
 connected lamindb: testuser1/test-scrna
 created Transform('agayZTonayqA0000'), started new Run('AEGxhIUn...') at 2025-05-08 07:33:25 UTC
 notebook imports: bionty==1.3.2 lamindb==1.5.0

Query artifacts by provenance metadata

Query the transform, e.g., by key:

transform = ln.Transform.get(key="scrna.ipynb")
transform
Hide code cell output
Transform(uid='Nv48yAceNSh80000', is_latest=True, key='scrna.ipynb', description='scRNA-seq', type='notebook', hash='N9bsgXXEvwah50XKpKewGg', space_id=1, created_by_id=1, created_at=2025-05-08 07:32:20 UTC)

Query the artifact:

ln.Artifact.filter(transform=transform).df()
Hide code cell output
uid key description suffix kind otype size hash n_files n_observations _hash_type _key_is_virtual _overwrite_versions space_id storage_id schema_id version is_latest run_id created_at created_by_id _aux _branch_code
id
1 N1mEcYOuezEzvHsx0000 datasets/conde22.h5ad None .h5ad dataset AnnData 57612943 t_YJQpYrAyAGhs7Ir68zKj None 1648 sha1-fl True False 1 1 3 None True 1 2025-05-08 07:32:58.528000+00:00 1 None 1

Query artifacts by biological metadata

tissues = bt.Tissue.lookup()

query = ln.Artifact.filter(
    tissues=tissues.blood,
)
query.df()
Hide code cell output
uid key description suffix kind otype size hash n_files n_observations _hash_type _key_is_virtual _overwrite_versions space_id storage_id schema_id version is_latest run_id created_at created_by_id _aux _branch_code
id
1 N1mEcYOuezEzvHsx0000 datasets/conde22.h5ad None .h5ad dataset AnnData 57612943 t_YJQpYrAyAGhs7Ir68zKj None 1648 sha1-fl True False 1 1 3 None True 1 2025-05-08 07:32:58.528000+00:00 1 None 1

Inspect artifact metadata

Query all artifacts that measured the “cell_type” feature:

query_set = ln.Artifact.filter(feature_sets__features__name="cell_type").all()
artifact1, artifact2 = query_set[0], query_set[1]
artifact1.describe()
Hide code cell output
Artifact .h5ad/AnnData
├── General
│   ├── .uid = 'N1mEcYOuezEzvHsx0000'
│   ├── .key = 'datasets/conde22.h5ad'
│   ├── .size = 57612943
│   ├── .hash = 't_YJQpYrAyAGhs7Ir68zKj'
│   ├── .n_observations = 1648
│   ├── .path = /home/runner/work/lamin-usecases/lamin-usecases/docs/test-scrna/.lamindb/N1mEcYOuezEzvHsx0000.h5ad
│   ├── .created_by = testuser1 (Test User1)
│   ├── .created_at = 2025-05-08 07:32:58
│   └── .transform = 'scRNA-seq'
├── Dataset features
│   ├── obs4                     [Feature]                                                           
│   │   assay                       cat[bionty.ExperimentalF…  10x 3' v3, 10x 5' v1, 10x 5' v2          
│   │   cell_type                   cat[bionty.CellType]       CD16-negative, CD56-bright natural kille…
│   │   tissue                      cat[bionty.Tissue]         blood, bone marrow, caecum, duodenum, il…
│   │   donor                       str                                                                 
│   └── var.T36503               [bionty.Gene.ensembl_gen…                                           
└── Labels
    └── .tissues                    bionty.Tissue              blood, thoracic lymph node, spleen, lung…
        .cell_types                 bionty.CellType            classical monocyte, T follicular helper …
        .experimental_factors       bionty.ExperimentalFactor  10x 3' v3, 10x 5' v2, 10x 5' v1          
artifact1.view_lineage()
Hide code cell output
_images/3c0d1738ac4398cb68fda088984db3b66154c81a6eabffef01f73efa49804268.svg
artifact2.describe()
Hide code cell output
Artifact .h5ad/AnnData
├── General
│   ├── .uid = 'DqTotMzB8ylFsZRB0001'
│   ├── .size = 857336
│   ├── .hash = 'GK721a-L-fGDI8kXefKMtA'
│   ├── .n_observations = 70
│   ├── .path = /home/runner/work/lamin-usecases/lamin-usecases/docs/test-scrna/.lamindb/DqTotMzB8ylFsZRB0001.h5ad
│   ├── .created_by = testuser1 (Test User1)
│   ├── .created_at = 2025-05-08 07:33:19
│   └── .transform = 'Standardize and append a dataset'
├── Dataset features
│   ├── var754                   [bionty.Gene]                                                       
│   │   HES4                        float                                                               
│   │   TNFRSF4                     float                                                               
│   │   SSU72                       float                                                               
│   │   PARK7                       float                                                               
│   │   RBP7                        float                                                               
│   │   SRM                         float                                                               
│   │   MAD2L2                      float                                                               
│   │   AGTRAP                      float                                                               
│   │   TNFRSF1B                    float                                                               
│   │   EFHD2                       float                                                               
│   │   NECAP2                      float                                                               
│   │   HP1BP3                      float                                                               
│   │   C1QA                        float                                                               
│   │   C1QB                        float                                                               
│   │   HNRNPR                      float                                                               
│   │   GALE                        float                                                               
│   │   STMN1                       float                                                               
│   │   CD52                        float                                                               
│   │   FGR                         float                                                               
│   │   ATP5IF1                     float                                                               
│   └── obs2                     [Feature]                                                           
cell_type                   cat[bionty.CellType]       B cell, CD19-positive, CD14-positive mon…
cell_type_untrusted         cat[bionty.CellType]       B cell, CD19-positive, CD14-positive mon…
└── Labels
    └── .cell_types                 bionty.CellType            CD8-positive, alpha-beta memory T cell, …
artifact2.view_lineage()
Hide code cell output
_images/3778ca21865a29eeb13b28ecaab49e56303116ed22ff270f6431242ea1073fd0.svg