Manage biological registries¶
With plug-in bionty
, it becomes easy to import records from public biological ontologies.
#! pip install 'lamindb[bionty]'
!lamin init --storage ./test-registries --schema bionty
Show code cell output
💡 connected lamindb: testuser1/test-registries
Let’s pre-populate the bionty.Organism
and bionty.CellType
registry with a few records:
import lamindb as ln
import bionty as bt
bt.Organism.from_public(name="human").save()
bt.CellType.from_public(name="T cell").save()
bt.CellType(name="my T cell subtype").save()
Show code cell output
💡 connected lamindb: testuser1/test-registries
❗ records with similar names exist! did you mean to load one of them?
uid | name | ontology_id | abbr | synonyms | description | source_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||
1 | 22LvKd01 | T cell | CL:0000084 | None | T-lymphocyte|T lymphocyte|T-cell | A Type Of Lymphocyte Whose Defining Characteri... | 31 | None | 1 | 2024-07-26 14:36:21.025040+00:00 |
2 | X6c7osZ5 | lymphocyte | CL:0000542 | None | None | A Lymphocyte Is A Leukocyte Commonly Found In ... | 31 | None | 1 | 2024-07-26 14:36:21.542279+00:00 |
3 | 4bKGljt0 | cell | CL:0000000 | None | None | A Material Entity Of Anatomical Origin (Part O... | 31 | None | 1 | 2024-07-26 14:36:21.904382+00:00 |
4 | 2K93w3xO | motile cell | CL:0000219 | None | None | A Cell That Moves By Its Own Activities. | 31 | None | 1 | 2024-07-26 14:36:21.904535+00:00 |
5 | 2cXC7cgF | single nucleate cell | CL:0000226 | None | None | A Cell With A Single Nucleus. | 31 | None | 1 | 2024-07-26 14:36:21.904674+00:00 |
6 | 4WnpvUTH | eukaryotic cell | CL:0000255 | None | None | None | 31 | None | 1 | 2024-07-26 14:36:21.904813+00:00 |
7 | 3VEAlFdi | leukocyte | CL:0000738 | None | white blood cell|leucocyte | An Achromatic Cell Of The Myeloid Or Lymphoid ... | 31 | None | 1 | 2024-07-26 14:36:21.904979+00:00 |
8 | 2Jgr5Xx4 | mononuclear cell | CL:0000842 | None | mononuclear leukocyte | A Leukocyte With A Single Non-Segmented Nucleu... | 31 | None | 1 | 2024-07-26 14:36:21.905116+00:00 |
9 | 4Ilrnj9U | hematopoietic cell | CL:0000988 | None | haematopoietic cell|hemopoietic cell|haemopoie... | A Cell Of A Hematopoietic Lineage. | 31 | None | 1 | 2024-07-26 14:36:21.905251+00:00 |
10 | u3sr1Gdf | nucleate cell | CL:0002242 | None | None | A Cell Containing At Least One Nucleus. | 31 | None | 1 | 2024-07-26 14:36:21.905385+00:00 |
CellType(uid='2eNGzkOc', name='my T cell subtype', created_by_id=1, updated_at='2024-07-26 14:36:21 UTC')
Access records in public ontologies¶
Consider a public ontology for cell types: .public()
returns a bionty.core.PublicOntology
object for accessing a public ontology.
public = bt.CellType.public()
public
PublicOntology
Entity: CellType
Organism: all
Source: cl, 2024-02-13
#terms: 2918
We can use it to search the public ontology against cell types:
public.search("gamma delta T cell").head(3)
Show code cell output
ontology_id | definition | synonyms | parents | __ratio__ | |
---|---|---|---|---|---|
name | |||||
gamma-delta T cell | CL:0000798 | A T Cell That Expresses A Gamma-Delta T Cell R... | gammadelta T cell|gamma-delta T-cell|gamma-del... | [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:0002419, CL:0000798] | 83.720930 |
Or to look up cell types with auto-complete:
lookup = public.lookup()
lookup.gamma_delta_t_cell
Show code cell output
CellType(ontology_id='CL:0000798', name='gamma-delta T cell', definition='A T Cell That Expresses A Gamma-Delta T Cell Receptor Complex.', synonyms='gammadelta T cell|gamma-delta T-cell|gamma-delta T lymphocyte|gamma-delta T-lymphocyte', 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
Show code cell output
❗ records with similar names exist! did you mean to load one of them?
uid | name | ontology_id | abbr | synonyms | description | source_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||
1 | 22LvKd01 | T cell | CL:0000084 | None | T-lymphocyte|T lymphocyte|T-cell | A Type Of Lymphocyte Whose Defining Characteri... | 31.0 | None | 1 | 2024-07-26 14:36:21.025040+00:00 |
3 | 4bKGljt0 | cell | CL:0000000 | None | None | A Material Entity Of Anatomical Origin (Part O... | 31.0 | None | 1 | 2024-07-26 14:36:21.904382+00:00 |
4 | 2K93w3xO | motile cell | CL:0000219 | None | None | A Cell That Moves By Its Own Activities. | 31.0 | None | 1 | 2024-07-26 14:36:21.904535+00:00 |
5 | 2cXC7cgF | single nucleate cell | CL:0000226 | None | None | A Cell With A Single Nucleus. | 31.0 | None | 1 | 2024-07-26 14:36:21.904674+00:00 |
6 | 4WnpvUTH | eukaryotic cell | CL:0000255 | None | None | None | 31.0 | None | 1 | 2024-07-26 14:36:21.904813+00:00 |
8 | 2Jgr5Xx4 | mononuclear cell | CL:0000842 | None | mononuclear leukocyte | A Leukocyte With A Single Non-Segmented Nucleu... | 31.0 | None | 1 | 2024-07-26 14:36:21.905116+00:00 |
9 | 4Ilrnj9U | hematopoietic cell | CL:0000988 | None | haematopoietic cell|hemopoietic cell|haemopoie... | A Cell Of A Hematopoietic Lineage. | 31.0 | None | 1 | 2024-07-26 14:36:21.905251+00:00 |
10 | u3sr1Gdf | nucleate cell | CL:0002242 | None | None | A Cell Containing At Least One Nucleus. | 31.0 | None | 1 | 2024-07-26 14:36:21.905385+00:00 |
11 | 2eNGzkOc | my T cell subtype | None | None | None | None | NaN | None | 1 | 2024-07-26 14:36:21.950634+00:00 |
CellType(uid='1HuNn2EP', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gammadelta T cell|gamma-delta T-cell|gamma-delta T lymphocyte|gamma-delta T-lymphocyte', created_by_id=1, source_id=31)
Alternatively, we can construct the gamma delta T cell via from_public()
, which is synonyms-aware:
bt.CellType.from_public(ontology_id="CL:0000798")
Show code cell output
CellType(uid='1HuNn2EP', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gammadelta T cell|gamma-delta T-cell|gamma-delta T lymphocyte|gamma-delta T-lymphocyte', description='A T Cell That Expresses A Gamma-Delta T Cell Receptor Complex.', created_by_id=1, source_id=31)
When we save this record to the registry, logging informs us that we’re also saving parent records:
gdt_cell.save()
Show code cell output
CellType(uid='1HuNn2EP', name='gamma-delta T cell', ontology_id='CL:0000798', synonyms='gammadelta T cell|gamma-delta T-cell|gamma-delta T lymphocyte|gamma-delta T-lymphocyte', created_by_id=1, source_id=31, updated_at='2024-07-26 14:36:23 UTC')
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()
Or access the parents directly:
gdt_cell.parents.df()
Show code cell output
uid | name | ontology_id | abbr | synonyms | description | source_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||
1 | 22LvKd01 | T cell | CL:0000084 | None | T-lymphocyte|T lymphocyte|T-cell | A Type Of Lymphocyte Whose Defining Characteri... | 31 | None | 1 | 2024-07-26 14:36:21.025040+00:00 |
You can construct custom hierarchies of records:
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)
This cell type and all its parents can now be queried & searched in the registry via bt.CellType.filter()
and bt.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, in the cell_type
annotations of this AnnData
object, we find 4 references to cell types:
adata = ln.core.datasets.anndata_with_obs()
adata.obs.cell_type.value_counts()
Show code cell output
cell_type
T cell 10
hematopoietic stem cell 10
hepatocyte 10
my new cell type 10
Name: count, 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
Show code cell output
❗ 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-lymphocyte|T lymphocyte|T-cell', description='A Type Of Lymphocyte Whose Defining Characteristic Is The Expression Of A T Cell Receptor Complex.', created_by_id=1, source_id=31, updated_at='2024-07-26 14:36:21 UTC'),
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.', created_by_id=1, source_id=31),
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.', created_by_id=1, source_id=31)]
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:
If registry records match the values, load these records
If values match synonyms of registry records, load these records
If no record in the registry matches, attempt to load records from a public ontology
Same as 3. but based on synonyms
No records will be returned if all 4 look ups are unsuccessful.
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()
Sometimes, it’s useful to treat validated records differently from non-validated records. Here is a way:
original_values = ["gut", "gut2"]
validated_status = bt.Tissue.validate(original_values)
validated_values = [value for value, validated in zip(original_values, validated_status) if validated]
records_from_validated_values = bt.Tissue.from_values(validated_values)
ln.save(records_from_validated_values)
Alternatively, we can create entries based on ontology ids:
adata.obs.cell_type_id.unique().tolist()
Show code cell output
['CL:0000084', 'CL:0000037', 'CL:0000182', '']
bt.CellType.from_values(adata.obs.cell_type_id, field=bt.CellType.ontology_id)
Show code cell output
[CellType(uid='22LvKd01', name='T cell', ontology_id='CL:0000084', synonyms='T-lymphocyte|T lymphocyte|T-cell', description='A Type Of Lymphocyte Whose Defining Characteristic Is The Expression Of A T Cell Receptor Complex.', created_by_id=1, source_id=31, updated_at='2024-07-26 14:36:21 UTC'),
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.', created_by_id=1, source_id=31),
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.', created_by_id=1, source_id=31)]
If we’re happy with the cell type records, we save them to the registry:
ln.save(cell_types)
Now, let’s look at our in-house registry:
bt.CellType.df()
Show code cell output
uid | name | ontology_id | abbr | synonyms | description | source_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||
22 | 5J0ndawv | precursor cell | CL:0011115 | None | None | A Cell That, By Division Or Terminal Different... | 31.0 | None | 1 | 2024-07-26 14:36:25.825331+00:00 |
21 | 5fX4hLCd | progenitor cell | CL:0011026 | None | None | A Precursor Cell That Has A Tendency To Differ... | 31.0 | None | 1 | 2024-07-26 14:36:25.825193+00:00 |
20 | 5M0BT5FC | hematopoietic precursor cell | CL:0008001 | None | None | Any Hematopoietic Cell That Is A Precursor Of ... | 31.0 | None | 1 | 2024-07-26 14:36:25.825055+00:00 |
19 | 2Dvf9ly5 | somatic stem cell | CL:0000723 | None | None | A Stem Cell That Can Give Rise To Cell Types O... | 31.0 | None | 1 | 2024-07-26 14:36:25.824908+00:00 |
18 | M3aRHlL9 | endopolyploid cell | CL:0000417 | None | None | None | 31.0 | None | 1 | 2024-07-26 14:36:25.824730+00:00 |
17 | 1035XQsH | polyploid cell | CL:0000412 | None | None | A Cell That Contains More Than Two Haploid Set... | 31.0 | None | 1 | 2024-07-26 14:36:25.824593+00:00 |
16 | 68LNvDH7 | epithelial cell | CL:0000066 | None | epitheliocyte | A Cell That Is Usually Found In A Two-Dimensio... | 31.0 | None | 1 | 2024-07-26 14:36:25.824453+00:00 |
15 | jxDD8ajD | stem cell | CL:0000034 | None | animal stem cell | A Relatively Undifferentiated Cell That Retain... | 31.0 | None | 1 | 2024-07-26 14:36:25.824300+00:00 |
14 | 7hggmgo1 | hepatocyte | CL:0000182 | None | None | The Main Structural Component Of The Liver. Th... | 31.0 | None | 1 | 2024-07-26 14:36:25.579329+00:00 |
13 | 2U8xapxu | hematopoietic stem cell | CL:0000037 | None | hemopoietic stem cell|blood forming stem cell | A Stem Cell From Which All Cells Of The Lympho... | 31.0 | None | 1 | 2024-07-26 14:36:25.579176+00:00 |
12 | 1HuNn2EP | gamma-delta T cell | CL:0000798 | None | gammadelta T cell|gamma-delta T-cell|gamma-del... | None | 31.0 | None | 1 | 2024-07-26 14:36:23.259236+00:00 |
11 | 2eNGzkOc | my T cell subtype | None | None | None | None | NaN | None | 1 | 2024-07-26 14:36:21.950634+00:00 |
10 | u3sr1Gdf | nucleate cell | CL:0002242 | None | None | A Cell Containing At Least One Nucleus. | 31.0 | None | 1 | 2024-07-26 14:36:21.905385+00:00 |
9 | 4Ilrnj9U | hematopoietic cell | CL:0000988 | None | haematopoietic cell|hemopoietic cell|haemopoie... | A Cell Of A Hematopoietic Lineage. | 31.0 | None | 1 | 2024-07-26 14:36:21.905251+00:00 |
8 | 2Jgr5Xx4 | mononuclear cell | CL:0000842 | None | mononuclear leukocyte | A Leukocyte With A Single Non-Segmented Nucleu... | 31.0 | None | 1 | 2024-07-26 14:36:21.905116+00:00 |
7 | 3VEAlFdi | leukocyte | CL:0000738 | None | white blood cell|leucocyte | An Achromatic Cell Of The Myeloid Or Lymphoid ... | 31.0 | None | 1 | 2024-07-26 14:36:21.904979+00:00 |
6 | 4WnpvUTH | eukaryotic cell | CL:0000255 | None | None | None | 31.0 | None | 1 | 2024-07-26 14:36:21.904813+00:00 |
5 | 2cXC7cgF | single nucleate cell | CL:0000226 | None | None | A Cell With A Single Nucleus. | 31.0 | None | 1 | 2024-07-26 14:36:21.904674+00:00 |
4 | 2K93w3xO | motile cell | CL:0000219 | None | None | A Cell That Moves By Its Own Activities. | 31.0 | None | 1 | 2024-07-26 14:36:21.904535+00:00 |
3 | 4bKGljt0 | cell | CL:0000000 | None | None | A Material Entity Of Anatomical Origin (Part O... | 31.0 | None | 1 | 2024-07-26 14:36:21.904382+00:00 |
2 | X6c7osZ5 | lymphocyte | CL:0000542 | None | None | A Lymphocyte Is A Leukocyte Commonly Found In ... | 31.0 | None | 1 | 2024-07-26 14:36:21.542279+00:00 |
1 | 22LvKd01 | T cell | CL:0000084 | None | T-lymphocyte|T lymphocyte|T-cell | A Type Of Lymphocyte Whose Defining Characteri... | 31.0 | None | 1 | 2024-07-26 14:36:21.025040+00:00 |
Access records in in-house ontologies¶
Search:
bt.CellType.search("gamma delta T cell").df().head(2)
Show code cell output
uid | name | ontology_id | abbr | synonyms | description | source_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||
1 | 22LvKd01 | T cell | CL:0000084 | None | T-lymphocyte|T lymphocyte|T-cell | A Type Of Lymphocyte Whose Defining Characteri... | 31.0 | None | 1 | 2024-07-26 14:36:21.025040+00:00 |
3 | 4bKGljt0 | cell | CL:0000000 | None | None | A Material Entity Of Anatomical Origin (Part O... | 31.0 | None | 1 | 2024-07-26 14:36:21.904382+00:00 |
Or look up with auto-complete:
cell_types = bt.CellType.lookup()
hsc_record = cell_types.hematopoietic_stem_cell
hsc_record
Show code cell output
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.', created_by_id=1, source_id=31, updated_at='2024-07-26 14:36:25 UTC')
Validate & standardize¶
Simple validation of an iterable of values works like so:
bt.CellType.validate(["HSC", "blood forming stem cell"])
Show code cell output
❗ 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"])
Show code cell output
['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"])
Show code cell output
❗ 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.', created_by_id=1, source_id=31, updated_at='2024-07-26 14:36:25 UTC')]
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"])
Show code cell output
['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
Show code cell output
CellType(uid='2U8xapxu', name='hematopoietic stem cell', ontology_id='CL:0000037', abbr='HSC', synonyms='HSCs|HSC|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.', created_by_id=1, source_id=31, updated_at='2024-07-26 14:36:26 UTC')
The same workflow works for all of bionty
’s registries.
Manage registries across organisms¶
Most registries are organism-aware, for instance, Gene
:
bt.Gene.from_public(symbol="TCF7", organism="human")
Gene(uid='7IkHKPl0ScQR', symbol='TCF7', ensembl_gene_id='ENSG00000081059', ncbi_gene_ids='6932', biotype='protein_coding', synonyms='TCF-1', description='transcription factor 7 ', created_by_id=1, organism_id=1, source_id=11)
Similarly, API calls that interact with multi-organism registries accept a organism
argument, e.g.:
bt.Gene.validate(["TCF7", "ABC1"], organism="human")
Show code cell output
❗ 2 terms (100.00%) are not validated for symbol: TCF7, ABC1
array([False, False])
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")
Gene(uid='3b8mHb0MRal4', symbol='Ap5b1', ensembl_gene_id='ENSMUSG00000049562', ncbi_gene_ids='381201', biotype='protein_coding', synonyms='Gm962', description='adaptor-related protein complex 5, beta 1 subunit ', created_by_id=1, organism_id=2, source_id=15)
Track underlying ontology versions¶
Under-the-hood, source ontology versions are automatically tracked:
bt.Source.filter(currently_used=True).df()
Show code cell output
uid | entity | organism | source | version | in_db | currently_used | source_name | url | md5 | source_website | df_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||
1 | 496G | Organism | vertebrates | ensembl | release-112 | False | True | Ensembl | https://ftp.ensembl.org/pub/release-112/specie... | 0ec37e77f4bc2d0b0b47c6c62b9f122d | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.194556+00:00 |
6 | 79UX | Organism | bacteria | ensembl | release-57 | False | True | Ensembl | https://ftp.ensemblgenomes.ebi.ac.uk/pub/bacte... | ee28510ed5586ea7ab4495717c96efc8 | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.195437+00:00 |
7 | 1Aul | Organism | fungi | ensembl | release-57 | False | True | Ensembl | http://ftp.ensemblgenomes.org/pub/fungi/releas... | dbcde58f4396ab8b2480f7fe9f83df8a | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.195614+00:00 |
8 | 4PAe | Organism | metazoa | ensembl | release-57 | False | True | Ensembl | http://ftp.ensemblgenomes.org/pub/metazoa/rele... | 424636a574fec078a61cbdddb05f9132 | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.195784+00:00 |
9 | 1m81 | Organism | plants | ensembl | release-57 | False | True | Ensembl | https://ftp.ensemblgenomes.ebi.ac.uk/pub/plant... | eadaa1f3e527e4c3940c90c7fa5c8bf4 | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.195956+00:00 |
10 | 3tEq | Organism | all | ncbitaxon | 2023-06-20 | False | True | NCBItaxon Ontology | s3://bionty-assets/df_all__ncbitaxon__2023-06-... | 00d97ba65627f1cd65636d2df22ea76c | https://github.com/obophenotype/ncbitaxon | None | None | 1 | 2024-07-26 14:36:17.196126+00:00 |
11 | 1xH4 | Gene | human | ensembl | release-112 | False | True | Ensembl | s3://bionty-assets/df_human__ensembl__release-... | 4ccda4d88720a326737376c534e8446b | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.196296+00:00 |
15 | 1AT3 | Gene | mouse | ensembl | release-112 | False | True | Ensembl | s3://bionty-assets/df_mouse__ensembl__release-... | 519cf7b8acc3c948274f66f3155a3210 | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.197000+00:00 |
19 | 6hrB | Gene | saccharomyces cerevisiae | ensembl | release-112 | False | True | Ensembl | s3://bionty-assets/df_saccharomyces cerevisiae... | 11775126b101233525a0a9e2dd64edae | https://www.ensembl.org | None | None | 1 | 2024-07-26 14:36:17.197694+00:00 |
22 | 58f3 | Protein | human | uniprot | 2024-03 | False | True | Uniprot | s3://bionty-assets/df_human__uniprot__2024-03_... | b5b9e7645065b4b3187114f07e3f402f | https://www.uniprot.org | None | None | 1 | 2024-07-26 14:36:17.198202+00:00 |
25 | 1032 | Protein | mouse | uniprot | 2024-03 | False | True | Uniprot | s3://bionty-assets/df_mouse__uniprot__2024-03_... | b1b6a196eb853088d36198d8e3749ec4 | https://www.uniprot.org | None | None | 1 | 2024-07-26 14:36:17.198709+00:00 |
28 | 7cT7 | CellMarker | human | cellmarker | 2.0 | False | True | CellMarker | s3://bionty-assets/human_cellmarker_2.0_CellMa... | d565d4a542a5c7e7a06255975358e4f4 | http://bio-bigdata.hrbmu.edu.cn/CellMarker | None | None | 1 | 2024-07-26 14:36:17.199218+00:00 |
29 | kweZ | CellMarker | mouse | cellmarker | 2.0 | False | True | CellMarker | s3://bionty-assets/mouse_cellmarker_2.0_CellMa... | 189586732c63be949e40dfa6a3636105 | http://bio-bigdata.hrbmu.edu.cn/CellMarker | None | None | 1 | 2024-07-26 14:36:17.199388+00:00 |
30 | 5yMS | CellLine | all | clo | 2022-03-21 | False | True | Cell Line Ontology | https://data.bioontology.org/ontologies/CLO/su... | ea58a1010b7e745702a8397a526b3a33 | https://bioportal.bioontology.org/ontologies/CLO | None | None | 1 | 2024-07-26 14:36:17.199558+00:00 |
31 | 2HS5 | CellType | all | cl | 2024-02-13 | False | True | Cell Ontology | http://purl.obolibrary.org/obo/cl/releases/202... | https://obophenotype.github.io/cell-ontology | None | None | 1 | 2024-07-26 14:36:17.199726+00:00 | |
36 | 3wfb | Tissue | all | uberon | 2024-02-20 | False | True | Uberon multi-species anatomy ontology | http://purl.obolibrary.org/obo/uberon/releases... | 2048667b5fdf93192384bdf53cafba18 | http://obophenotype.github.io/uberon | None | None | 1 | 2024-07-26 14:36:17.200597+00:00 |
41 | 5tcO | Disease | all | mondo | 2024-02-06 | False | True | Mondo Disease Ontology | http://purl.obolibrary.org/obo/mondo/releases/... | 78914fa236773c5ea6605f7570df6245 | https://mondo.monarchinitiative.org | None | None | 1 | 2024-07-26 14:36:17.201465+00:00 |
46 | r5aU | Disease | human | doid | 2024-01-31 | False | True | Human Disease Ontology | http://purl.obolibrary.org/obo/doid/releases/2... | b36c15a4610757094f8db64b78ae2693 | https://disease-ontology.org | None | None | 1 | 2024-07-26 14:36:17.202312+00:00 |
53 | WcIm | ExperimentalFactor | all | efo | 3.63.0 | False | True | The Experimental Factor Ontology | http://www.ebi.ac.uk/efo/releases/v3.63.0/efo.owl | 603e6f6981d53d501c5921aa3940b095 | https://bioportal.bioontology.org/ontologies/EFO | None | None | 1 | 2024-07-26 14:36:17.203499+00:00 |
56 | 6Rhk | Phenotype | human | hp | 2024-03-06 | False | True | Human Phenotype Ontology | https://github.com/obophenotype/human-phenotyp... | 36b0d00c24a68edb9131707bc146a4c7 | https://hpo.jax.org | None | None | 1 | 2024-07-26 14:36:17.204004+00:00 |
60 | 74xB | Phenotype | mammalian | mp | 2024-02-07 | False | True | Mammalian Phenotype Ontology | https://github.com/mgijax/mammalian-phenotype-... | 31c27ed2c7d5774f8b20a77e4e1fd278 | https://github.com/mgijax/mammalian-phenotype-... | None | None | 1 | 2024-07-26 14:36:17.204679+00:00 |
62 | 2YS5 | Phenotype | zebrafish | zp | 2024-01-22 | False | True | Zebrafish Phenotype Ontology | https://github.com/obophenotype/zebrafish-phen... | 01600a5d392419b27fc567362d4cfff8 | https://github.com/obophenotype/zebrafish-phen... | None | None | 1 | 2024-07-26 14:36:17.205047+00:00 |
65 | 2hjK | Phenotype | all | pato | 2023-05-18 | False | True | Phenotype And Trait Ontology | http://purl.obolibrary.org/obo/pato/releases/2... | bd472f4971492109493d4ad8a779a8dd | https://github.com/pato-ontology/pato | None | None | 1 | 2024-07-26 14:36:17.208530+00:00 |
66 | 5Jfr | Pathway | all | go | 2023-05-10 | False | True | Gene Ontology | https://data.bioontology.org/ontologies/GO/sub... | e9845499eadaef2418f464cd7e9ac92e | http://geneontology.org | None | None | 1 | 2024-07-26 14:36:17.208696+00:00 |
69 | 5e83 | BFXPipeline | all | lamin | 1.0.0 | False | True | Bioinformatics Pipeline | s3://bionty-assets/bfxpipelines.json | a7eff57a256994692fba46e0199ffc94 | https://lamin.ai | None | None | 1 | 2024-07-26 14:36:17.209249+00:00 |
70 | 4uDt | Drug | all | dron | 2024-03-02 | False | True | Drug Ontology | https://data.bioontology.org/ontologies/DRON/s... | 84138459de4f65034e979f4e46783747 | https://bioportal.bioontology.org/ontologies/DRON | None | None | 1 | 2024-07-26 14:36:17.209428+00:00 |
72 | 238S | DevelopmentalStage | human | hsapdv | 2020-03-10 | False | True | Human Developmental Stages | http://aber-owl.net/media/ontologies/HSAPDV/11... | 52181d59df84578ed69214a5cb614036 | https://github.com/obophenotype/developmental-... | None | None | 1 | 2024-07-26 14:36:17.209765+00:00 |
73 | 4hcb | DevelopmentalStage | mouse | mmusdv | 2020-03-10 | False | True | Mouse Developmental Stages | http://aber-owl.net/media/ontologies/MMUSDV/9/... | 5bef72395d853c7f65450e6c2a1fc653 | https://github.com/obophenotype/developmental-... | None | None | 1 | 2024-07-26 14:36:17.209930+00:00 |
74 | 5kwU | Ethnicity | human | hancestro | 3.0 | False | True | Human Ancestry Ontology | https://github.com/EBISPOT/hancestro/raw/3.0/h... | 76dd9efda9c2abd4bc32fc57c0b755dd | https://github.com/EBISPOT/hancestro | None | None | 1 | 2024-07-26 14:36:17.210094+00:00 |
75 | 3pvh | BioSample | all | ncbi | 2023-09 | False | True | NCBI BioSample attributes | s3://bionty-assets/df_all__ncbi__2023-09__BioS... | 918db9bd1734b97c596c67d9654a4126 | https://www.ncbi.nlm.nih.gov/biosample/docs/at... | None | None | 1 | 2024-07-26 14:36:17.210258+00:00 |
Each record is linked to a versioned public source (if it was created from public):
hepatocyte = bt.CellType.filter(name="hepatocyte").one()
hepatocyte.source
Show code cell output
Source(uid='2HS5', entity='CellType', organism='all', source='cl', version='2024-02-13', in_db=False, currently_used=True, source_name='Cell Ontology', url='http://purl.obolibrary.org/obo/cl/releases/2024-02-13/cl.owl', md5='', source_website='https://obophenotype.github.io/cell-ontology', created_by_id=1, updated_at='2024-07-26 14:36:17 UTC')
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()
Show code cell output
PublicOntology
Entity: Phenotype
Organism: human
Source: hp, 2024-03-06
#terms: 18697
bt.Phenotype.sources(currently_used=True).df()
Show code cell output
uid | entity | organism | source | version | in_db | currently_used | source_name | url | md5 | source_website | df_id | run_id | created_by_id | updated_at | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | |||||||||||||||
56 | 6Rhk | Phenotype | human | hp | 2024-03-06 | False | True | Human Phenotype Ontology | https://github.com/obophenotype/human-phenotyp... | 36b0d00c24a68edb9131707bc146a4c7 | https://hpo.jax.org | None | None | 1 | 2024-07-26 14:36:17.204004+00:00 |
60 | 74xB | Phenotype | mammalian | mp | 2024-02-07 | False | True | Mammalian Phenotype Ontology | https://github.com/mgijax/mammalian-phenotype-... | 31c27ed2c7d5774f8b20a77e4e1fd278 | https://github.com/mgijax/mammalian-phenotype-... | None | None | 1 | 2024-07-26 14:36:17.204679+00:00 |
62 | 2YS5 | Phenotype | zebrafish | zp | 2024-01-22 | False | True | Zebrafish Phenotype Ontology | https://github.com/obophenotype/zebrafish-phen... | 01600a5d392419b27fc567362d4cfff8 | https://github.com/obophenotype/zebrafish-phen... | None | None | 1 | 2024-07-26 14:36:17.205047+00:00 |
65 | 2hjK | Phenotype | all | pato | 2023-05-18 | False | True | Phenotype And Trait Ontology | http://purl.obolibrary.org/obo/pato/releases/2... | bd472f4971492109493d4ad8a779a8dd | https://github.com/pato-ontology/pato | None | None | 1 | 2024-07-26 14:36:17.208530+00:00 |
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:
source = bt.PublicSource.filter(entity="Organism", source="ncbitaxon").one()
iris_setosa = bt.Organism.from_public(name="iris setosa", source=source)
iris_setosa.save()
Analogously, you can pass source
to bulk-create records from a non-default source:
records = bt.Organism.from_values(
["iris setosa", "iris versicolor", "iris virginica"], source=source
)
ln.save(records)
iris_setosa.parents.get(name="iris").view_parents(with_children=True)
Show code cell content
# clean up test instance
!lamin delete --force test-registries
💡 deleting instance testuser1/test-registries