facs3/4 Jupyter Notebook lamindata

Query & integrate data#

import lamindb as ln
import lnschema_bionty as lb
馃挕 lamindb instance: testuser1/test-facs
ln.track()
馃挕 notebook imports: lamindb==0.66.0 lnschema_bionty==0.37.2
馃挕 saved: Transform(uid='wukchS8V976U6K79', name='Query & integrate data', short_name='facs3', version='0', type=notebook, updated_at=2024-01-08 08:55:50 UTC, created_by_id=1)
馃挕 saved: Run(uid='48g2MYTfWgYyB3iTyysV', run_at=2024-01-08 08:55:50 UTC, transform_id=3, created_by_id=1)

Inspect the CellMarker registry #

Inspect your aggregated cell marker registry as a DataFrame:

lb.CellMarker.df().head()
uid name synonyms gene_symbol ncbi_gene_id uniprotkb_id organism_id bionty_source_id created_at updated_at created_by_id
id
1 Nb2sscq9cBcB CD57 B3GAT1 27087 Q9P2W7 1 18.0 2024-01-08 08:55:29.892974+00:00 2024-01-08 08:55:29.892999+00:00 1
2 8OhpfB7wwV32 Cd19 CD19 930 P15391 1 18.0 2024-01-08 08:55:29.893092+00:00 2024-01-08 08:55:29.893104+00:00 1
3 HEK41hvaIazP Cd4 CD4 920 B4DT49 1 18.0 2024-01-08 08:55:29.893188+00:00 2024-01-08 08:55:29.893199+00:00 1
4 ttBc0Fs01sYk CD8 CD8A 925 P01732 1 18.0 2024-01-08 08:55:29.893282+00:00 2024-01-08 08:55:29.893293+00:00 1
5 0evamYEdmaoY Igd None None None 1 18.0 2024-01-08 08:55:29.893399+00:00 2024-01-08 08:55:29.893411+00:00 1

Search for a marker (synonyms aware):

lb.CellMarker.search("PD-1").head(2)
uid synonyms score
name
PD1 2VeZenLi2dj5 PID1|PD-1|PD 1 100.0
CD14/19 9VptKqpwq9BZ 54.5

Look up markers with auto-complete:

markers = lb.CellMarker.lookup()

markers.cd8
CellMarker(uid='ttBc0Fs01sYk', name='CD8', synonyms='', gene_symbol='CD8A', ncbi_gene_id='925', uniprotkb_id='P01732', updated_at=2024-01-08 08:55:29 UTC, organism_id=1, bionty_source_id=18, created_by_id=1)

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()
uid storage_id key suffix accessor description version size hash hash_type n_objects n_observations transform_id run_id visibility key_is_virtual created_at updated_at created_by_id
id
1 r0JEtdmlEk8HOlLBdLKs 1 None .h5ad AnnData Alpert19 None 33369696 VsTnnzHN63ovNESaJtlRUQ md5 None None 1 1 1 True 2024-01-08 08:55:33.687730+00:00 2024-01-08 08:55:34.714699+00:00 1
2 91D4QKdvDfmBT4YRFDMM 1 None .h5ad AnnData Oetjen18_t1 None 46501304 I8nRS02iBs5z1J01b2qwOg md5 None None 2 2 1 True 2024-01-08 08:55:43.926800+00:00 2024-01-08 08:55:43.926820+00:00 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()
file1, file2 = artifacts[0], artifacts[1]
shared_markers = file1.features["var"] & file2.features["var"]
shared_markers.list("name")
['Cd4', 'CD8', 'CD3', 'CD27', 'Ccr7', 'CD45RA']