Query & integrate data#
import lamindb as ln
import lnschema_bionty as lb
lb.settings.species = "human"
馃挕 loaded instance: testuser1/test-facs (lamindb 0.56a1)
ln.track()
馃挕 notebook imports: lamindb==0.56a1 lnschema_bionty==0.32.0
馃挕 Transform(id=3, uid='wukchS8V976Uz8', name='Query & integrate data', short_name='facs3', version='0', type=notebook, updated_at=2023-10-16 21:49:40, created_by_id=1)
馃挕 Run(id=3, uid='mKyFXTXUc9nrKuVDTrLY', run_at=2023-10-16 21:49:40, 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 | species_id | bionty_source_id | updated_at | created_by_id | |
---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||
1 | Nb2sscq9cBcB | CD57 | B3GAT1 | 27087 | Q9P2W7 | 1 | 17.0 | 2023-10-16 21:49:09 | 1 | |
2 | 8OhpfB7wwV32 | Cd19 | CD19 | 930 | P15391 | 1 | 17.0 | 2023-10-16 21:49:09 | 1 | |
3 | HEK41hvaIazP | Cd4 | CD4 | 920 | B4DT49 | 1 | 17.0 | 2023-10-16 21:49:09 | 1 | |
4 | ttBc0Fs01sYk | CD8 | CD8A | 925 | P01732 | 1 | 17.0 | 2023-10-16 21:49:09 | 1 | |
5 | 0evamYEdmaoY | Igd | None | None | None | 1 | 17.0 | 2023-10-16 21:49:09 | 1 |
Search for a marker (synonyms aware):
lb.CellMarker.search("PD-1").head(2)
id | synonyms | __ratio__ | |
---|---|---|---|
name | |||
PD1 | 29 | PID1|PD-1|PD 1 | 100.000000 |
CD14/19 | 41 | 54.545455 |
Look up markers with auto-complete:
markers = lb.CellMarker.lookup()
markers.cd8
CellMarker(id=4, uid='ttBc0Fs01sYk', name='CD8', synonyms='', gene_symbol='CD8A', ncbi_gene_id='925', uniprotkb_id='P01732', updated_at=2023-10-16 21:49:09, species_id=1, bionty_source_id=17, 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 | updated_at | created_by_id | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||
1 | vdxgbweGmDIR4MRGGKRa | 1 | None | .h5ad | AnnData | Alpert19 | None | 33369696 | VsTnnzHN63ovNESaJtlRUQ | md5 | 1 | 1 | None | 2023-10-16 21:49:16 | 1 |
2 | unYBZoZnnTvtsTgHisGC | 1 | None | .h5ad | AnnData | Oetjen18_t1 | None | 46501304 | I8nRS02iBs5z1J01b2qwOg | md5 | 2 | 2 | None | 2023-10-16 21:49:30 | 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']