Jupyter Notebook

Manage biological registries#

Registries manage the formalized knowledge & experimental design that anchor dry & wetlab work.

In LaminDB, registries are standard SQL tables, equipped with mechanisms that avoid typos & duplicated data.

In addition, LaminDB makes it easy to import records from public biological ontologies, based on plug-in bionty.

In this notebook, you’ll see how to manage an in-house ontology anchored in public knowledge.

(If you also manage experimental design through registries, you can access all metadata through one API and store it in one simple SQL database.)

Setup#

Let us create an instance that has bionty mounted, which extends to include biological registries:

!lamin init --storage ./test-registries --schema bionty
Hide code cell output
πŸ’‘ connected lamindb: testuser1/test-registries
import lamindb as ln
import bionty as bt

ln.connect("test-registries")
ln.settings.verbosity = "info"
πŸ’‘ connected lamindb: testuser1/test-registries

Let’s pre-populate the cell type registry with a few records:

bt.Organism.from_public(name="human").save()
bt.CellType.from_public(name="T cell").save()
bt.CellType(name="my T cell subtype").save()
Hide code cell output
βœ… created 1 Organism record from Bionty matching name: 'human'
βœ… created 1 CellType record from Bionty matching name: 'T cell'
πŸ’‘ also saving parents of CellType(uid='22LvKd01', name='T cell', ontology_id='CL:0000084', synonyms='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=2024-05-01 18:48:53 UTC, public_source_id=21, created_by_id=1)
βœ… 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
πŸ’‘ also saving parents of CellType(uid='X6c7osZ5', 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=2024-05-01 18:48:53 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000842'
πŸ’‘ also saving parents of CellType(uid='2Jgr5Xx4', name='mononuclear cell', ontology_id='CL:0000842', synonyms='mononuclear leukocyte', description='A Leukocyte With A Single Non-Segmented Nucleus In The Mature Form.', updated_at=2024-05-01 18:48:54 UTC, public_source_id=21, created_by_id=1)
βœ… created 2 CellType records from Bionty matching ontology_id: 'CL:0000738', 'CL:0000226'
πŸ’‘ also saving parents of CellType(uid='3VEAlFdi', 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=2024-05-01 18:48:54 UTC, public_source_id=21, created_by_id=1)
βœ… created 3 CellType records from Bionty matching ontology_id: 'CL:0000988', 'CL:0002242', 'CL:0000219'
πŸ’‘ also saving parents of CellType(uid='2K93w3xO', name='motile cell', ontology_id='CL:0000219', description='A Cell That Moves By Its Own Activities.', updated_at=2024-05-01 18:48:55 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000003'
πŸ’‘ also saving parents of CellType(uid='1AtefLrT', 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=2024-05-01 18:48:55 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000000'
πŸ’‘ also saving parents of CellType(uid='u3sr1Gdf', name='nucleate cell', ontology_id='CL:0002242', description='A Cell Containing At Least One Nucleus.', updated_at=2024-05-01 18:48:55 UTC, public_source_id=21, created_by_id=1)
πŸ’‘ also saving parents of CellType(uid='4Ilrnj9U', name='hematopoietic cell', ontology_id='CL:0000988', synonyms='haematopoietic cell|hemopoietic cell|haemopoietic cell', description='A Cell Of A Hematopoietic Lineage.', updated_at=2024-05-01 18:48:55 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0002371'
πŸ’‘ also saving parents of CellType(uid='1ivhjCnJ', 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=2024-05-01 18:48:56 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000548'
πŸ’‘ also saving parents of CellType(uid='2FCw82aH', name='animal cell', ontology_id='CL:0000548', synonyms='metazoan cell', description='A Native Cell That Is Part Of Some Metazoa.', updated_at=2024-05-01 18:48:57 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000255'
πŸ’‘ also saving parents of CellType(uid='4WnpvUTH', name='eukaryotic cell', ontology_id='CL:0000255', updated_at=2024-05-01 18:48:58 UTC, public_source_id=21, created_by_id=1)
πŸ’‘ also saving parents of CellType(uid='2cXC7cgF', name='single nucleate cell', ontology_id='CL:0000226', description='A Cell With A Single Nucleus.', updated_at=2024-05-01 18:48:54 UTC, public_source_id=21, created_by_id=1)

Access records in public ontologies#

We start with a public ontology for cell types.

.public() gives you access to the ReferenceTable, a class for accessing public ontologies.

ReferenceTable provides simple access to standardized public ontologies that Lamin hosts for reliable and performant access. For most ReferenceTable objects, you can access the underlying ontology through Pronto.

Let’s create a ReferenceTable object:

public = bt.CellType.public()
public
PublicOntology
Entity: CellType
Organism: all
Source: cl, 2023-08-24
#terms: 2894

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

We can use it to search the public ontology against cell types:

public.search("gamma delta T cell").head(3)
ontology_id definition synonyms parents __ratio__
name
gamma-delta T cell CL:0000798 A T Cell That Expresses A Gamma-Delta T Cell R... gamma-delta T lymphocyte|gamma-delta T-lymphoc... [CL:0000084] 100.000000
CD27-negative gamma-delta T cell CL:0002125 A Circulating Gamma-Delta T Cell That Expresse... gammadelta-17 cells [CL:0000800] 86.486486
mature gamma-delta T cell CL:0000800 A Gamma-Delta T Cell That Has A Mature Phenoty... mature gamma-delta T-lymphocyte|mature gamma-d... [CL:0000798, CL:0002419] 83.720930

And we can also use it to look up cell types with auto-complete:

lookup = public.lookup()
lookup.gamma_delta_t_cell
CellType(ontology_id='CL:0000798', name='gamma-delta T cell', definition='A T Cell That Expresses A Gamma-Delta T Cell Receptor Complex.', synonyms='gamma-delta T lymphocyte|gamma-delta T-lymphocyte|gamma-delta T-cell|gammadelta T cell', parents=array(['CL:0000084'], dtype=object))

Create records in in-house ontologies#

We can now create a record for our in-house SQL registry by passing the result of the lookup in the public ontology to the CellType constructor:

gdt_cell = bt.CellType(lookup.gamma_delta_t_cell)
gdt_cell
CellType(uid='1HuNn2EP', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gamma-delta T lymphocyte|gamma-delta T-lymphocyte|gamma-delta T-cell|gammadelta T cell', public_source_id=21, created_by_id=1)

(Alternatively, we could construct the gamma delta T cell via from_public(), which is synonyms-aware.)

bt.CellType.from_public(ontology_id="CL:0000798")
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000798'
CellType(uid='1HuNn2EP', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gamma-delta T lymphocyte|gamma-delta T-lymphocyte|gamma-delta T-cell|gammadelta T cell', description='A T Cell That Expresses A Gamma-Delta T Cell Receptor Complex.', public_source_id=21, created_by_id=1)

When we save this record to the registry, logging informs us that we’re also saving parent ontological terms:

gdt_cell.save()
Hide code cell output
πŸ’‘ also saving parents of CellType(uid='1HuNn2EP', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gamma-delta T lymphocyte|gamma-delta T-lymphocyte|gamma-delta T-cell|gammadelta T cell', updated_at=2024-05-01 18:48:59 UTC, public_source_id=21, created_by_id=1)
Will I always see parents being saved?

No, this only happens a single time.

  • If we accidentally save the same record again, it will be recognized that the record and all parents are already in the registry.

  • If we save another record that has overlapping parents, only new parents will be saved.

View the ontological hierarchy:

gdt_cell.view_parents()
_images/ca3216edd5f15f39af44b6928ee2afd6bbcc741f8f65c3debbc917b52f07a3e0.svg

Or access the parents directly:

gdt_cell.parents.df()
uid name ontology_id abbr synonyms description public_source_id created_at updated_at created_by_id
id
1 22LvKd01 T cell CL:0000084 None T-cell|T-lymphocyte|T lymphocyte A Type Of Lymphocyte Whose Defining Characteri... 21 2024-05-01 18:48:53.206602+00:00 2024-05-01 18:48:53.206632+00:00 1

You can construct custom hierarchies of terms by specifying parents:

my_celltype = bt.CellType.filter(name="my T cell subtype").one()
my_celltype.parents.add(gdt_cell)
gdt_cell.view_parents(distance=2, with_children=True)
_images/d489b6fee84c2d1771a61acdca4a5302fdb608708cf47967f9f25b7e2d739a40.svg

This cell type and all its parents can now be queried & searched in the registry using bionty.CellType.filter and bionty.CellType.search.

Load records for values in data sources#

When accessing data sources, one often encounters bulk references to entities that might be corrupted or standardized using different standardization schemes.

Let’s consider an example based on an AnnData object:

adata = ln.core.datasets.anndata_with_obs()

In the cell_type annotations of this AnnData object, we find 4 references to cell types:

adata.obs.cell_type.value_counts()
T cell                     10
hematopoietic stem cell    10
hepatocyte                 10
my new cell type           10
Name: cell_type, dtype: int64

We’d like to load the corresponding records in our in-house ontology to annotate a dataset.

To this end, you’ll typically use from_values, which will both validate & load records that match the values.

cell_types = bt.CellType.from_values(adata.obs.cell_type)
cell_types
βœ… loaded 1 CellType record matching name: 'T cell'
βœ… created 2 CellType records from Bionty matching name: 'hepatocyte', 'hematopoietic stem cell'
❗ did not create CellType record for 1 non-validated name: 'my new cell type'
[CellType(uid='22LvKd01', name='T cell', ontology_id='CL:0000084', synonyms='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=2024-05-01 18:48:53 UTC, public_source_id=21, created_by_id=1),
 CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', synonyms='hemopoietic stem cell|blood forming stem cell', description='A Stem Cell From Which All Cells Of The Lymphoid And Myeloid Lineages Develop, Including Blood Cells And Cells Of The Immune System. Hematopoietic Stem Cells Lack Cell Markers Of Effector Cells (Lin-Negative). Lin-Negative Is Defined By Lacking One Or More Of The Following Cell Surface Markers: Cd2, Cd3 Epsilon, Cd4, Cd5 ,Cd8 Alpha Chain, Cd11B, Cd14, Cd19, Cd20, Cd56, Ly6G, Ter119.', public_source_id=21, created_by_id=1),
 CellType(uid='7hggmgo1', name='hepatocyte', ontology_id='CL:0000182', description='The Main Structural Component Of The Liver. They Are Specialized Epithelial Cells That Are Organized Into Interconnected Plates Called Lobules. Majority Of Cell Population Of Liver, Polygonal In Shape, Arranged In Plates Or Trabeculae Between Sinusoids; May Have Single Nucleus Or Binucleated.', public_source_id=21, created_by_id=1)]

Logging informed us that 3 cell types were validated. Since we loaded these records at the same time, we could readily use them to annotate a dataset.

What happened under-the-hood?

.from_values() performs the following look ups:

  1. If registry records match the values, load these records

  2. If values match synonyms of registry records, load these records

  3. (bionty-only) If no record in the registry matches, attempt to load records from a public reference

  4. (bionty-only) Same as 3. but based on synonyms

No records will be returned if input field values aren’t mappable.

Example:

celltype_names = [
    "gamma-delta T cell",  # existing record with the same name
    "T lymphocyte",  # existing record with synonym
    "hepatocyte",  # public record with the same name
    "HSC",  # public record with synonym
    "my new cell type",  # Not exist in in-house registry, not exist in public reference
]
bionty.CellType.from_values(celltype_names)

This returns records for all names except from β€œmy new cell type”.

If you’d like to add this new value to the registry, do it like so:

my_celltype = bionty.CellType(name="my new cell type")
my_celltype.save()

Alternatively, we can create entries based on ontology ids:

adata.obs.cell_type_id.unique().tolist()
['CL:0000084', 'CL:0000037', 'CL:0000182', '']
bt.CellType.from_values(adata.obs.cell_type_id, field=bt.CellType.ontology_id)
βœ… loaded 1 CellType record matching ontology_id: 'CL:0000084'
βœ… created 2 CellType records from Bionty matching ontology_id: 'CL:0000182', 'CL:0000037'
[CellType(uid='22LvKd01', name='T cell', ontology_id='CL:0000084', synonyms='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=2024-05-01 18:48:53 UTC, public_source_id=21, created_by_id=1),
 CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', synonyms='hemopoietic stem cell|blood forming stem cell', description='A Stem Cell From Which All Cells Of The Lymphoid And Myeloid Lineages Develop, Including Blood Cells And Cells Of The Immune System. Hematopoietic Stem Cells Lack Cell Markers Of Effector Cells (Lin-Negative). Lin-Negative Is Defined By Lacking One Or More Of The Following Cell Surface Markers: Cd2, Cd3 Epsilon, Cd4, Cd5 ,Cd8 Alpha Chain, Cd11B, Cd14, Cd19, Cd20, Cd56, Ly6G, Ter119.', public_source_id=21, created_by_id=1),
 CellType(uid='7hggmgo1', name='hepatocyte', ontology_id='CL:0000182', description='The Main Structural Component Of The Liver. They Are Specialized Epithelial Cells That Are Organized Into Interconnected Plates Called Lobules. Majority Of Cell Population Of Liver, Polygonal In Shape, Arranged In Plates Or Trabeculae Between Sinusoids; May Have Single Nucleus Or Binucleated.', public_source_id=21, created_by_id=1)]

If we’re happy with cell_types records, we save them to the registry:

ln.save(cell_types)
Hide code cell output
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ also saving parents of CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', synonyms='hemopoietic stem cell|blood forming stem cell', description='A Stem Cell From Which All Cells Of The Lymphoid And Myeloid Lineages Develop, Including Blood Cells And Cells Of The Immune System. Hematopoietic Stem Cells Lack Cell Markers Of Effector Cells (Lin-Negative). Lin-Negative Is Defined By Lacking One Or More Of The Following Cell Surface Markers: Cd2, Cd3 Epsilon, Cd4, Cd5 ,Cd8 Alpha Chain, Cd11B, Cd14, Cd19, Cd20, Cd56, Ly6G, Ter119.', updated_at=2024-05-01 18:49:01 UTC, public_source_id=21, created_by_id=1)
βœ… created 3 CellType records from Bionty matching ontology_id: 'CL:0008001', 'CL:0000723', 'CL:0011026'
πŸ’‘ also saving parents of CellType(uid='5fX4hLCd', name='progenitor cell', ontology_id='CL:0011026', description='A Precursor Cell That Has A Tendency To Differentiate Into A Specific Type Of Cell. They Are Descendants Of Stem Cells, Only They Are More Constrained In Their Differentiation Potential Or Capacity For Self-Renewal, And Are Often More Limited In Both Senses.', updated_at=2024-05-01 18:49:02 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0011115'
πŸ’‘ also saving parents of CellType(uid='5J0ndawv', name='precursor cell', ontology_id='CL:0011115', description='A Cell That, By Division Or Terminal Differentiation, Can Give Rise To Other Cell Types.', updated_at=2024-05-01 18:49:02 UTC, public_source_id=21, created_by_id=1)
πŸ’‘ also saving parents of CellType(uid='2Dvf9ly5', name='somatic stem cell', ontology_id='CL:0000723', description='A Stem Cell That Can Give Rise To Cell Types Of The Body Other Than Those Of The Germ-Line.', updated_at=2024-05-01 18:49:02 UTC, public_source_id=21, created_by_id=1)
βœ… loaded 1 CellType record matching ontology_id: 'CL:0002371'
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000034'
πŸ’‘ also saving parents of CellType(uid='jxDD8ajD', name='stem cell', ontology_id='CL:0000034', synonyms='animal stem cell', description='A Relatively Undifferentiated Cell That Retains The Ability To Divide And Proliferate Throughout Life To Provide Progenitor Cells That Can Differentiate Into Specialized Cells.', updated_at=2024-05-01 18:49:03 UTC, public_source_id=21, created_by_id=1)
πŸ’‘ also saving parents of CellType(uid='5M0BT5FC', name='hematopoietic precursor cell', ontology_id='CL:0008001', description='Any Hematopoietic Cell That Is A Precursor Of Some Other Hematopoietic Cell Type.', updated_at=2024-05-01 18:49:02 UTC, public_source_id=21, created_by_id=1)
πŸ’‘ also saving parents of CellType(uid='7hggmgo1', name='hepatocyte', ontology_id='CL:0000182', description='The Main Structural Component Of The Liver. They Are Specialized Epithelial Cells That Are Organized Into Interconnected Plates Called Lobules. Majority Of Cell Population Of Liver, Polygonal In Shape, Arranged In Plates Or Trabeculae Between Sinusoids; May Have Single Nucleus Or Binucleated.', updated_at=2024-05-01 18:49:01 UTC, public_source_id=21, created_by_id=1)
βœ… loaded 1 CellType record matching ontology_id: 'CL:0002371'
βœ… created 2 CellType records from Bionty matching ontology_id: 'CL:0000066', 'CL:0000417'
πŸ’‘ also saving parents of CellType(uid='68LNvDH7', name='epithelial cell', ontology_id='CL:0000066', synonyms='epitheliocyte', 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=2024-05-01 18:49:04 UTC, public_source_id=21, created_by_id=1)
πŸ’‘ also saving parents of CellType(uid='M3aRHlL9', name='endopolyploid cell', ontology_id='CL:0000417', updated_at=2024-05-01 18:49:04 UTC, public_source_id=21, created_by_id=1)
βœ… created 1 CellType record from Bionty matching ontology_id: 'CL:0000412'
πŸ’‘ also saving parents of CellType(uid='1035XQsH', name='polyploid cell', ontology_id='CL:0000412', description='A Cell Whose Nucleus, Or Nuclei, Each Contain More Than Two Haploid Genomes.', updated_at=2024-05-01 18:49:04 UTC, public_source_id=21, created_by_id=1)

Now, let’s inspect our in-house registry:

bt.CellType.df()
Hide code cell output
uid name ontology_id abbr synonyms description public_source_id created_at updated_at created_by_id
id
25 1035XQsH polyploid cell CL:0000412 None None A Cell Whose Nucleus, Or Nuclei, Each Contain ... 21.0 2024-05-01 18:49:04.521787+00:00 2024-05-01 18:49:04.521817+00:00 1
24 M3aRHlL9 endopolyploid cell CL:0000417 None None None 21.0 2024-05-01 18:49:04.013774+00:00 2024-05-01 18:49:04.013789+00:00 1
23 68LNvDH7 epithelial cell CL:0000066 None epitheliocyte A Cell That Is Usually Found In A Two-Dimensio... 21.0 2024-05-01 18:49:04.013630+00:00 2024-05-01 18:49:04.013658+00:00 1
22 jxDD8ajD stem cell CL:0000034 None animal stem cell A Relatively Undifferentiated Cell That Retain... 21.0 2024-05-01 18:49:03.419410+00:00 2024-05-01 18:49:03.419454+00:00 1
21 5J0ndawv precursor cell CL:0011115 None None A Cell That, By Division Or Terminal Different... 21.0 2024-05-01 18:49:02.926329+00:00 2024-05-01 18:49:02.926360+00:00 1
20 5M0BT5FC hematopoietic precursor cell CL:0008001 None None Any Hematopoietic Cell That Is A Precursor Of ... 21.0 2024-05-01 18:49:02.306942+00:00 2024-05-01 18:49:02.306957+00:00 1
19 2Dvf9ly5 somatic stem cell CL:0000723 None None A Stem Cell That Can Give Rise To Cell Types O... 21.0 2024-05-01 18:49:02.306815+00:00 2024-05-01 18:49:02.306831+00:00 1
18 5fX4hLCd progenitor cell CL:0011026 None None A Precursor Cell That Has A Tendency To Differ... 21.0 2024-05-01 18:49:02.306664+00:00 2024-05-01 18:49:02.306694+00:00 1
17 7hggmgo1 hepatocyte CL:0000182 None None The Main Structural Component Of The Liver. Th... 21.0 2024-05-01 18:49:01.704869+00:00 2024-05-01 18:49:01.704885+00:00 1
16 2U8xapxu hematopoietic stem cell CL:0000037 None hemopoietic stem cell|blood forming stem cell A Stem Cell From Which All Cells Of The Lympho... 21.0 2024-05-01 18:49:01.704708+00:00 2024-05-01 18:49:01.704740+00:00 1
15 1HuNn2EP gamma-delta T cell CL:0000798 None gamma-delta T lymphocyte|gamma-delta T-lymphoc... None 21.0 2024-05-01 18:48:59.651294+00:00 2024-05-01 18:48:59.651323+00:00 1
14 2eNGzkOc my T cell subtype None None None None NaN 2024-05-01 18:48:58.332191+00:00 2024-05-01 18:48:58.332220+00:00 1
13 4WnpvUTH eukaryotic cell CL:0000255 None None None 21.0 2024-05-01 18:48:58.241622+00:00 2024-05-01 18:48:58.241650+00:00 1
12 2FCw82aH animal cell CL:0000548 None metazoan cell A Native Cell That Is Part Of Some Metazoa. 21.0 2024-05-01 18:48:57.602972+00:00 2024-05-01 18:48:57.603003+00:00 1
11 1ivhjCnJ somatic cell CL:0002371 None None A Cell Of An Organism That Does Not Pass On It... 21.0 2024-05-01 18:48:56.991369+00:00 2024-05-01 18:48:56.991398+00:00 1
10 4bKGljt0 cell CL:0000000 None None A Material Entity Of Anatomical Origin (Part O... 21.0 2024-05-01 18:48:56.509419+00:00 2024-05-01 18:48:56.509447+00:00 1
9 1AtefLrT native cell CL:0000003 None None A Cell That Is Found In A Natural Setting, Whi... 21.0 2024-05-01 18:48:55.917214+00:00 2024-05-01 18:48:55.917244+00:00 1
8 4Ilrnj9U hematopoietic cell CL:0000988 None haematopoietic cell|hemopoietic cell|haemopoie... A Cell Of A Hematopoietic Lineage. 21.0 2024-05-01 18:48:55.461582+00:00 2024-05-01 18:48:55.461596+00:00 1
7 u3sr1Gdf nucleate cell CL:0002242 None None A Cell Containing At Least One Nucleus. 21.0 2024-05-01 18:48:55.461455+00:00 2024-05-01 18:48:55.461471+00:00 1
6 2K93w3xO motile cell CL:0000219 None None A Cell That Moves By Its Own Activities. 21.0 2024-05-01 18:48:55.461305+00:00 2024-05-01 18:48:55.461335+00:00 1
5 2cXC7cgF single nucleate cell CL:0000226 None None A Cell With A Single Nucleus. 21.0 2024-05-01 18:48:54.887431+00:00 2024-05-01 18:48:54.887447+00:00 1
4 3VEAlFdi leukocyte CL:0000738 None white blood cell|leucocyte An Achromatic Cell Of The Myeloid Or Lymphoid ... 21.0 2024-05-01 18:48:54.887285+00:00 2024-05-01 18:48:54.887313+00:00 1
3 2Jgr5Xx4 mononuclear cell CL:0000842 None mononuclear leukocyte A Leukocyte With A Single Non-Segmented Nucleu... 21.0 2024-05-01 18:48:54.286167+00:00 2024-05-01 18:48:54.286226+00:00 1
2 X6c7osZ5 lymphocyte CL:0000542 None None A Lymphocyte Is A Leukocyte Commonly Found In ... 21.0 2024-05-01 18:48:53.773354+00:00 2024-05-01 18:48:53.773385+00:00 1
1 22LvKd01 T cell CL:0000084 None T-cell|T-lymphocyte|T lymphocyte A Type Of Lymphocyte Whose Defining Characteri... 21.0 2024-05-01 18:48:53.206602+00:00 2024-05-01 18:48:53.206632+00:00 1

Access records in in-house ontologies#

Search:

bt.CellType.search("gamma delta T cell").head(2)
uid synonyms score
name
gamma-delta T cell 1HuNn2EP gamma-delta T lymphocyte|gamma-delta T-lymphoc... 100.0
stem cell jxDD8ajD animal stem cell 64.7

Or look up with auto-complete:

cell_types = bt.CellType.lookup()
hsc_record = cell_types.hematopoietic_stem_cell

hsc_record
CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', synonyms='hemopoietic stem cell|blood forming stem cell', description='A Stem Cell From Which All Cells Of The Lymphoid And Myeloid Lineages Develop, Including Blood Cells And Cells Of The Immune System. Hematopoietic Stem Cells Lack Cell Markers Of Effector Cells (Lin-Negative). Lin-Negative Is Defined By Lacking One Or More Of The Following Cell Surface Markers: Cd2, Cd3 Epsilon, Cd4, Cd5 ,Cd8 Alpha Chain, Cd11B, Cd14, Cd19, Cd20, Cd56, Ly6G, Ter119.', updated_at=2024-05-01 18:49:01 UTC, public_source_id=21, created_by_id=1)

Validate & standardize#

Simple validation of an iterable of values works like so:

bt.CellType.validate(["HSC", "blood forming stem cell"])
❗ 2 terms (100.00%) are not validated for name: HSC, blood forming stem cell
array([False, False])

Because these values don’t comply with the registry, they’re not validated!

You can easily convert these values to validated standardized names based on synonyms like so:

bt.CellType.standardize(["HSC", "blood forming stem cell"])
πŸ’‘ standardized 1/2 terms
['HSC', 'hematopoietic stem cell']

Alternatively, you can use .from_values(), which will only ever create validated records and automatically standardize under-the-hood:

bt.CellType.from_values(["HSC", "blood forming stem cell"])
βœ… loaded 1 CellType record matching synonyms: 'blood forming stem cell'
❗ did not create CellType record for 1 non-validated name: 'HSC'
[CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', synonyms='hemopoietic stem cell|blood forming stem cell', description='A Stem Cell From Which All Cells Of The Lymphoid And Myeloid Lineages Develop, Including Blood Cells And Cells Of The Immune System. Hematopoietic Stem Cells Lack Cell Markers Of Effector Cells (Lin-Negative). Lin-Negative Is Defined By Lacking One Or More Of The Following Cell Surface Markers: Cd2, Cd3 Epsilon, Cd4, Cd5 ,Cd8 Alpha Chain, Cd11B, Cd14, Cd19, Cd20, Cd56, Ly6G, Ter119.', updated_at=2024-05-01 18:49:01 UTC, public_source_id=21, created_by_id=1)]

We can also add new synonyms to a record like so:

hsc_record.add_synonym("HSCs")

And when we encounter this synonym as a value, it will now be standardized using synonyms-lookup, and mapped on the correct registry record:

bt.CellType.standardize(["HSCs"])
πŸ’‘ standardized 1/1 terms
['hematopoietic stem cell']

A special synonym is .abbr (short for abbreviation), which has its own field and can be assigned via:

hsc_record.set_abbr("HSC")

You can create a lookup object from the .abbr field:

cell_types = bt.CellType.lookup("abbr")
hsc = cell_types.hsc
hsc
CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', abbr='HSC', synonyms='HSCs|hemopoietic stem cell|blood forming stem cell|HSC', description='A Stem Cell From Which All Cells Of The Lymphoid And Myeloid Lineages Develop, Including Blood Cells And Cells Of The Immune System. Hematopoietic Stem Cells Lack Cell Markers Of Effector Cells (Lin-Negative). Lin-Negative Is Defined By Lacking One Or More Of The Following Cell Surface Markers: Cd2, Cd3 Epsilon, Cd4, Cd5 ,Cd8 Alpha Chain, Cd11B, Cd14, Cd19, Cd20, Cd56, Ly6G, Ter119.', updated_at=2024-05-01 18:49:05 UTC, public_source_id=21, created_by_id=1)

The same workflow works for all of bionty’s registries.

Manage registries across organism#

Most registries are organism-aware, for instance, Gene:

bt.Gene.from_public(symbol="TCF7", organism="human")
βœ… created 1 Gene record from Bionty matching symbol: 'TCF7'
Gene(uid='7IkHKPl0ScQR', symbol='TCF7', ensembl_gene_id='ENSG00000081059', ncbi_gene_ids='6932', biotype='protein_coding', description='transcription factor 7 ', synonyms='TCF-1', organism_id=1, public_source_id=9, created_by_id=1)

Similarly, API calls that interact with multi-organism registries accept a organism argument, e.g.:

bt.Gene.validate(["TCF7", "ABC1"], organism="human")
Hide code cell output
❗ 2 terms (100.00%) are not validated for symbol: TCF7, ABC1
array([False, False])

You can also pass organism for validating features upon registering data, e.g., in ln.Artifact.from_anndata(..., field=bionty.Gene.ensembl_gene_id, organism=...).

And when working with the same organism throughout your analysis/workflow, you can omit the organism argument by configuring it globally:

bt.settings.organism = "mouse"
bt.Gene.from_public(symbol="Ap5b1")
βœ… created 1 Gene record from Bionty matching symbol: 'Ap5b1'
Gene(uid='3b8mHb0MRal4', symbol='Ap5b1', ensembl_gene_id='ENSMUSG00000049562', ncbi_gene_ids='381201', biotype='protein_coding', description='adaptor-related protein complex 5, beta 1 subunit ', synonyms='Gm962', organism_id=2, public_source_id=11, created_by_id=1)

Track underlying ontology versions#

Under-the-hood, source ontology versions are automatically tracked:

bt.PublicSource.filter(currently_used=True).df()
Hide code cell output
uid entity organism currently_used source source_name version url md5 source_website created_at updated_at created_by_id
id
1 6IUo Organism vertebrates True ensembl Ensembl release-110 https://ftp.ensembl.org/pub/release-110/specie... f3faf95648d3a2b50fd3625456739706 https://www.ensembl.org 2024-05-01 18:48:50.087381+00:00 2024-05-01 18:48:50.087406+00:00 1
4 2Jzh Organism bacteria True ensembl Ensembl release-57 https://ftp.ensemblgenomes.ebi.ac.uk/pub/bacte... ee28510ed5586ea7ab4495717c96efc8 https://www.ensembl.org 2024-05-01 18:48:50.087836+00:00 2024-05-01 18:48:50.087850+00:00 1
5 1kdI Organism fungi True ensembl Ensembl release-57 http://ftp.ensemblgenomes.org/pub/fungi/releas... dbcde58f4396ab8b2480f7fe9f83df8a https://www.ensembl.org 2024-05-01 18:48:50.087973+00:00 2024-05-01 18:48:50.087986+00:00 1
6 2mIM Organism metazoa True ensembl Ensembl release-57 http://ftp.ensemblgenomes.org/pub/metazoa/rele... 424636a574fec078a61cbdddb05f9132 https://www.ensembl.org 2024-05-01 18:48:50.088109+00:00 2024-05-01 18:48:50.088122+00:00 1
7 2XQ6 Organism plants True ensembl Ensembl release-57 https://ftp.ensemblgenomes.ebi.ac.uk/pub/plant... eadaa1f3e527e4c3940c90c7fa5c8bf4 https://www.ensembl.org 2024-05-01 18:48:50.088244+00:00 2024-05-01 18:48:50.088258+00:00 1
8 1Vzs Organism all True ncbitaxon NCBItaxon Ontology 2023-06-20 s3://bionty-assets/df_all__ncbitaxon__2023-06-... 00d97ba65627f1cd65636d2df22ea76c https://github.com/obophenotype/ncbitaxon 2024-05-01 18:48:50.088380+00:00 2024-05-01 18:48:50.088393+00:00 1
9 4yVc Gene human True ensembl Ensembl release-110 s3://bionty-assets/df_human__ensembl__release-... 832f3947e83664588d419608a469b528 https://www.ensembl.org 2024-05-01 18:48:50.088515+00:00 2024-05-01 18:48:50.088528+00:00 1
11 2akp Gene mouse True ensembl Ensembl release-110 s3://bionty-assets/df_mouse__ensembl__release-... fa4ce130f2929aefd7ac3bc8eaf0c4de https://www.ensembl.org 2024-05-01 18:48:50.088783+00:00 2024-05-01 18:48:50.088797+00:00 1
13 2UvD Gene saccharomyces cerevisiae True ensembl Ensembl release-110 s3://bionty-assets/df_saccharomyces cerevisiae... 2e59495a3e87ea6575e408697dd73459 https://www.ensembl.org 2024-05-01 18:48:50.089052+00:00 2024-05-01 18:48:50.089065+00:00 1
14 7llW Protein human True uniprot Uniprot 2023-03 s3://bionty-assets/df_human__uniprot__2023-03_... 1c46e85c6faf5eff3de5b4e1e4edc4d3 https://www.uniprot.org 2024-05-01 18:48:50.089185+00:00 2024-05-01 18:48:50.089198+00:00 1
16 5U7J Protein mouse True uniprot Uniprot 2023-03 s3://bionty-assets/df_mouse__uniprot__2023-03_... 9d5e9a8225011d3218e10f9bbb96a46c https://www.uniprot.org 2024-05-01 18:48:50.089454+00:00 2024-05-01 18:48:50.089467+00:00 1
18 5nkB CellMarker human True cellmarker CellMarker 2.0 s3://bionty-assets/human_cellmarker_2.0_CellMa... d565d4a542a5c7e7a06255975358e4f4 http://bio-bigdata.hrbmu.edu.cn/CellMarker 2024-05-01 18:48:50.089722+00:00 2024-05-01 18:48:50.089735+00:00 1
19 6AFz CellMarker mouse True cellmarker CellMarker 2.0 s3://bionty-assets/mouse_cellmarker_2.0_CellMa... 189586732c63be949e40dfa6a3636105 http://bio-bigdata.hrbmu.edu.cn/CellMarker 2024-05-01 18:48:50.089856+00:00 2024-05-01 18:48:50.089869+00:00 1
20 6cbC CellLine all True clo Cell Line Ontology 2022-03-21 https://data.bioontology.org/ontologies/CLO/su... ea58a1010b7e745702a8397a526b3a33 https://bioportal.bioontology.org/ontologies/CLO 2024-05-01 18:48:50.089990+00:00 2024-05-01 18:48:50.090003+00:00 1
21 6tvq CellType all True cl Cell Ontology 2023-08-24 http://purl.obolibrary.org/obo/cl/releases/202... 46e7dd89421f1255cf0191eca1548f73 https://obophenotype.github.io/cell-ontology 2024-05-01 18:48:50.090124+00:00 2024-05-01 18:48:50.090137+00:00 1
25 1PY3 Tissue all True uberon Uberon multi-species anatomy ontology 2023-09-05 http://purl.obolibrary.org/obo/uberon/releases... abcee3ede566d1311d758b853ccdf5aa http://obophenotype.github.io/uberon 2024-05-01 18:48:50.090695+00:00 2024-05-01 18:48:50.090708+00:00 1
29 6EOm Disease all True mondo Mondo Disease Ontology 2023-08-02 http://purl.obolibrary.org/obo/mondo/releases/... 7f33767422042eec29f08b501fc851db https://mondo.monarchinitiative.org 2024-05-01 18:48:50.091234+00:00 2024-05-01 18:48:50.091247+00:00 1
33 3V9D Disease human True doid Human Disease Ontology 2023-03-31 http://purl.obolibrary.org/obo/doid/releases/2... 64f083a1e47867c307c8eae308afc3bb https://disease-ontology.org 2024-05-01 18:48:50.091778+00:00 2024-05-01 18:48:50.091791+00:00 1
39 6fKX ExperimentalFactor all True efo The Experimental Factor Ontology 3.57.0 http://www.ebi.ac.uk/efo/releases/v3.57.0/efo.owl 2ecafc69b3aba7bdb31ad99438505c05 https://bioportal.bioontology.org/ontologies/EFO 2024-05-01 18:48:50.092594+00:00 2024-05-01 18:48:50.092607+00:00 1
41 6jHz Phenotype human True hp Human Phenotype Ontology 2023-06-17 https://github.com/obophenotype/human-phenotyp... 65e8d96bc81deb893163927063b10c06 https://hpo.jax.org 2024-05-01 18:48:50.092867+00:00 2024-05-01 18:48:50.092880+00:00 1
44 4q5A Phenotype mammalian True mp Mammalian Phenotype Ontology 2023-05-31 https://github.com/mgijax/mammalian-phenotype-... be89052cf6d9c0b6197038fe347ef293 https://github.com/mgijax/mammalian-phenotype-... 2024-05-01 18:48:50.093275+00:00 2024-05-01 18:48:50.093288+00:00 1
45 6Czy Phenotype zebrafish True zp Zebrafish Phenotype Ontology 2022-12-17 https://github.com/obophenotype/zebrafish-phen... 03430b567bf153216c0fa4c3440b3b24 https://github.com/obophenotype/zebrafish-phen... 2024-05-01 18:48:50.093411+00:00 2024-05-01 18:48:50.093424+00:00 1
47 55lY Phenotype all True pato Phenotype And Trait Ontology 2023-05-18 http://purl.obolibrary.org/obo/pato/releases/2... bd472f4971492109493d4ad8a779a8dd https://github.com/pato-ontology/pato 2024-05-01 18:48:50.093684+00:00 2024-05-01 18:48:50.093697+00:00 1
48 48aa Pathway all True go Gene Ontology 2023-05-10 https://data.bioontology.org/ontologies/GO/sub... e9845499eadaef2418f464cd7e9ac92e http://geneontology.org 2024-05-01 18:48:50.093823+00:00 2024-05-01 18:48:50.093836+00:00 1
50 3rm9 BFXPipeline all True lamin Bioinformatics Pipeline 1.0.0 s3://bionty-assets/bfxpipelines.json a7eff57a256994692fba46e0199ffc94 https://lamin.ai 2024-05-01 18:48:50.094099+00:00 2024-05-01 18:48:50.094113+00:00 1
51 3TI0 Drug all True dron Drug Ontology 2023-03-10 https://data.bioontology.org/ontologies/DRON/s... 75e86011158fae76bb46d96662a33ba3 https://bioportal.bioontology.org/ontologies/DRON 2024-05-01 18:48:50.094254+00:00 2024-05-01 18:48:50.094270+00:00 1
52 7CRn DevelopmentalStage human True hsapdv Human Developmental Stages 2020-03-10 http://aber-owl.net/media/ontologies/HSAPDV/11... 52181d59df84578ed69214a5cb614036 https://github.com/obophenotype/developmental-... 2024-05-01 18:48:50.094406+00:00 2024-05-01 18:48:50.094419+00:00 1
53 16tR DevelopmentalStage mouse True mmusdv Mouse Developmental Stages 2020-03-10 http://aber-owl.net/media/ontologies/MMUSDV/9/... 5bef72395d853c7f65450e6c2a1fc653 https://github.com/obophenotype/developmental-... 2024-05-01 18:48:50.094544+00:00 2024-05-01 18:48:50.094557+00:00 1
54 3Tlc Ethnicity human True hancestro Human Ancestry Ontology 3.0 https://github.com/EBISPOT/hancestro/raw/3.0/h... 76dd9efda9c2abd4bc32fc57c0b755dd https://github.com/EBISPOT/hancestro 2024-05-01 18:48:50.094682+00:00 2024-05-01 18:48:50.094695+00:00 1
55 5JnV BioSample all True ncbi NCBI BioSample attributes 2023-09 s3://bionty-assets/df_all__ncbi__2023-09__BioS... 918db9bd1734b97c596c67d9654a4126 https://www.ncbi.nlm.nih.gov/biosample/docs/at... 2024-05-01 18:48:50.094818+00:00 2024-05-01 18:48:50.094831+00:00 1

Each record is linked to a versioned public source (if it was created from public):

hepatocyte = bt.CellType.filter(name="hepatocyte").one()
hepatocyte.public_source
PublicSource(uid='6tvq', entity='CellType', organism='all', currently_used=True, source='cl', source_name='Cell Ontology', version='2023-08-24', url='http://purl.obolibrary.org/obo/cl/releases/2023-08-24/cl.owl', md5='46e7dd89421f1255cf0191eca1548f73', source_website='https://obophenotype.github.io/cell-ontology', updated_at=2024-05-01 18:48:50 UTC, created_by_id=1)

Create records from specific public ontologies#

By default, records are created from the "currently_used" public sources which are configured during the instance initialization, e.g.:

bt.Phenotype.public()
PublicOntology
Entity: Phenotype
Organism: human
Source: hp, 2023-06-17
#terms: 17653

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

Sometimes, the default source doesn’t contain the ontology term you are looking for.

You can then specify to create a record from a non-default source. For instance, instead of using untyped labels for iris organisms as Tutorial: Features & labels, we can use the ncbitaxon ontology:

public_source = bt.PublicSource.filter(entity="Organism", source="ncbitaxon").one()
iris_setosa = bt.Organism.from_public(name="iris setosa", public_source=public_source)
iris_setosa.save()
Hide code cell output


βœ… created 1 Organism record from Bionty matching name: 'iris setosa'
πŸ’‘ also saving parents of Organism(uid='6TR5Sp4r', name='iris setosa', ontology_id='NCBITaxon:198825', scientific_name='Iris setosa', updated_at=2024-05-01 18:49:24 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:26378'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ also saving parents of Organism(uid='5nYgMCPV', name='iris', ontology_id='NCBITaxon:26378', scientific_name='Iris <monocots>', updated_at=2024-05-01 18:49:34 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:2508073'
πŸ’‘ also saving parents of Organism(uid='7deGQdx4', name='irideae', ontology_id='NCBITaxon:2508073', scientific_name='Irideae', updated_at=2024-05-01 18:49:45 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:2507920'
πŸ’‘ also saving parents of Organism(uid='4zKlR7zE', name='iridoideae', ontology_id='NCBITaxon:2507920', scientific_name='Iridoideae', updated_at=2024-05-01 18:49:56 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:26339'
πŸ’‘ also saving parents of Organism(uid='38kEjqnG', name='iris family', ontology_id='NCBITaxon:26339', scientific_name='Iridaceae', updated_at=2024-05-01 18:50:07 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:73496'
πŸ’‘ also saving parents of Organism(uid='6HG6Arqo', name='asparagales', ontology_id='NCBITaxon:73496', scientific_name='Asparagales', updated_at=2024-05-01 18:50:18 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:1437197'
πŸ’‘ also saving parents of Organism(uid='77aWJKiu', name='petrosaviidae', ontology_id='NCBITaxon:1437197', scientific_name='Petrosaviidae', updated_at=2024-05-01 18:50:28 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:4447'
πŸ’‘ also saving parents of Organism(uid='F9UPuTZZ', name='monocots', ontology_id='NCBITaxon:4447', scientific_name='Liliopsida', updated_at=2024-05-01 18:50:40 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:1437183'
πŸ’‘ also saving parents of Organism(uid='4xpUY0O2', name='mesangiospermae', ontology_id='NCBITaxon:1437183', scientific_name='Mesangiospermae', updated_at=2024-05-01 18:50:50 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:3398'
πŸ’‘ also saving parents of Organism(uid='5PgnUVAF', name='angiosperms', ontology_id='NCBITaxon:3398', scientific_name='Magnoliopsida', updated_at=2024-05-01 18:51:01 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:58024'
πŸ’‘ also saving parents of Organism(uid='7FSKVYNz', name='seed plants', ontology_id='NCBITaxon:58024', scientific_name='Spermatophyta', updated_at=2024-05-01 18:51:12 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:78536'
πŸ’‘ also saving parents of Organism(uid='1XDBk3DM', name='euphyllophytes', ontology_id='NCBITaxon:78536', scientific_name='Euphyllophyta', updated_at=2024-05-01 18:51:23 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:58023'
πŸ’‘ also saving parents of Organism(uid='3ojvStK5', name='vascular plants', ontology_id='NCBITaxon:58023', scientific_name='Tracheophyta', updated_at=2024-05-01 18:51:34 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:3193'
πŸ’‘ also saving parents of Organism(uid='b95VeaBX', name='plants', ontology_id='NCBITaxon:3193', scientific_name='Embryophyta', updated_at=2024-05-01 18:51:45 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:131221'
πŸ’‘ also saving parents of Organism(uid='GguvaRrK', name='charophyte/embryophyte group', ontology_id='NCBITaxon:131221', scientific_name='Streptophytina', updated_at=2024-05-01 18:51:56 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:35493'
πŸ’‘ also saving parents of Organism(uid='5puME4C8', name='streptophyta', ontology_id='NCBITaxon:35493', scientific_name='Streptophyta', updated_at=2024-05-01 18:52:07 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:33090'
πŸ’‘ also saving parents of Organism(uid='3oxzSlnK', name='green plants', ontology_id='NCBITaxon:33090', scientific_name='Viridiplantae', updated_at=2024-05-01 18:52:17 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:2759'
πŸ’‘ also saving parents of Organism(uid='obreunKV', name='eukaryotes', ontology_id='NCBITaxon:2759', scientific_name='Eukaryota', updated_at=2024-05-01 18:52:28 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:131567'
πŸ’‘ also saving parents of Organism(uid='4BpEwmDD', name='cellular organisms', ontology_id='NCBITaxon:131567', scientific_name='cellular organisms', updated_at=2024-05-01 18:52:39 UTC, public_source_id=8, created_by_id=1)
βœ… created 1 Organism record from Bionty matching ontology_id: 'NCBITaxon:1'
iris_setosa
Organism(uid='6TR5Sp4r', name='iris setosa', ontology_id='NCBITaxon:198825', scientific_name='Iris setosa', updated_at=2024-05-01 18:49:24 UTC, public_source_id=8, created_by_id=1)
iris_setosa.public_source
PublicSource(uid='1Vzs', entity='Organism', organism='all', currently_used=True, source='ncbitaxon', source_name='NCBItaxon Ontology', version='2023-06-20', url='s3://bionty-assets/df_all__ncbitaxon__2023-06-20__Organism.parquet', md5='00d97ba65627f1cd65636d2df22ea76c', source_website='https://github.com/obophenotype/ncbitaxon', updated_at=2024-05-01 18:48:50 UTC, created_by_id=1)
iris_setosa.parents.df()
uid name ontology_id scientific_name public_source_id created_at updated_at created_by_id
id
4 5nYgMCPV iris NCBITaxon:26378 Iris <monocots> 8 2024-05-01 18:49:34.615837+00:00 2024-05-01 18:49:34.615879+00:00 1

Analogously, you can pass public_source to bulk-create records from a non-default source:

records = bt.Organism.from_values(
    ["iris setosa", "iris versicolor", "iris virginica"], public_source=public_source
)
ln.save(records)
Hide code cell output
βœ… loaded 1 Organism record matching name: 'iris setosa'
βœ… created 2 Organism records from Bionty matching name: 'iris virginica', 'iris versicolor'
❗ now recursing through parents: this only happens once, but is much slower than bulk saving
πŸ’‘ also saving parents of Organism(uid='3aySHUU9', name='iris versicolor', ontology_id='NCBITaxon:585827', scientific_name='Iris versicolor', updated_at=2024-05-01 18:53:03 UTC, public_source_id=8, created_by_id=1)
πŸ’‘ also saving parents of Organism(uid='3ez4JpPd', name='iris virginica', ontology_id='NCBITaxon:292533', scientific_name='Iris virginica', updated_at=2024-05-01 18:53:03 UTC, public_source_id=8, created_by_id=1)
records
[Organism(uid='6TR5Sp4r', name='iris setosa', ontology_id='NCBITaxon:198825', scientific_name='Iris setosa', updated_at=2024-05-01 18:49:24 UTC, public_source_id=8, created_by_id=1),
 Organism(uid='3aySHUU9', name='iris versicolor', ontology_id='NCBITaxon:585827', scientific_name='Iris versicolor', updated_at=2024-05-01 18:53:03 UTC, public_source_id=8, created_by_id=1),
 Organism(uid='3ez4JpPd', name='iris virginica', ontology_id='NCBITaxon:292533', scientific_name='Iris virginica', updated_at=2024-05-01 18:53:03 UTC, public_source_id=8, created_by_id=1)]
iris_setosa.parents.get(name="iris").view_parents(with_children=True)
_images/3174ae60153a8d75a3378e643a6eccc6106b7378d583c6017fdfb7759be08ebb.svg
Hide code cell content
# clean up test instance
!lamin delete --force test-registries
!rm -r test-registries
πŸ’‘ deleting instance testuser1/test-registries
πŸ’‘ not deleting instance from hub as instance not found there
rm: cannot remove 'test-registries': No such file or directory