facs3/4 Jupyter Notebook lamindata

Query & integrate data

import lamindb as ln
import bionty as bt
馃挕 connected lamindb: testuser1/test-facs
ln.settings.transform.stem_uid = "wukchS8V976U"
ln.settings.transform.version = "0"
ln.track()
馃挕 notebook imports: bionty==0.43.0 lamindb==0.72.0
馃挕 saved: Transform(version='0', uid='wukchS8V976U6K79', name='Query & integrate data', key='facs3', type='notebook', updated_at=2024-05-20 08:35:34 UTC, created_by_id=1)
馃挕 saved: Run(uid='UfWgXiPnx0qqMXrm7gNS', transform_id=3, created_by_id=1)

Inspect the CellMarker registry

Inspect your aggregated cell marker registry as a DataFrame:

bt.CellMarker.df().head()
created_at created_by_id run_id updated_at uid name synonyms gene_symbol ncbi_gene_id uniprotkb_id organism_id public_source_id
id
41 2024-05-20 08:35:28.688042+00:00 1 None 2024-05-20 08:35:28.688125+00:00 7SyRazPQeCqG CD14/19 None None None None 1 NaN
40 2024-05-20 08:35:28.678528+00:00 1 None 2024-05-20 08:35:28.678558+00:00 6ASIQ7GR2c39 CD103 ITGAE 3682 P38570 1 18.0
39 2024-05-20 08:35:28.678425+00:00 1 None 2024-05-20 08:35:28.678452+00:00 7OES2NXy0W6C CD69 CD69 969 Q07108 1 18.0
38 2024-05-20 08:35:28.678317+00:00 1 None 2024-05-20 08:35:28.678346+00:00 4Y0JkNLWc8tl CD49B ITGA2 3673 P17301 1 18.0
37 2024-05-20 08:35:28.678204+00:00 1 None 2024-05-20 08:35:28.678235+00:00 2ddvD3rZZ38f CXCR4 CXCR4 7852 P61073 1 18.0

Search for a marker (synonyms aware):

bt.CellMarker.search("PD-1").df().head(2)
created_at created_by_id run_id updated_at uid name synonyms gene_symbol ncbi_gene_id uniprotkb_id organism_id public_source_id
id
29 2024-05-20 08:35:13.236098+00:00 1 None 2024-05-20 08:35:13.236125+00:00 6c7MomnrsfYu PD1 PID1|PD-1|PD 1 PDCD1 5133 A0A0M3M0G7 1 18

Look up markers with auto-complete:

markers = bt.CellMarker.lookup()
markers.cd8
CellMarker(updated_at=2024-05-20 08:35:13 UTC, uid='5YxpB5QNiCWr', name='CD8', synonyms='', gene_symbol='CD8A', ncbi_gene_id='925', uniprotkb_id='P01732', created_by_id=1, organism_id=1, public_source_id=18)

Query artifacts by markers

Query panels and collections based on markers, e.g., which collections have 'CD8' in the flow panel:

panels_with_cd8 = ln.FeatureSet.filter(cell_markers=markers.cd8).all()
ln.Artifact.filter(feature_sets__in=panels_with_cd8).df()
version created_at created_by_id updated_at uid storage_id key suffix accessor description size hash hash_type n_objects n_observations transform_id run_id visibility key_is_virtual
id
1 None 2024-05-20 08:35:18.256408+00:00 1 2024-05-20 08:35:18.335020+00:00 tTAEA65pR5jTPDLKIDEU 1 None .h5ad AnnData Alpert19 33374864 QNP1c3p6scaAwPo9AW8fLw md5 None None 1 1 1 True
2 None 2024-05-20 08:35:29.108369+00:00 1 2024-05-20 08:35:29.192176+00:00 G1eD6CjXt1PMsOJXWNg2 1 None .h5ad AnnData Oetjen18_t1 46506448 WbPHGIMM_5GT68rC8ZydHA md5 None None 2 2 1 True

Access registries:

features = ln.Feature.lookup()

Find shared cell markers between two files:

artifacts = ln.Artifact.filter(feature_sets__in=panels_with_cd8).list()
shared_markers = artifacts[0].features["var"] & artifacts[1].features["var"]
shared_markers.list("name")
['Cd4', 'CD8', 'CD3', 'CD27', 'Ccr7', 'CD45RA']