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.67.2 lnschema_bionty==0.39.0
馃挕 saved: Transform(uid='wukchS8V976U6K79', name='Query & integrate data', short_name='facs3', version='0', type=notebook, updated_at=2024-01-24 13:39:25 UTC, created_by_id=1)
馃挕 saved: Run(uid='feHPhXHgj4xyP0M1bOZz', run_at=2024-01-24 13:39:25 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 public_source_id created_at updated_at created_by_id
id
41 7SyRazPQeCqG CD14/19 None None None None 1 NaN 2024-01-24 13:39:18.399925+00:00 2024-01-24 13:39:18.399946+00:00 1
40 6ASIQ7GR2c39 CD103 ITGAE 3682 P38570 1 18.0 2024-01-24 13:39:18.364261+00:00 2024-01-24 13:39:18.364272+00:00 1
39 7OES2NXy0W6C CD69 CD69 969 Q07108 1 18.0 2024-01-24 13:39:18.364165+00:00 2024-01-24 13:39:18.364176+00:00 1
38 4Y0JkNLWc8tl CD49B ITGA2 3673 P17301 1 18.0 2024-01-24 13:39:18.364072+00:00 2024-01-24 13:39:18.364083+00:00 1
37 2ddvD3rZZ38f CXCR4 CXCR4 7852 P61073 1 18.0 2024-01-24 13:39:18.363977+00:00 2024-01-24 13:39:18.363988+00:00 1

Search for a marker (synonyms aware):

lb.CellMarker.search("PD-1").head(2)
uid synonyms score
name
PD1 6c7MomnrsfYu PID1|PD-1|PD 1 100.0
CD14/19 7SyRazPQeCqG 54.5

Look up markers with auto-complete:

markers = lb.CellMarker.lookup()

markers.cd8
CellMarker(uid='5YxpB5QNiCWr', name='CD8', synonyms='', gene_symbol='CD8A', ncbi_gene_id='925', uniprotkb_id='P01732', updated_at=2024-01-24 13:39:03 UTC, organism_id=1, public_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 M4MZXcQ1A0ZGe26dIu9M 1 None .h5ad AnnData Alpert19 None 33369696 VsTnnzHN63ovNESaJtlRUQ md5 None None 1 1 1 True 2024-01-24 13:39:08.438266+00:00 2024-01-24 13:39:09.460392+00:00 1
2 bGX8Qu2tmdF4ojiInHuu 1 None .h5ad AnnData Oetjen18_t1 None 46501304 I8nRS02iBs5z1J01b2qwOg md5 None None 2 2 1 True 2024-01-24 13:39:18.837340+00:00 2024-01-24 13:39:18.837360+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']