Query & integrate data#
import lamindb as ln
import lnschema_bionty as lb
lb.settings.species = "human"
馃挕 loaded instance: testuser1/test-facs (lamindb 0.54.4)
ln.track()
馃挕 notebook imports: lamindb==0.54.4 lnschema_bionty==0.31.2
馃挕 Transform(id='wukchS8V976Uz8', name='Query & integrate data', short_name='facs2', version='0', type=notebook, updated_at=2023-10-01 16:44:48, created_by_id='DzTjkKse')
馃挕 Run(id='BoE9M7kk0ZBJidtGdqB7', run_at=2023-10-01 16:44:48, transform_id='wukchS8V976Uz8', created_by_id='DzTjkKse')
Inspect the CellMarker registry #
Inspect your aggregated cell marker registry as a DataFrame
:
lb.CellMarker.filter().df().head()
name | synonyms | gene_symbol | ncbi_gene_id | uniprotkb_id | species_id | bionty_source_id | updated_at | created_by_id | |
---|---|---|---|---|---|---|---|---|---|
id | |||||||||
0vAls2cmLKWq | ICOS | ICOS | 29851 | Q53QY6 | uHJU | 8RAX | 2023-10-01 16:44:29 | DzTjkKse | |
bspnQ0igku6c | CD16 | FCGR3A | 2215 | O75015 | uHJU | 8RAX | 2023-10-01 16:44:29 | DzTjkKse | |
50v4SaR2m5zQ | CD25 | IL2RA | 3559 | P01589 | uHJU | 8RAX | 2023-10-01 16:44:29 | DzTjkKse | |
HEK41hvaIazP | Cd4 | CD4 | 920 | B4DT49 | uHJU | 8RAX | 2023-10-01 16:44:29 | DzTjkKse | |
k0zGbSgZEX3q | HLADR | HLA鈥怐R|HLA-DR|HLA DR | None | None | None | uHJU | 8RAX | 2023-10-01 16:44:29 | DzTjkKse |
Search for a marker (synonyms aware):
lb.CellMarker.search("PD-1").head(2)
id | synonyms | __ratio__ | |
---|---|---|---|
name | |||
PD1 | 2VeZenLi2dj5 | PID1|PD-1|PD 1 | 100.0 |
Cd14 | roEbL8zuLC5k | 50.0 |
Look up markers with auto-complete:
markers = lb.CellMarker.lookup()
markers.cd14
CellMarker(id='roEbL8zuLC5k', name='Cd14', synonyms='', gene_symbol='CD14', ncbi_gene_id='4695', uniprotkb_id='O43678', updated_at=2023-10-01 16:44:29, species_id='uHJU', bionty_source_id='8RAX', created_by_id='DzTjkKse')
Query files by markers #
Query panels and datasets based on markers, e.g., which datasets have 'CD14'
in the flow panel:
panels_with_cd14 = ln.FeatureSet.filter(cell_markers=markers.cd14).all()
ln.File.filter(feature_sets__in=panels_with_cd14).df()
storage_id | key | suffix | accessor | description | version | size | hash | hash_type | transform_id | run_id | initial_version_id | updated_at | created_by_id | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||||||
8zlLWz5kwz4eVoYxBRwf | mUeGHHxE | None | .h5ad | AnnData | Alpert19 | None | 33369696 | Piw2n0vdnoNoAV7ZxgsW-g | md5 | OWuTtS4SAponz8 | TJweM0VKGkTQHyy8CZci | None | 2023-10-01 16:44:34 | DzTjkKse |
rYTrXas2KdzpqLDUILvH | mUeGHHxE | None | .h5ad | AnnData | Flow cytometry file 2 | None | 6837528 | t6plg-pXZMxqmQN9naNeuw | md5 | SmQmhrhigFPLz8 | qh5Vw8DryjLToUWD3lqo | None | 2023-10-01 16:44:42 | DzTjkKse |
Access registries:
features = ln.Feature.lookup()
Find shared cell markers between two files:
files = ln.File.filter(feature_sets__in=panels_with_cd14).list()
file1, file2 = files[0], files[1]
shared_markers = file1.features["var"] & file2.features["var"]
shared_markers.list("name")
['Cd4', 'CD3', 'CD57', 'Cd14', 'CD8', 'CD127', 'CD27', 'Cd19', 'CD28', 'Ccr7']