Jupyter Notebook Binder

Register CellTypist vocabulary#

Cell types classify cells based on public and private knowledge from studying transcription, morphology, function & other properties. Established cell types have well-characterized markers and properties; however, cell subtypes and states are continuously being discovered, refined and better understood.

In this notebook, we register the immune cell type vocabulary from CellTypist, a computational tool used for cell type classification in scRNA-seq data.

Setup#

!lamin init --storage ./celltypist --schema bionty
Hide code cell output
πŸ’‘ creating schemas: core==0.47.5 bionty==0.30.4 
βœ… saved: User(id='DzTjkKse', handle='testuser1', email='testuser1@lamin.ai', name='Test User1', updated_at=2023-09-06 17:21:37)
βœ… saved: Storage(id='jOnLPaEB', root='/home/runner/work/lamin-usecases/lamin-usecases/docs/celltypist', type='local', updated_at=2023-09-06 17:21:37, created_by_id='DzTjkKse')
βœ… loaded instance: testuser1/celltypist
πŸ’‘ did not register local instance on hub (if you want, call `lamin register`)

Hide code cell content
# filter warnings from celltypist
import warnings

warnings.filterwarnings("ignore", message=".*The 'nopython' keyword.*")
import lamindb as ln
import lnschema_bionty as lb
import celltypist
import pandas as pd

lb.settings.species = "human"  # globally set species
βœ… loaded instance: testuser1/celltypist (lamindb 0.52.2)


ln.track()
πŸ’‘ notebook imports: celltypist==1.6.0 lamindb==0.52.2 lnschema_bionty==0.30.4 pandas==2.0.3
βœ… saved: Transform(id='s5mkN5NQ1ttIz8', name='Register CellTypist vocabulary', short_name='celltypist', version='0', type=notebook, updated_at=2023-09-06 17:21:41, created_by_id='DzTjkKse')
βœ… saved: Run(id='m8mtNwKivTg2235hGiQK', run_at=2023-09-06 17:21:41, transform_id='s5mkN5NQ1ttIz8', created_by_id='DzTjkKse')

Access CellTypist records #

As a first step we will read in CellTypist’s immune cell encyclopedia

description = "CellTypist Pan Immune Atlas v2: basic cell type information"
celltypist_source_v2_url = "https://github.com/Teichlab/celltypist_wiki/raw/main/atlases/Pan_Immune_CellTypist/v2/tables/Basic_celltype_information.xlsx"

# our source data
celltypist_file = ln.File.filter(description=description).one_or_none()

if celltypist_file is None:
    celltypist_df = pd.read_excel(celltypist_source_v2_url)
    celltypist_file = ln.File(celltypist_df).save()
else:
    celltypist_df = celltypist_file.load().head()
πŸ’‘ file will be copied to default storage upon `save()` with key `None` ('.lamindb/DutAY50vj7A7W8KRyK1W.parquet')
πŸ’‘ data is a dataframe, consider using .from_df() to link column names as features
βœ… storing file 'DutAY50vj7A7W8KRyK1W' at '.lamindb/DutAY50vj7A7W8KRyK1W.parquet'

It provides an ontology_id of the public Cell Ontology for the majority of records.

celltypist_df.head()
High-hierarchy cell types Low-hierarchy cell types Description Cell Ontology ID Curated markers
0 B cells B cells B lymphocytes with diverse cell surface immuno... CL:0000236 CD79A, MS4A1, CD19
1 B cells Follicular B cells resting mature B lymphocytes found in the prim... CL:0000843 CXCR5, TNFRSF13B, CD22
2 B cells Proliferative germinal center B cells proliferating germinal center B cells CL:0000844 MKI67, SUGCT, AICDA
3 B cells Germinal center B cells proliferating mature B cells that undergo soma... CL:0000844 POU2AF1, CD40, SUGCT
4 B cells Memory B cells long-lived mature B lymphocytes which are form... CL:0000787 CR2, CD27, MS4A1

The β€œCell Ontology ID” is associated with multiple β€œLow-hierarchy cell types”:

celltypist_df.set_index(["Cell Ontology ID", "Low-hierarchy cell types"]).head(10)
High-hierarchy cell types Description Curated markers
Cell Ontology ID Low-hierarchy cell types
CL:0000236 B cells B cells B lymphocytes with diverse cell surface immuno... CD79A, MS4A1, CD19
CL:0000843 Follicular B cells B cells resting mature B lymphocytes found in the prim... CXCR5, TNFRSF13B, CD22
CL:0000844 Proliferative germinal center B cells B cells proliferating germinal center B cells MKI67, SUGCT, AICDA
Germinal center B cells B cells proliferating mature B cells that undergo soma... POU2AF1, CD40, SUGCT
CL:0000787 Memory B cells B cells long-lived mature B lymphocytes which are form... CR2, CD27, MS4A1
Age-associated B cells B cells CD11c+ T-bet+ memory B cells associated with a... FCRL2, ITGAX, TBX21
CL:0000788 Naive B cells B cells mature B lymphocytes which express cell-surfac... IGHM, IGHD, TCL1A
CL:0000818 Transitional B cells B cells immature B cell precursors in the bone marrow ... CD24, MYO1C, MS4A1
CL:0000817 Large pre-B cells B-cell lineage proliferative B lymphocyte precursors derived ... MME, CD24, MKI67
Small pre-B cells B-cell lineage non-proliferative B lymphocyte precursors deri... MME, CD24, IGLL5

Validate CellTypist records #

For any cell type record that can be validated against the public Cell Ontology, we’d like to ensure that it’s actually validated.

This will avoid that we’ll refer to the same cell type with different identifiers.

We need a Bionty object for this:

bionty = lb.CellType.bionty()


bionty
CellType
Species: all
Source: cl, 2023-04-20
#terms: 2862

