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.64.2 lnschema_bionty==0.36.1
馃挕 saved: Transform(uid='wukchS8V976Uz8', name='Query & integrate data', short_name='facs3', version='0', type=notebook, updated_at=2023-12-22 11:27:22 UTC, created_by_id=1)
馃挕 saved: Run(uid='kVkNVHblePX0mjvpi2F5', run_at=2023-12-22 11:27:22 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 bionty_source_id updated_at created_by_id
id
1 Nb2sscq9cBcB CD57 B3GAT1 27087 Q9P2W7 1 18.0 2023-12-22 11:27:02.104621+00:00 1
2 8OhpfB7wwV32 Cd19 CD19 930 P15391 1 18.0 2023-12-22 11:27:02.104663+00:00 1
3 HEK41hvaIazP Cd4 CD4 920 B4DT49 1 18.0 2023-12-22 11:27:02.104700+00:00 1
4 ttBc0Fs01sYk CD8 CD8A 925 P01732 1 18.0 2023-12-22 11:27:02.104734+00:00 1
5 0evamYEdmaoY Igd None None None 1 18.0 2023-12-22 11:27:02.104770+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-12-22 11:27:02 UTC, organism_id=1, bionty_source_id=18, created_by_id=1)

Query artifacts 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.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 initial_version_id visibility key_is_virtual updated_at created_by_id
id
1 OslkqzGb7i4uhn457Suz 1 None .h5ad AnnData Alpert19 None 33369696 VsTnnzHN63ovNESaJtlRUQ md5 None None 1 1 None 1 True 2023-12-22 11:27:06.598051+00:00 1
2 oy4U1ZeKtFyrQBzSqZa8 1 None .h5ad AnnData Oetjen18_t1 None 46501304 I8nRS02iBs5z1J01b2qwOg md5 None None 2 2 None 1 True 2023-12-22 11:27:15.996428+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']