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', key='scrna3.ipynb'), started new Run('X4SzPBQCx7is9Kun') at 2025-11-26 11:07:08 UTC
 notebook imports: bionty==1.9.1 lamindb==1.16.1

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='uis9JE6QvjtV0000', version=None, is_latest=True, key='scrna.ipynb', description='scRNA-seq', type='notebook', hash='d6nbXlW_Fw7QJiczNGpj-g', reference=None, reference_type=None, branch_id=1, space_id=1, created_by_id=1, created_at=2025-11-26 11:06:21 UTC, is_locked=False)

Query the artifact:

ln.Artifact.filter(transform=transform).to_dataframe()
Hide code cell output
uid key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id
id
1 RN05RcFzLZWRsad20000 datasets/conde22.h5ad None .h5ad dataset AnnData 57612943 t_YJQpYrAyAGhs7Ir68zKj None 1648 None True False 2025-11-26 11:06:47.005000+00:00 1 1 1 1 3 1

Query artifacts by biological metadata

tissues = bt.Tissue.lookup()

query = ln.Artifact.filter(
    tissues=tissues.blood,
)
query.to_dataframe()
Hide code cell output
uid key description suffix kind otype size hash n_files n_observations version is_latest is_locked created_at branch_id space_id storage_id run_id schema_id created_by_id
id
1 RN05RcFzLZWRsad20000 datasets/conde22.h5ad None .h5ad dataset AnnData 57612943 t_YJQpYrAyAGhs7Ir68zKj None 1648 None True False 2025-11-26 11:06:47.005000+00:00 1 1 1 1 3 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: datasets/conde22.h5ad (0000)
├── uid: RN05RcFzLZWRsad20000            run: NrVbfmV (scrna.ipynb)
kind: dataset                        otype: AnnData            
hash: t_YJQpYrAyAGhs7Ir68zKj         size: 54.9 MB             
branch: main                         space: all                
created_at: 2025-11-26 11:06:47 UTC  created_by: testuser1     
n_observations: 1648                                           
├── storage/path: 
/home/runner/work/lamin-usecases/lamin-usecases/docs/test-scrna/.lamindb/RN05RcFzLZWRsad20000.h5ad
├── Dataset features
├── obs (4)                                                                                                    
│   assay                           bionty.ExperimentalFactor          10x 3' v3, 10x 5' v1, 10x 5' v2         
│   cell_type                       bionty.CellType                    CD16-negative, CD56-bright natural kill…
│   tissue                          bionty.Tissue                      blood, bone marrow, caecum, duodenum, i…
│   donor                           str                                                                        
└── var.T (36283 bionty.Gene.ense…                                                                             
└── Labels
    └── .tissues                        bionty.Tissue                      blood, thoracic lymph node, spleen, lun…
        .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/a50384505288ce953cf8880f757a9bed7bc25b77dcaefc47bc220ba64a1a774e.svg
artifact2.describe()
Hide code cell output
Artifact: scrna/dataset2.h5ad (0001)
|   description: 10x reference adata, trusted cell type annotation
├── uid: YPzTiZZiULn5ufBM0001            run: hzx93VM (scrna2.ipynb)
kind: dataset                        otype: AnnData             
hash: 57xpUqmnZeBP6et6xOCcPA         size: 835.8 KB             
branch: main                         space: all                 
created_at: 2025-11-26 11:07:03 UTC  created_by: testuser1      
n_observations: 70                                              
├── storage/path: 
/home/runner/work/lamin-usecases/lamin-usecases/docs/test-scrna/.lamindb/YPzTiZZiULn5ufBM0001.h5ad
├── Dataset features
├── obs (1)                                                                                                    
│   cell_type                       bionty.CellType                    B cell, CD19-positive, CD14-positive mo…
└── var.T (754 bionty.Gene.ensemb…                                                                             
    HES4                            num                                                                        
    TNFRSF4                         num                                                                        
    SSU72                           num                                                                        
    PARK7                           num                                                                        
    RBP7                            num                                                                        
    SRM                             num                                                                        
    MAD2L2                          num                                                                        
    AGTRAP                          num                                                                        
    TNFRSF1B                        num                                                                        
    EFHD2                           num                                                                        
    NECAP2                          num                                                                        
    HP1BP3                          num                                                                        
    C1QA                            num                                                                        
    C1QB                            num                                                                        
    HNRNPR                          num                                                                        
    GALE                            num                                                                        
    STMN1                           num                                                                        
    CD52                            num                                                                        
    FGR                             num                                                                        
    ATP5IF1                         num                                                                        
└── Labels
    └── .cell_types                     bionty.CellType                    CD8-positive, alpha-beta memory T cell,…
artifact2.view_lineage()
Hide code cell output
_images/e48c163328ae534ae7446eda526a7e5232d46476872a60e004bf165dc24712c2.svg