πŸ“– CellType.df(): ontology reference table
πŸ”Ž CellType.lookup(): autocompletion of terms
🎯 CellType.search(): free text search of terms
βœ… CellType.validate(): strictly validate values
🧐 CellType.inspect(): full inspection of values
πŸ‘½ CellType.standardize(): convert to standardized names
πŸͺœ CellType.diff(): difference between two versions
πŸ”— CellType.ontology: Pronto.Ontology object

We can now validate the "Cell Ontology ID" column

When should I use inspect() and when validate()?

inspect() gives us more logging than validate() but runs a bit slower.

Hence, we’ll use inspect if we suspect validation won’t pass and we want to debug why to curate data.

bionty.inspect(celltypist_df["Cell Ontology ID"], bionty.ontology_id);
βœ… 68 terms (100.00%) are validated for ontology_id

This looks good!

But when inspecting the names, most of them don’t validate:

bionty.inspect(celltypist_df["Low-hierarchy cell types"], bionty.name);
βœ… 1 term (1.00%) is validated for name
❗ 97 terms (99.00%) are not validated for name: B cells, Follicular B cells, Proliferative germinal center B cells, Germinal center B cells, Memory B cells, Age-associated B cells, Naive B cells, Transitional B cells, Large pre-B cells, Small pre-B cells, Pre-pro-B cells, Pro-B cells, Cycling B cells, Cycling DCs, Cycling gamma-delta T cells, Cycling monocytes, Cycling NK cells, Cycling T cells, DC, DC1, ...
πŸ’‘    detected 9 terms with synonyms: DC1, DC2, ETP, CMP, ELP, GMP, ILC2, ILC3, pDC
πŸ’‘ β†’  standardize terms via .standardize()

A search tells us that terms that are named in plural in Cell Typist occur with a name in singular in the Cell Ontology:

