Query & integrate data#
import lamindb as ln
import lnschema_bionty as lb
lb.settings.species = "human"
馃挕 loaded instance: testuser1/test-facs (lamindb 0.54.2)
ln.track()
馃挕 notebook imports: lamindb==0.54.2 lnschema_bionty==0.31.2
馃挕 Transform(id='wukchS8V976Uz8', name='Query & integrate data', short_name='facs2', version='0', type=notebook, updated_at=2023-09-27 19:03:58, created_by_id='DzTjkKse')
馃挕 Run(id='eA3SzcdxdSmlKbTlpgUp', run_at=2023-09-27 19:03:58, 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 | |||||||||
0qCmUijBeByY | CD94 | KLRD1 | 3824 | Q13241 | uHJU | RlqM | 2023-09-27 19:03:35 | DzTjkKse | |
bspnQ0igku6c | CD16 | FCGR3A | 2215 | O75015 | uHJU | RlqM | 2023-09-27 19:03:35 | DzTjkKse | |
ttBc0Fs01sYk | CD8 | CD8A | 925 | P01732 | uHJU | RlqM | 2023-09-27 19:03:35 | DzTjkKse | |
ljp5UfCF9HCi | TCRgd | TCRGAMMADELTA|TCR纬未 | None | None | None | uHJU | RlqM | 2023-09-27 19:03:35 | DzTjkKse |
yCyTIVxZkIUz | DNA2 | DNA2 | 1763 | P51530 | uHJU | RlqM | 2023-09-27 19:03:35 | 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 |
CD16 | bspnQ0igku6c | 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-09-27 19:03:35, species_id='uHJU', bionty_source_id='RlqM', 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 | ||||||||||||||
RY2suClyjVaJf7WYC0SH | VvPocT7z | None | .h5ad | AnnData | Flow cytometry file 2 | None | 6837528 | aWYCHE1-26gzAU6rlgoMtQ | md5 | SmQmhrhigFPLz8 | iKuM6oyOKGVBDvx0YQ7P | None | 2023-09-27 19:03:52 | DzTjkKse |
8RZdIbll16NTrAwo7lRL | VvPocT7z | None | .h5ad | AnnData | See dataset 8RZdIbll16NTrAwo7lRL | None | 33369696 | fnzTGHE8BlkiMMIqHLDjyA | md5 | OWuTtS4SAponz8 | 6LxzHJKBOJu5s56VPocZ | None | 2023-09-27 19:03: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")
['CD27', 'CD8', 'Ccr7', 'CD57', 'Cd4', 'CD3', 'Cd19', 'CD28', 'CD127', 'Cd14']