facs3/4 Jupyter Notebook lamindata

Query & integrate data#

import lamindb as ln
import lnschema_bionty as lb

lb.settings.organism = "human"
馃挕 lamindb instance: testuser1/test-facs
ln.track()
馃挕 notebook imports: lamindb==0.61.0 lnschema_bionty==0.35.0
馃挕 saved: Transform(uid='wukchS8V976Uz8', name='Query & integrate data', short_name='facs3', version='0', type=notebook, updated_at=2023-11-15 15:55:47 UTC, created_by_id=1)
馃挕 saved: Run(uid='xSIh0BI7wsUWsCsSrcEv', run_at=2023-11-15 15:55:47 UTC, transform_id=3, created_by_id=1)

Inspect the CellMarker registry #

Inspect your aggregated cell marker registry as a DataFrame:

lb.CellMarker.filter().df().head()
uid name synonyms gene_symbol ncbi_gene_id uniprotkb_id organism_id bionty_source_id updated_at created_by_id
id
1 Nb2sscq9cBcB CD57 B3GAT1 27087 Q9P2W7 1 18.0 2023-11-15 15:55:29.186798+00:00 1
2 8OhpfB7wwV32 Cd19 CD19 930 P15391 1 18.0 2023-11-15 15:55:29.186838+00:00 1
3 HEK41hvaIazP Cd4 CD4 920 B4DT49 1 18.0 2023-11-15 15:55:29.186873+00:00 1
4 ttBc0Fs01sYk CD8 CD8A 925 P01732 1 18.0 2023-11-15 15:55:29.186906+00:00 1
5 0evamYEdmaoY Igd None None None 1 18.0 2023-11-15 15:55:29.186941+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=2023-11-15 15:55:29 UTC, organism_id=1, bionty_source_id=18, created_by_id=1)

Query files by markers #

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

panels_with_cd8 = ln.FeatureSet.filter(cell_markers=markers.cd8).all()
ln.File.filter(feature_sets__in=panels_with_cd8).df()
uid storage_id key suffix accessor description version size hash hash_type transform_id run_id initial_version_id visibility key_is_virtual updated_at created_by_id
id
1 a5aPhqsgPvgFbGxVjpmR 1 None .h5ad AnnData Alpert19 None 33369696 VsTnnzHN63ovNESaJtlRUQ md5 1 1 None 0 True 2023-11-15 15:55:33.358120+00:00 1
2 uMsxW6fp1kbpvRhS7b7r 1 None .h5ad AnnData Oetjen18_t1 None 46501304 I8nRS02iBs5z1J01b2qwOg md5 2 2 None 0 True 2023-11-15 15:55:41.767240+00:00 1

Access registries:

features = ln.Feature.lookup()

Find shared cell markers between two files:

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