celltypist_df["Low-hierarchy cell types"][0]
'B cells'
bionty.search(celltypist_df["Low-hierarchy cell types"][0]).head(2)
ontology_id definition synonyms parents __agg__ __ratio__
name
B cell CL:0000236 A Lymphocyte Of B Lineage That Is Capable Of B... B-cell|B lymphocyte|B-lymphocyte [CL:0000945] b cell 92.307692
cell CL:0000000 A Material Entity Of Anatomical Origin (Part O... None [] cell 90.000000

Let’s try to strip "s" and inspect if more names are now validated. Yes, there are!

bionty.inspect(
    [i.rstrip("s") for i in celltypist_df["Low-hierarchy cell types"]],
    bionty.name,
);
βœ… 5 terms (5.10%) are validated for name
❗ 93 terms (94.90%) are not validated for name: Follicular B cell, Proliferative germinal center B cell, Germinal center B cell, Memory B cell, Age-associated B cell, Naive B cell, Transitional B cell, Large pre-B cell, Small pre-B cell, Pre-pro-B cell, Pro-B cell, Cycling B cell, Cycling DC, Cycling gamma-delta T cell, Cycling monocyte, Cycling NK cell, Cycling T cell, DC, DC1, DC2, ...
πŸ’‘    detected 34 terms with inconsistent casing/synonyms: Follicular B cell, Germinal center B cell, Memory B cell, Naive B cell, Transitional B cell, Small pre-B cell, Pro-B cell, DC1, DC2, Endothelial cell, Epithelial cell, Erythrocyte, ETP, Fibroblast, Granulocyte, Neutrophil, CMP, ELP, GMP, ILC2, ...
πŸ’‘ β†’  standardize terms via .standardize()

Every β€œlow-hierarchy cell type” has an ontology id and most β€œhigh-hierarchy cell types” also appear as β€œlow-hierarchy cell types” in the Cell Typist table. Four, however, don’t, and therefore don’t have an ontology ID.

high_terms = celltypist_df["High-hierarchy cell types"].unique()
low_terms = celltypist_df["Low-hierarchy cell types"].unique()

high_terms_nonval = set(high_terms).difference(low_terms)
high_terms_nonval
{'B-cell lineage', 'Cycling cells', 'Erythroid', 'T cells'}

Register CellTypist records #

Let’s first add the β€œHigh-hierarchy cell types” as a column "parent".

This enables LaminDB to populate the parents and children fields, which will enable you to query for hierarchical relationships.

celltypist_df["parent"] = celltypist_df.pop("High-hierarchy cell types")

# if high and low terms are the same, no parents
celltypist_df.loc[
    (celltypist_df["parent"] == celltypist_df["Low-hierarchy cell types"]), "parent"
] = None

# rename columns, drop markers
celltypist_df.drop(columns=["Curated markers"], inplace=True)
celltypist_df.rename(
    columns={"Low-hierarchy cell types": "name", "Cell Ontology ID": "ontology_id"},
    inplace=True,
)
celltypist_df.columns = celltypist_df.columns.str.lower()
celltypist_df.head(2)
name description ontology_id parent
0 B cells B lymphocytes with diverse cell surface immuno... CL:0000236 None
1 Follicular B cells resting mature B lymphocytes found in the prim... CL:0000843 B cells

Now, let’s create records from the public ontology:

public_records = lb.CellType.from_values(
    celltypist_df.ontology_id, lb.CellType.ontology_id
)
βœ… created 68 CellType records from Bionty matching ontology_id: 'CL:0000236', 'CL:0000843', 'CL:0000844', 'CL:0000787', 'CL:0000788', 'CL:0000818', 'CL:0000817', 'CL:0002046', 'CL:0000826', 'CL:0001056', 'CL:0000798', 'CL:0000576', 'CL:0000623', 'CL:0000084', 'CL:0000990', 'CL:0000840', 'CL:0001029', 'CL:0002489', 'CL:0000809', 'CL:0000553', ...

Let’s now amend public ontology records so that they maintain additional annotations that Cell Typist might have.

records_names = {}
public_records_dict = {r.ontology_id: r for r in public_records}

for _, row in celltypist_df.iterrows():
    name = row["name"]
    ontology_id = row["ontology_id"]
    public_record = public_records_dict[ontology_id]

    # if both name and ontology_id match public record, use public record
    if name.lower() == public_record.name.lower():
        records_names[name] = public_record
        continue
    else:  # when ontology_id matches the public record and name doesn't match
        # if singular form of the Celltypist name matches public name
        if name.lower().rstrip("s") == public_record.name.lower():
            # add the Celltypist name to the synonyms of the public ontology record
            public_record.add_synonym(name)
            records_names[name] = public_record
            continue
        if public_record.synonyms is not None:
            synonyms = [s.lower() for s in public_record.synonyms.split("|")]
            # if any of the public matches celltypist name
            if any(
                [
                    i.lower() in {name.lower(), name.lower().rstrip("s")}
                    for i in synonyms
                ]
            ):
                # add the Celltypist name to the synonyms of the public ontology record
                public_record.add_synonym(name)
                records_names[name] = public_record
                continue

        # create a record only based on Celltypist metadata
        records_names[name] = lb.CellType(
            name=name, ontology_id=ontology_id, description=row.description
        )

You can see certain records are created by adding the Celltypist name to the synonyms of the public record:

records_names["GMP"]
CellType(id='f5eAsw0p', name='granulocyte monocyte progenitor cell', ontology_id='CL:0000557', synonyms='granulocyte/monocyte precursor|GMP|CFU-GM|colony forming unit granulocyte macrophage|granulocyte/monocyte progenitor|granulocyte-macrophage progenitor', description='A Hematopoietic Progenitor Cell That Is Committed To The Granulocyte And Monocyte Lineages. These Cells Are Cd123-Positive, And Do Not Express Gata1 Or Gata2 But Do Express C/Ebpa, And Pu.1.', bionty_source_id='a0Tz', created_by_id='DzTjkKse')

Other records are created based on Celltypist metadata:

records_names["Age-associated B cells"]
CellType(id='00ieV0IG', name='Age-associated B cells', ontology_id='CL:0000787', description='CD11c+ T-bet+ memory B cells associated with autoimmunity and aging', created_by_id='DzTjkKse')

Let’s save them to our database:

records = set(records_names.values())

ln.save(records)
Hide code cell output
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='0JvRwfVm', name='plasma cell', ontology_id='CL:0000786', synonyms='plasma B cell|plasmacyte|Plasma cells|plasmocyte|plasma B-cell', description='A Terminally Differentiated, Post-Mitotic, Antibody Secreting Cell Of The B Cell Lineage With The Phenotype Cd138-Positive, Surface Immunonoglobulin-Negative, And Mhc Class Ii-Negative. Plasma Cells Are Oval Or Round With Extensive Rough Endoplasmic Reticulum, A Well-Developed Golgi Apparatus, And A Round Nucleus Having A Characteristic Cartwheel Heterochromatin Pattern And Are Devoted To Producing Large Amounts Of Immunoglobulin.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000946'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='hFMWJcWc', name='antibody secreting cell', ontology_id='CL:0000946', description='A Lymphocyte Of B Lineage That Is Devoted To Secreting Large Amounts Of Immunoglobulin.', updated_at=2023-09-06 17:21:44, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000945'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='Z0yFV7vU', name='lymphocyte of B lineage', ontology_id='CL:0000945', description='A Lymphocyte Of B Lineage With The Commitment To Express An Immunoglobulin Complex.', updated_at=2023-09-06 17:21:45, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000542'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='g8slxY8X', name='lymphocyte', ontology_id='CL:0000542', description='A Lymphocyte Is A Leukocyte Commonly Found In The Blood And Lymph That Has The Characteristics Of A Large Nucleus, A Neutral Staining Cytoplasm, And Prominent Heterochromatin.', updated_at=2023-09-06 17:21:45, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000738'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='MkrH0gsX', name='leukocyte', ontology_id='CL:0000738', synonyms='white blood cell|leucocyte', description='An Achromatic Cell Of The Myeloid Or Lymphoid Lineages Capable Of Ameboid Movement, Found In Blood Or Other Tissue.', updated_at=2023-09-06 17:21:46, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000988'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='Q0aQr5JB', name='hematopoietic cell', ontology_id='CL:0000988', synonyms='haematopoietic cell|hemopoietic cell|haemopoietic cell', description='A Cell Of A Hematopoietic Lineage.', updated_at=2023-09-06 17:21:46, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 2 CellType records from Bionty matching ontology_id: 'CL:0002371', 'CL:0000548'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='H0taCt24', name='animal cell', ontology_id='CL:0000548', synonyms='metazoan cell', description='A Native Cell That Is Part Of Some Metazoa.', updated_at=2023-09-06 17:21:47, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000255'
πŸ’‘ also saving parents of CellType(id='QMAH6IlS', name='somatic cell', ontology_id='CL:0002371', description='A Cell Of An Organism That Does Not Pass On Its Genetic Material To The Organism'S Offspring (I.E. A Non-Germ Line Cell).', updated_at=2023-09-06 17:21:47, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… loaded 1 CellType record matching ontology_id: 'CL:0000548'
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000003'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='VT73gpK2', name='native cell', ontology_id='CL:0000003', description='A Cell That Is Found In A Natural Setting, Which Includes Multicellular Organism Cells 'In Vivo' (I.E. Part Of An Organism), And Unicellular Organisms 'In Environment' (I.E. Part Of A Natural Environment).', updated_at=2023-09-06 17:21:48, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000000'
πŸ’‘ also saving parents of CellType(id='uMLhrmbZ', name='germinal center B cell', ontology_id='CL:0000844', synonyms='GC B lymphocyte|germinal center B lymphocyte|GC B-cell|germinal center B-lymphocyte|GC B-lymphocyte|Germinal center B cells|germinal center B-cell|GC B cell', description='A Rapidly Cycling Mature B Cell That Has Distinct Phenotypic Characteristics And Is Involved In T-Dependent Immune Responses And Located Typically In The Germinal Centers Of Lymph Nodes. This Cell Type Expresses Ly77 After Activation.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000785'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='0I51jgPp', name='mature B cell', ontology_id='CL:0000785', synonyms='mature B lymphocyte|mature B-cell|mature B-lymphocyte', description='A B Cell That Is Mature, Having Left The Bone Marrow. Initially, These Cells Are Igm-Positive And Igd-Positive, And They Can Be Activated By Antigen.', updated_at=2023-09-06 17:21:49, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0001201'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='CIS4VJI0', name='B cell, CD19-positive', ontology_id='CL:0001201', synonyms='CD19+ B cell|B lymphocyte, CD19-positive|B-lymphocyte, CD19-positive|CD19-positive B cell|B-cell, CD19-positive', description='A B Cell That Is Cd19-Positive.', updated_at=2023-09-06 17:21:50, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='nd6Qaf38', name='Hofbauer cell', ontology_id='CL:3000001', synonyms='Hofbauer cells', description='Oval Eosinophilic Histiocytes With Granules And Vacuoles Found In Placenta, Which Are Of Mesenchymal Origin, In Mesoderm Of The Chorionic Villus, Particularly Numerous In Early Pregnancy.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='Iywg7lUq', name='early lymphoid progenitor', ontology_id='CL:0000936', synonyms='lymphoid-primed multipotent progenitor|LMPP|ELP', description='A Lymphoid Progenitor Cell That Is Found In Bone Marrow, Gives Rise To B Cells, T Cells, Natural Killer Cells And Dendritic Cells, And Has The Phenotype Lin-Negative, Kit-Positive, Sca-1-Positive, Flt3-Positive, Cd34-Positive, Cd150 Negative, And Glya-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='YzV7Qgmj', name='monocyte', ontology_id='CL:0000576', synonyms='Monocytes', description='Myeloid Mononuclear Recirculating Leukocyte That Can Act As A Precursor Of Tissue Macrophages, Osteoclasts And Some Populations Of Tissue Dendritic Cells.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000766'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='40onq0tm', name='myeloid leukocyte', ontology_id='CL:0000766', description='A Cell Of The Monocyte, Granulocyte, Or Mast Cell Lineage.', updated_at=2023-09-06 17:21:51, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='xfxkvliE', name='granulocyte', ontology_id='CL:0000094', synonyms='Granulocytes|granular leukocyte|polymorphonuclear leukocyte|granular leucocyte', description='A Leukocyte With Abundant Granules In The Cytoplasm.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='8lTrmDbK', name='neutrophil', ontology_id='CL:0000775', synonyms='neutrophilic leucocyte|neutrophil leukocyte|Neutrophils|neutrophil leucocyte|neutrocyte|neutrophilic leukocyte', description='Any Of The Immature Or Mature Forms Of A Granular Leukocyte That In Its Mature Form Has A Nucleus With Three To Five Lobes Connected By Slender Threads Of Chromatin, And Cytoplasm Containing Fine Inconspicuous Granules And Stainable By Neutral Dyes.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='XjG8T0GY', name='fibroblast', ontology_id='CL:0000057', synonyms='Fibroblasts', description='A Connective Tissue Cell Which Secretes An Extracellular Matrix Rich In Collagen And Other Macromolecules. Flattened And Irregular In Outline With Branching Processes; Appear Fusiform Or Spindle-Shaped.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002320'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='4zAzIMBQ', name='connective tissue cell', ontology_id='CL:0002320', description='A Cell Of The Supporting Or Framework Tissue Of The Body, Arising Chiefly From The Embryonic Mesoderm And Including Adipose Tissue, Cartilage, And Bone.', updated_at=2023-09-06 17:21:51, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='b5k0suF0', name='erythrocyte', ontology_id='CL:0000232', synonyms='red blood cell|RBC|Erythrocytes', description='A Red Blood Cell. In Mammals, Mature Erythrocytes Are Biconcave Disks Containing Hemoglobin Whose Function Is To Transport Oxygen.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='4fOuOYtl', name='endothelial cell', ontology_id='CL:0000115', synonyms='Endothelial cells|endotheliocyte', description='An Endothelial Cell Comprises The Outermost Layer Or Lining Of Anatomical Structures And Can Be Squamous Or Cuboidal. In Mammals, Endothelial Cell Has Vimentin Filaments And Is Derived From The Mesoderm.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 2 CellType records from Bionty matching ontology_id: 'CL:0000213', 'CL:0002078'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='AHV57RuN', name='lining cell', ontology_id='CL:0000213', synonyms='boundary cell', description='A Cell Within An Epithelial Cell Sheet Whose Main Function Is To Act As An Internal Or External Covering For A Tissue Or An Organism.', updated_at=2023-09-06 17:21:52, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000215'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='gON03kRx', name='barrier cell', ontology_id='CL:0000215', description='A Cell Whose Primary Function Is To Prevent The Transport Of Stuff Across Compartments.', updated_at=2023-09-06 17:21:52, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='nGEtVlKq', name='meso-epithelial cell', ontology_id='CL:0002078', synonyms='epithelial mesenchymal cell', description='Epithelial Cell Derived From Mesoderm Or Mesenchyme.', updated_at=2023-09-06 17:21:52, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='Q2BH279Q', name='classical monocyte', ontology_id='CL:0000860', synonyms='inflammatory monocyte|Classical monocytes', description='A Monocyte That Responds Rapidly To Microbial Stimuli By Secreting Cytokines And Antimicrobial Factors And Which Is Characterized By High Expression Of Ccr2 In Both Rodents And Humans, Negative For The Lineage Markers Cd3, Cd19, And Cd20, And Of Larger Size Than Non-Classical Monocytes.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='YN0gzDt3', name='Kupffer cell', ontology_id='CL:0000091', synonyms='stellate cell of von Kupffer|liver macrophage|Kupffer cells|von Kupffer cell|hepatic macrophage|littoral cell of hepatic sinusoid|macrophagocytus stellatus', description='A Tissue-Resident Macrophage Of The Reticuloendothelial System Found On The Luminal Surface Of The Hepatic Sinusoids Involved In Erythrocyte Clearance. Markers Include F4/80+, Cd11B-Low, Cd68-Positive, Sialoadhesin-Positive, Cd163/Srcr-Positive. Irregular, With Long Processes Including Lamellipodia Extending Into The Sinusoid Lumen, Have Flattened Nucleus With Cytoplasm Containing Characteristic Invaginations Of The Plasma Membrane (Vermiform Bodies); Lie Within The Sinusoid Lumen Attached To The Endothelial Surface; Derived From The Bone Marrow, Form A Major Part Of The Body'S Mononuclear Phagocyte System.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000864'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='pXnRaLwJ', name='tissue-resident macrophage', ontology_id='CL:0000864', synonyms='resting histiocyte|fixed macrophage', description='A Macrophage Constitutively Resident In A Particular Tissue Under Non-Inflammatory Conditions, And Capable Of Phagocytosing A Variety Of Extracellular Particulate Material, Including Immune Complexes, Microorganisms, And Dead Cells.', updated_at=2023-09-06 17:21:53, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='P6E7yrc7', name='epithelial cell', ontology_id='CL:0000066', synonyms='epitheliocyte|Epithelial cells', description='A Cell That Is Usually Found In A Two-Dimensional Sheet With A Free Surface. The Cell Has A Cytoskeleton That Allows For Tight Cell To Cell Contact And For Cell Polarity Where Apical Part Is Directed Towards The Lumen And The Basal Part To The Basal Lamina.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='X458vtJX', name='naive B cell', ontology_id='CL:0000788', synonyms='Naive B cells|naive B-lymphocyte|naive B-cell|naive B lymphocyte', description='A Naive B Cell Is A Mature B Cell That Has The Phenotype Surface Igd-Positive, Surface Igm-Positive, Cd20-Positive, Cd27-Negative And That Has Not Yet Been Activated By Antigen In The Periphery.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='67zMsufW', name='memory B cell', ontology_id='CL:0000787', synonyms='Memory B cells|memory B-lymphocyte|memory B-cell|memory B lymphocyte', description='A Memory B Cell Is A Mature B Cell That Is Long-Lived, Readily Activated Upon Re-Encounter Of Its Antigenic Determinant, And Has Been Selected For Expression Of Higher Affinity Immunoglobulin. This Cell Type Has The Phenotype Cd19-Positive, Cd20-Positive, Mhc Class Ii-Positive, And Cd138-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='RSjQq98q', name='pro-B cell', ontology_id='CL:0000826', synonyms='pro-B-lymphocyte|progenitor B-lymphocyte|Pro-B cells|pro-B-cell|progenitor B lymphocyte|progenitor B-cell|progenitor B cell|pro-B lymphocyte', description='A Progenitor Cell Of The B Cell Lineage, With Some Lineage Specific Activity Such As Early Stages Of Recombination Of B Cell Receptor Genes, But Not Yet Fully Committed To The B Cell Lineage Until The Expression Of Pax5 Occurs.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000838'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='vQ9N8BKH', name='lymphoid lineage restricted progenitor cell', ontology_id='CL:0000838', description='A Progenitor Cell Restricted To The Lymphoid Lineage.', updated_at=2023-09-06 17:21:54, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002031'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='xl6RtpG9', name='hematopoietic lineage restricted progenitor cell', ontology_id='CL:0002031', description='A Hematopoietic Progenitor Cell That Is Capable Of Developing Into Only One Lineage Of Hematopoietic Cells.', updated_at=2023-09-06 17:21:54, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… loaded 1 CellType record matching ontology_id: 'CL:0000988'
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0008001'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='0d3ym06W', name='hematopoietic precursor cell', ontology_id='CL:0008001', description='Any Hematopoietic Cell That Is A Precursor Of Some Other Hematopoietic Cell Type.', updated_at=2023-09-06 17:21:55, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='S4Urkinl', name='macrophage', ontology_id='CL:0000235', synonyms='histiocyte|Macrophages', description='A Mononuclear Phagocyte Present In Variety Of Tissues, Typically Differentiated From Monocytes, Capable Of Phagocytosing A Variety Of Extracellular Particulate Material, Including Immune Complexes, Microorganisms, And Dead Cells.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='FMTngXKK', name='follicular B cell', ontology_id='CL:0000843', synonyms='follicular B-lymphocyte|follicular B lymphocyte|follicular B-cell|Follicular B cells|Fo B-cell|Fo B cell', description='A Resting Mature B Cell That Has The Phenotype Igm-Positive, Igd-Positive, Cd23-Positive And Cd21-Positive, And Found In The B Cell Follicles Of The White Pulp Of The Spleen Or The Corticol Areas Of The Peripheral Lymph Nodes. This Cell Type Is Also Described As Being Cd19-Positive, B220-Positive, Aa4-Negative, Cd43-Negative, And Cd5-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='NJ07Q1hX', name='plasmablast', ontology_id='CL:0000980', synonyms='Plasmablasts|CD27-positive, CD38-positive, CD20-negative B cell', description='An Activated Mature (Naive Or Memory) B Cell That Is Secreting Immunoglobulin, Typified By Being Cd27-Positive, Cd38-Positive, Cd138-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='TENASE93', name='alveolar macrophage', ontology_id='CL:0000583', synonyms='Alveolar macrophages|dust cell', description='A Tissue-Resident Macrophage Found In The Alveoli Of The Lungs. Ingests Small Inhaled Particles Resulting In Degradation And Presentation Of The Antigen To Immunocompetent Cells. Markers Include F4/80-Positive, Cd11B-/Low, Cd11C-Positive, Cd68-Positive, Sialoadhesin-Positive, Dectin-1-Positive, Mr-Positive, Cx3Cr1-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… loaded 1 CellType record matching ontology_id: 'CL:0000864'
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:1001603'
πŸ’‘ also saving parents of CellType(id='cx8VcggA', name='B cell', ontology_id='CL:0000236', synonyms='B-cell|B cells|B lymphocyte|B-lymphocyte', description='A Lymphocyte Of B Lineage That Is Capable Of B Cell Mediated Immunity.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='l0R9X3Bs', name='promyelocyte', ontology_id='CL:0000836', synonyms='Promyelocytes', description='A Precursor In The Granulocytic Series, Being A Cell Intermediate In Development Between A Myeloblast And Myelocyte, That Has Distinct Nucleoli, A Nuclear-To-Cytoplasmic Ratio Of 5:1 To 3:1, And Containing A Few Primary Cytoplasmic Granules. Markers For This Cell Are Fucosyltransferase Fut4-Positive, Cd33-Positive, Integrin Alpha-M-Negative, Low Affinity Immunoglobulin Gamma Fc Region Receptor Iii-Negative, And Cd24-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002191'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='odstSt5D', name='granulocytopoietic cell', ontology_id='CL:0002191', description='A Cell Involved In The Formation Of A Granulocyte.', updated_at=2023-09-06 17:21:56, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000839'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='Q0v4wWyZ', name='myeloid lineage restricted progenitor cell', ontology_id='CL:0000839', description='A Progenitor Cell Restricted To The Myeloid Lineage.', updated_at=2023-09-06 17:21:57, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='f5eAsw0p', name='granulocyte monocyte progenitor cell', ontology_id='CL:0000557', synonyms='granulocyte/monocyte precursor|GMP|CFU-GM|colony forming unit granulocyte macrophage|granulocyte/monocyte progenitor|granulocyte-macrophage progenitor', description='A Hematopoietic Progenitor Cell That Is Committed To The Granulocyte And Monocyte Lineages. These Cells Are Cd123-Positive, And Do Not Express Gata1 Or Gata2 But Do Express C/Ebpa, And Pu.1.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002032'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='JYQl3RX8', name='hematopoietic oligopotent progenitor cell', ontology_id='CL:0002032', description='A Hematopoietic Oligopotent Progenitor Cell That Has The Ability To Differentiate Into Limited Cell Types But Lacks Lineage Cell Markers And Self Renewal Capabilities.', updated_at=2023-09-06 17:21:57, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='Z7uMAWUF', name='regulatory T cell', ontology_id='CL:0000815', synonyms='regulatory T-cell|Treg|regulatory T-lymphocyte|regulatory T lymphocyte|Regulatory T cells', description='A T Cell Which Regulates Overall Immune Responses As Well As The Responses Of Other T Cell Subsets Through Direct Cell-Cell Contact And Cytokine Release.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002419'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='2C5PhwrW', name='mature T cell', ontology_id='CL:0002419', synonyms='mature T-cell|CD3e-positive T cell', description='A T Cell That Expresses A T Cell Receptor Complex And Has Completed T Cell Selection.', updated_at=2023-09-06 17:21:58, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='64kIG7So', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gamma-delta T-cell|gamma-delta T cells|gamma-delta T lymphocyte|gammadelta T cell|gamma-delta T-lymphocyte', description='A T Cell That Expresses A Gamma-Delta T Cell Receptor Complex.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='i20ionW5', name='mast cell', ontology_id='CL:0000097', synonyms='histaminocyte|mastocyte|Mast cells|labrocyte', description='A Cell That Is Found In Almost All Tissues Containing Numerous Basophilic Granules And Capable Of Releasing Large Amounts Of Histamine And Heparin Upon Activation. Progenitors Leave Bone Marrow And Mature In Connective And Mucosal Tissue. Mature Mast Cells Are Found In All Tissues, Except The Bloodstream. Their Phenotype Is Cd117-High, Cd123-Negative, Cd193-Positive, Cd200R3-Positive, And Fceri-High. Stem-Cell Factor (Kit-Ligand; Scf) Is The Main Controlling Signal Of Their Survival And Development.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… loaded 1 CellType record matching ontology_id: 'CL:0000766'
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002274'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='70wMh2r7', name='histamine secreting cell', ontology_id='CL:0002274', description='A Cell Type That Secretes Histamine.', updated_at=2023-09-06 17:21:58, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000457'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='TpKvGjqi', name='biogenic amine secreting cell', ontology_id='CL:0000457', updated_at=2023-09-06 17:21:59, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000151'
πŸ’‘ also saving parents of CellType(id='g2Rk2xkb', name='myelocyte', ontology_id='CL:0002193', synonyms='Myelocytes', description='A Cell Type That Is The First Of The Maturation Stages Of The Granulocytic Leukocytes Normally Found In The Bone Marrow. Granules Are Seen In The Cytoplasm. The Nuclear Material Of The Myelocyte Is Denser Than That Of The Myeloblast But Lacks A Definable Membrane. The Cell Is Flat And Contains Increasing Numbers Of Granules As Maturation Progresses.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='ePsFBu6n', name='transitional stage B cell', ontology_id='CL:0000818', synonyms='transitional stage B lymphocyte|transitional stage B-cell|Transitional B cells|transitional B cell|transitional stage B-lymphocyte', description='An Immature B Cell Of An Intermediate Stage Between The Pre-B Cell Stage And The Mature Naive Stage With The Phenotype Surface Igm-Positive And Cd19-Positive, And Are Subject To The Process Of B Cell Selection. A Transitional B Cell Migrates From The Bone Marrow Into The Peripheral Circulation, And Then To The Spleen.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='ppLUhJWx', name='non-classical monocyte', ontology_id='CL:0000875', synonyms='resident monocyte|patrolling monocyte|Non-classical monocytes', description='A Type Of Monocyte Characterized By Low Expression Of Ccr2, Low Responsiveness To Monocyte Chemoattractant Ccl2/Mcp1, Low Phagocytic Activity, And Decrease Size Relative To Classical Monocytes, But Increased Co-Stimulatory Activity. May Also Play A Role In Tissue Repair.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='loo3Xanl', name='common myeloid progenitor', ontology_id='CL:0000049', synonyms='common myeloid precursor|CMP', description='A Progenitor Cell Committed To Myeloid Lineage, Including The Megakaryocyte And Erythroid Lineages.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
πŸ’‘ also saving parents of CellType(id='3rJgLble', name='conventional dendritic cell', ontology_id='CL:0000990', synonyms='type 1 DC|DC1|dendritic reticular cell|cDC', description='Conventional Dendritic Cell Is A Dendritic Cell That Is Cd11C-High.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000451'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ you can switch this off via: lb.settings.auto_save_parents = False
πŸ’‘ also saving parents of CellType(id='9JGbXeUA', name='dendritic cell', ontology_id='CL:0000451', description='A Cell Of Hematopoietic Origin, Typically Resident In Particular Tissues, Specialized In The Uptake, Processing, And Transport Of Antigens To Lymph Nodes For The Purpose Of Stimulating An Immune Response Via T Cell Activation. These Cells Are Lineage Negative (Cd3-Negative, Cd19-Negative, Cd34-Negative, And Cd56-Negative).', updated_at=2023-09-06 17:22:00, bionty_source_id='a0Tz', created_by_id='DzTjkKse')

Add parent-child relationship of the records from Celltypist#

We still need to add the renaming 4 High hierarchy terms:

list(high_terms_nonval)
['Erythroid', 'T cells', 'Cycling cells', 'B-cell lineage']

Let’s get the top hits from a search:

for term in list(high_terms_nonval):
    print(f"Term: {term}")
    display(bionty.search(term).head(1))
Term: Erythroid

ontology_id definition synonyms parents __agg__ __ratio__
name
erythroid progenitor cell CL:0000038 A Progenitor Cell Committed To The Erythroid L... None [CL:0000839, CL:0000764] erythroid progenitor cell 90.0
Term: T cells

ontology_id definition synonyms parents __agg__ __ratio__
name
T cell CL:0000084 A Type Of Lymphocyte Whose Defining Characteri... T-lymphocyte|T-cell|T lymphocyte [CL:0000542] t cell 92.307692
Term: Cycling cells

ontology_id definition synonyms parents __agg__ __ratio__
name
type G enteroendocrine cell CL:0000508 An Endocrine Cell Found In The Pyloric Gland M... G cell [CL:0000509, CL:0000164, CL:0000506] type g enteroendocrine cell 90.0
Term: B-cell lineage

ontology_id definition synonyms parents __agg__ __ratio__
name
cell CL:0000000 A Material Entity Of Anatomical Origin (Part O... None [] cell 90.0

So we decide to:

  • Add the β€œT cells” to the synonyms of the public β€œT cell” record

  • Create the remaining 3 terms only using their names (we think β€œB cell flow” shouldn’t be identified with β€œB cell”)

for name in high_terms_nonval:
    if name == "T cells":
        record = lb.CellType.from_bionty(name="T cell")
        record.add_synonym(name)
        record.save()
    else:
        record = lb.CellType(name=name)
        record.save()
    records_names[name] = record
❗ records with similar names exist! did you mean to load one of them?
id synonyms __ratio__
name
Mid erythroid lveE8XKg 95.0
Early erythroid MiIxaBcE 90.0
Late erythroid NY6Iq1SQ 90.0
Megakaryocyte-erythroid-mast cell progenitor rDuO4MVx 90.0
βœ… created 1 CellType record from Bionty matching name: 'T cell'
πŸ’‘ also saving parents of CellType(id='BxNjby0x', name='T cell', ontology_id='CL:0000084', synonyms='T cells|T-cell|T-lymphocyte|T lymphocyte', description='A Type Of Lymphocyte Whose Defining Characteristic Is The Expression Of A T Cell Receptor Complex.', updated_at=2023-09-06 17:22:01, bionty_source_id='a0Tz', created_by_id='DzTjkKse')
❗ records with similar names exist! did you mean to load one of them?
id synonyms __ratio__
name
Cycling B cells ibzfn1zQ 95.0
Cycling T cells TTziQpub 95.0
Cycling NK cells rC47wc9h 95.0
cell Ry0JGwSD 90.0
Tcm/Naive cytotoxic T cells 6KPuL5ry 85.5
CRTAM+ gamma-delta T cells pYHfZPub 85.5
Cycling gamma-delta T cells mI0t06Vi 85.5
Follicular helper T cells Z40YuehV 85.5
Memory CD4+ cytotoxic T cells lgyyreJJ 85.5
Proliferative germinal center B cells TC2eLf0p 85.5
B cell cx8VcggA B-cell|B cells|B lymphocyte|B-lymphocyte 85.5
Tem/Effector helper T cells E6PjRrZr 85.5
T cell BxNjby0x T cells|T-cell|T-lymphocyte|T lymphocyte 85.5
Tem/Effector helper T cells PD1+ LIJ5jLyj 85.5
Tem/Temra cytotoxic T cells Qr0e8qFx 85.5
germinal center B cell uMLhrmbZ GC B lymphocyte|germinal center B lymphocyte|G... 85.5
natural killer cell qzbC18BN NK cells|NK cell 85.5
Tcm/Naive helper T cells qlqe2Fe3 85.5
Age-associated B cells 00ieV0IG 85.5
transitional stage B cell ePsFBu6n transitional stage B lymphocyte|transitional s... 85.5
❗ records with similar names exist! did you mean to load one of them?
id synonyms __ratio__
name
B cell cx8VcggA B-cell|B cells|B lymphocyte|B-lymphocyte 90.0
cell Ry0JGwSD 90.0
B cell, CD19-positive CIS4VJI0 CD19+ B cell|B lymphocyte, CD19-positive|B-lym... 85.5
T cell BxNjby0x T cells|T-cell|T-lymphocyte|T lymphocyte 85.5
alveolar macrophage TENASE93 Alveolar macrophages|dust cell 85.5
conventional dendritic cell 3rJgLble type 1 DC|DC1|dendritic reticular cell|cDC 85.5
follicular B cell FMTngXKK follicular B-lymphocyte|follicular B lymphocyt... 85.5
germinal center B cell uMLhrmbZ GC B lymphocyte|germinal center B lymphocyte|G... 85.5
meso-epithelial cell nGEtVlKq epithelial mesenchymal cell 85.5
natural killer cell qzbC18BN NK cells|NK cell 85.5
plasmablast NJ07Q1hX Plasmablasts|CD27-positive, CD38-positive, CD2... 85.5

Now let’s add the parent records:

for _, row in celltypist_df.iterrows():
    record = records_names[row["name"]]
    if row["parent"] is not None:
        parent_record = records_names[row["parent"]]
        record.parents.add(parent_record)

Access the registry#

The previously added CellTypist ontology registry is now available in LaminDB. To retrieve the full ontology table as a Pandas DataFrame we can use .filter:

lb.CellType.filter().df()
name ontology_id abbr synonyms description bionty_source_id updated_at created_by_id
id
8KlE7XUD ILC3 CL:0001078 None None innate lymphoid cell subpopulation III that is... None 2023-09-06 17:21:43 DzTjkKse
tOawPnkV Double-positive thymocytes CL:0000809 None None immature thymocytes capable of binding MHC cla... None 2023-09-06 17:21:43 DzTjkKse
oEwHDrlc ETP CL:0000893 None None early thymic progenitors migrated to the thymu... None 2023-09-06 17:21:43 DzTjkKse
Q4kKk0My CD8a/b(entry) CL:0002430 None None T lymphocytes with CD8 alpha/beta heterodimers... None 2023-09-06 17:21:43 DzTjkKse
YzV7Qgmj monocyte CL:0000576 None Monocytes Myeloid Mononuclear Recirculating Leukocyte Th... a0Tz 2023-09-06 17:21:43 DzTjkKse
... ... ... ... ... ... ... ... ...
9JGbXeUA dendritic cell CL:0000451 None None A Cell Of Hematopoietic Origin, Typically Resi... a0Tz 2023-09-06 17:22:00 DzTjkKse
dZRywRvh Erythroid None None None None None 2023-09-06 17:22:00 DzTjkKse
BxNjby0x T cell CL:0000084 None T cells|T-cell|T-lymphocyte|T lymphocyte A Type Of Lymphocyte Whose Defining Characteri... a0Tz 2023-09-06 17:22:01 DzTjkKse
XYoDhxB0 Cycling cells None None None None None 2023-09-06 17:22:01 DzTjkKse
QYbrQibk B-cell lineage None None None None None 2023-09-06 17:22:01 DzTjkKse

132 rows Γ— 8 columns

This enables us to look for cell types by creating a lookup object from our new CellType registry.

db_lookup = lb.CellType.lookup()
db_lookup.memory_b_cell
CellType(id='67zMsufW', name='memory B cell', ontology_id='CL:0000787', synonyms='Memory B cells|memory B-lymphocyte|memory B-cell|memory B lymphocyte', description='A Memory B Cell Is A Mature B Cell That Is Long-Lived, Readily Activated Upon Re-Encounter Of Its Antigenic Determinant, And Has Been Selected For Expression Of Higher Affinity Immunoglobulin. This Cell Type Has The Phenotype Cd19-Positive, Cd20-Positive, Mhc Class Ii-Positive, And Cd138-Negative.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')

See cell type hierarchy:

db_lookup.memory_b_cell.view_parents()
https://d33wubrfki0l68.cloudfront.net/9c87ddfc0070b44fa7fab2e5c62ee52a326f9d26/12694/_images/50ea80a01f32b4c1670bcfc1acf26cc1686d2957cf2339efa40fc16792ea9cc4.svg

Access parents of a record:

db_lookup.memory_b_cell.parents.list()
[CellType(id='0I51jgPp', name='mature B cell', ontology_id='CL:0000785', synonyms='mature B lymphocyte|mature B-cell|mature B-lymphocyte', description='A B Cell That Is Mature, Having Left The Bone Marrow. Initially, These Cells Are Igm-Positive And Igd-Positive, And They Can Be Activated By Antigen.', updated_at=2023-09-06 17:21:49, bionty_source_id='a0Tz', created_by_id='DzTjkKse'),
 CellType(id='cx8VcggA', name='B cell', ontology_id='CL:0000236', synonyms='B-cell|B cells|B lymphocyte|B-lymphocyte', description='A Lymphocyte Of B Lineage That Is Capable Of B Cell Mediated Immunity.', updated_at=2023-09-06 17:21:43, bionty_source_id='a0Tz', created_by_id='DzTjkKse')]
# clean up test instance
!lamin delete --force celltypist
!rm -r ./celltypist
Hide code cell output
πŸ’‘ deleting instance testuser1/celltypist
βœ…     deleted instance settings file: /home/runner/.lamin/instance--testuser1--celltypist.env
βœ…     instance cache deleted
βœ…     deleted '.lndb' sqlite file
❗     consider manually deleting your stored data: /home/runner/work/lamin-usecases/lamin-usecases/docs/celltypist