facs3/4 Jupyter Notebook lamindata

Query & integrate data

import lamindb as ln
import bionty as bt

ln.track("wukchS8V976U0000")
 connected lamindb: testuser1/test-facs
 created Transform('wukchS8V976U0000'), started new Run('INu3VKyy...') at 2025-01-20 07:39:15 UTC
 notebook imports: bionty==1.0.0 lamindb==1.0.2

Inspect the CellMarker registry

Inspect your aggregated cell marker registry as a DataFrame:

bt.CellMarker.df().head()
Hide code cell output
uid name synonyms description gene_symbol ncbi_gene_id uniprotkb_id space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
41 3ZFziy5ims8J CD14/19 None None None None None 1 NaN 1 2 2025-01-20 07:39:09.161000+00:00 1 None 1
36 5c4A0r7gMiGw CD95 None FAS 2194 P49327 1 28.0 1 2 2025-01-20 07:39:09.151000+00:00 1 None 1
37 3IPMBjs68Vy1 CXCR4 None CXCR4 7852 P61073 1 28.0 1 2 2025-01-20 07:39:09.151000+00:00 1 None 1
38 525YfNUB967z CD49B None ITGA2 3673 P17301 1 28.0 1 2 2025-01-20 07:39:09.151000+00:00 1 None 1
39 1iLDs6cZIpxj CD69 None CD69 969 Q07108 1 28.0 1 2 2025-01-20 07:39:09.151000+00:00 1 None 1

Search for a marker (synonyms aware):

bt.CellMarker.search("PD-1").df().head(2)
Hide code cell output
uid name synonyms description gene_symbol ncbi_gene_id uniprotkb_id space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
29 33vFR1q26vnM PD1 PID1|PD-1|PD 1 None PDCD1 5133 A0A0M3M0G7 1 28 1 1 2025-01-20 07:38:57.129000+00:00 1 None 1

Look up markers with auto-complete:

markers = bt.CellMarker.lookup()
markers.cd8
Hide code cell output
CellMarker(uid='1xRpnOHIkdyE', name='CD8', synonyms='', gene_symbol='CD8A', ncbi_gene_id='925', uniprotkb_id='P01732', created_by_id=1, run_id=1, space_id=1, source_id=28, organism_id=1, created_at=2025-01-20 07:38:57 UTC)

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()
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 4q0QrlBS4kevoDq60000 None Alpert19 .h5ad dataset AnnData 33374864 QNP1c3p6scaAwPo9AW8fLw None 166537 md5 True False 1 1 None None True 1 2025-01-20 07:39:00.005000+00:00 1 None 1
2 5s56cWrWhpiAwh5h0000 None Oetjen18_t1 .h5ad dataset AnnData 46506448 WbPHGIMM_5GT68rC8ZydHA None 241552 md5 True False 1 1 None None True 2 2025-01-20 07:39:09.544000+00:00 1 None 1

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")
Hide code cell output
['Cd4', 'CD8', 'CD3', 'CD27', 'Ccr7', 'CD45RA']