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('7QvW7mYW...') at 2025-07-08 11:03:09 UTC
 notebook imports: bionty==1.6.0 lamindb==1.7.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='Nv48yAceNSh80000', is_latest=True, key='scrna.ipynb', description='scRNA-seq', type='notebook', hash='IrEQsLuzw-3-3td1Pd778w', branch_id=1, space_id=1, created_by_id=1, created_at=2025-07-08 11:01:39 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_id
id
1 2AJSQbtyNKdIU9tk0000 datasets/conde22.h5ad None .h5ad dataset AnnData 57612943 t_YJQpYrAyAGhs7Ir68zKj None 1648 sha1-fl True False 1 1 3 None True 1 2025-07-08 11:02:38.377000+00:00 1 {'af': {'0': True}} 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_id
id
1 2AJSQbtyNKdIU9tk0000 datasets/conde22.h5ad None .h5ad dataset AnnData 57612943 t_YJQpYrAyAGhs7Ir68zKj None 1648 sha1-fl True False 1 1 3 None True 1 2025-07-08 11:02:38.377000+00:00 1 {'af': {'0': True}} 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 · dataset
├── General
│   ├── uid: 2AJSQbtyNKdIU9tk0000          hash: t_YJQpYrAyAGhs7Ir68zKj
│   ├── size: 54.9 MB                      n_observations: 1648
│   ├── space: all                         branch: main
│   ├── created_at: 2025-07-08 11:02:38    created_by: testuser1 (Test User1)
│   ├── key: datasets/conde22.h5ad
│   ├── storage location / path: 
│   │   /home/runner/work/lamin-usecases/lamin-usecases/docs/test-scrna/.lamindb/2AJSQbtyNKdIU9tk0000.h5ad
│   └── transform: scrna.ipynb
├── Dataset features
│   ├── obs4                         [Feature]                                                                  
│   │   assay                           cat[bionty.ExperimentalFactor]     10x 3' v3, 10x 5' v1, 10x 5' v2         
│   │   cell_type                       cat[bionty.CellType]               CD16-negative, CD56-bright natural kill…
│   │   tissue                          cat[bionty.Tissue]                 blood, bone marrow, caecum, duodenum, i…
│   │   donor                           str                                                                        
│   └── var.T36283                   [bionty.Gene.ensembl_gene_id]                                              
└── 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/c8d9e8ef5f4ba0aa3ef4597b30558ac1bdf8db0a8c94e5ffdc80f8c18b32f75a.svg
artifact2.describe()
Hide code cell output
Artifact .h5ad · AnnData · dataset
├── General
│   ├── uid: se0IcLB1kiNnExJ80001          hash: GK721a-L-fGDI8kXefKMtA
│   ├── size: 837.2 KB                     n_observations: 70
│   ├── space: all                         branch: main
│   ├── created_at: 2025-07-08 11:03:02    created_by: testuser1 (Test User1)
│   ├── storage location / path: 
│   │   /home/runner/work/lamin-usecases/lamin-usecases/docs/test-scrna/.lamindb/se0IcLB1kiNnExJ80001.h5ad
│   ├── description: 10x reference adata, trusted cell type annotation
│   └── transform: scrna2.ipynb
├── 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 mo…
cell_type_untrusted             cat[bionty.CellType]               B cell, CD19-positive, CD14-positive mo…
└── Labels
    └── .cell_types                     bionty.CellType                    CD8-positive, alpha-beta memory T cell,…
artifact2.view_lineage()
Hide code cell output
_images/6c9bddc5a9acbca26f148966bcf8283b66e7f4d323bcc092a5a7a231c3f6f9f8.svg