Configure schema modules#

import lamindb as ln
πŸ”Ά You haven't yet setup an instance using the CLI: Please call `ln.setup.init()` or `ln.setup.load()`

Core schema module#

The core schema module is part of any LaminDB instance and tracks data lineage.

Hide code cell content
ln.setup.load("mydata")
πŸ’¬ Found cached instance metadata: /home/runner/.lamin/testuser1-instance-mydata.env
βœ… Loaded instance: testuser1/mydata
'migrate-unnecessary'

You can find the code here: https://github.com/laminlabs/lnschema-core

ln.setup.schema.draw()
../_images/45cc424bbf51700a3e63d69eb9f72d53c54c3b6d1a167221ce86f73a808f9637.svg

Schema modules bionty & lamin1#

The bionty schema module maps fundamental biological entities: https://github.com/laminlabs/lnschema-bionty

The lamin1 module is an example for a configurable in-house schema that tracks lab operations: https://github.com/laminlabs/lnschema-lamin1

ln.setup.init(
    storage="mydata2", schema="bionty,lamin1"
)  # CLI: lamin init --storage mydata2 --schema bionty,lamin1
πŸ’¬ Not registering instance on hub, if you want, call `lamin register`
πŸ’¬ Loading schema modules: core==0.34.0 bionty==0.18.0 lamin1==0.17.0 
βœ… Loaded instance: testuser1/mydata2
βœ… Created & loaded instance: testuser1/mydata2
ln.setup.schema.draw()
../_images/f2c13d7d5551191446385966c88075b950be163a087d20c6a4da7c2e46dbc6ab.svg

For bionty, supporting public ontology versions are automatically tracked:

Hide code cell content
from lndb.dev._setup_knowledge import load_bionty_versions
load_bionty_versions(ln.setup.settings.instance, display=True)
database database_v
entity
Species ensembl release-108
Gene ensembl release-108
Protein uniprot 2022-04
CellMarker cellmarker 2.0
CellLine clo 2022-03-21
CellType cl 2023-02-15
Tissue uberon 2023-02-14
Disease mondo 2023-02-06
Readout efo 3.48.0
Phenotype hp 2023-01-27
Pathway pw 7.78
BFXPipeline lamin 1.0.0
Drug dron 2023-03-10
Hide code cell content
# clean up
ln.setup.delete("mydata2")
# test with postgres
from laminci.db import setup_local_test_postgres

pgurl = setup_local_test_postgres()
ln.setup.init(storage="mydata2", schema="bionty,lamin1", db=pgurl)
!docker stop pgtest && docker rm pgtest
ln.setup.delete("pgtest")
πŸ’¬ Deleting instance testuser1/mydata2
πŸ’¬     instance settings '.env' deleted
πŸ’¬     current instance settings /home/runner/.lamin/current_instance.env deleted
πŸ’¬     consider deleting your stored data manually: /home/runner/work/lndb/lndb/docs/guide/mydata2
πŸ’¬     deleted '.lndb' sqlite file
πŸ’¬ Created Postgres test instance: 'postgresql://postgres:pwd@0.0.0.0:5432/pgtest'
It runs in docker container 'pgtest'
πŸ”Ά Instance metadata exists, but DB might have been corrupted or deleted. Re-initializing the DB.
πŸ’¬ Not registering instance on hub, if you want, call `lamin register`
πŸ’¬ Loading schema modules: core==0.34.0 bionty==0.18.0 lamin1==0.17.0 
βœ… Loaded instance: testuser1/pgtest
βœ… Created & loaded instance: testuser1/pgtest
pgtest
pgtest
πŸ’¬ Deleting instance testuser1/pgtest
πŸ’¬     instance settings '.env' deleted
πŸ’¬     current instance settings /home/runner/.lamin/current_instance.env deleted
πŸ’¬     consider deleting your stored data manually: /home/runner/work/lndb/lndb/docs/guide/mydata2