Skip to content

laminlabs/laminr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaminDB interface in R

This package provides an interface to the LaminDB database. It allows you to query the database and download data from it.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("laminlabs/laminr")

Set up environment

For this package to work, we first need to run the following commands in the terminal:

pip install lamindb
lamin load laminlabs/cellxgene

This should create an .env file at ~/.lamin/current_instance.env and ~/.lamin/instance--laminlabs--cellxgene.env containing (amongst others) the following data:

lamindb_instance_id=0123456789abcdefghijklmnopqrstuv
lamindb_instance_owner=laminlabs
lamindb_instance_name=cellxgene
lamindb_instance_schema_id=0123456789abcdefghijklmnopqrstuv
lamindb_instance_api_url=https://us-west-2.api.lamin.ai

Note

The .env files don’t store the schema_id and api_url yet, so instead we pass these settings via options(lamindb_current_instance = ...) (see below).

Usage

library(laminr)

Connect to a LaminDB instance

options(
  lamindb_current_instance = list(
    owner = "lamin",
    name = "example",
    id = "0123456789abcdefghijklmnopqrstuv",
    api_url = "https://us-west-2.api.lamin.ai",
    schema_id = "0123456789abcdefghijklmnopqrstuv"
  )
)

db <- laminr::connect()

Print a LaminDB instance

db
Instance 'lamin/cellxgene'
  core classes:
    Run
    User
    Param
    ULabel
    Feature
    Storage
    Artifact
    Transform
    Collection
    FeatureSet
    ParamValue
    FeatureValue
  bionty classes:
    Gene
    Source
    Tissue
    Disease
    Pathway
    Protein
    CellLine
    CellType
    Organism
    Ethnicity
    Phenotype
    CellMarker
    DevelopmentalStage
    ExperimentalFactor

Get artifact

artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu")

Print artifact

artifact
Artifact(description = 'Myeloid compartment', storage_id = '2', version = '2024-07-01', _accessor = 'AnnData', id = '3659', key = 'cell-census/2024-07-01/h5ads/fe52003e-1460-4a65-a213-2bb1a508332f.h5ad', transform_id = '22', size = '691757462', is_latest = 'TRUE', created_by_id = '1', type = 'dataset', _hash_type = 'md5-n', n_observations = '51552', created_at = '2024-07-12T12:34:10.345829+00:00', updated_at = '2024-07-12T12:40:48.837026+00:00', run_id = '27', suffix = '.h5ad', visibility = '1', _key_is_virtual = 'FALSE', n_objects = 'KBW89Mf7IGcekja2hADu', uid = 'SZ5tB0T4YKfiUuUkAL09ZA', hash = 'Myeloid compartment')

Print simple fields

artifact$id
[1] 3659
artifact$uid
[1] "KBW89Mf7IGcekja2hADu"
artifact$key
[1] "cell-census/2024-07-01/h5ads/fe52003e-1460-4a65-a213-2bb1a508332f.h5ad"

Print related fields

artifact$storage
Warning: Data is missing expected fields: run_id, created_by_id

Storage(id = '2', uid = 'oIYGbD74', root = 's3://cellxgene-data-public', type = 's3', region = 'us-west-2', created_at = '2023-09-19T13:17:56.273068+00:00', updated_at = '2023-10-16T15:04:08.998203+00:00', description = '2', instance_uid = 'oIYGbD74')
artifact$created_by
User(id = '1', uid = 'kmvZDIX9', name = 'Sunny Sun', handle = 'sunnyosun', created_at = '2023-09-19T12:02:50.76501+00:00', updated_at = '2023-12-13T16:23:44.195541+00:00')

Cache artifact

Note

Only S3 storage is supported at the moment.

artifact$cache()
Warning: Data is missing expected fields: run_id, created_by_id

Load artifact

Note

Only S3 storage and AnnData accessors are supported at the moment.

artifact$load()
Warning: Data is missing expected fields: run_id, created_by_id

ℹ 's3://cellxgene-data-public/cell-census/2024-07-01/h5ads/fe52003e-1460-4a65-a213-2bb1a508332f.h5ad' already exists at '/home/rcannood/.cache/lamindb/cellxgene-data-public/cell-census/2024-07-01/h5ads/fe52003e-1460-4a65-a213-2bb1a508332f.h5ad'

AnnData object with n_obs × n_vars = 51552 × 36398
    obs: 'donor_id', 'Predicted_labels_CellTypist', 'Majority_voting_CellTypist', 'Manually_curated_celltype', 'assay_ontology_term_id', 'cell_type_ontology_term_id', 'development_stage_ontology_term_id', 'disease_ontology_term_id', 'self_reported_ethnicity_ontology_term_id', 'is_primary_data', 'organism_ontology_term_id', 'sex_ontology_term_id', 'tissue_ontology_term_id', 'suspension_type', 'tissue_type', 'cell_type', 'assay', 'disease', 'organism', 'sex', 'tissue', 'self_reported_ethnicity', 'development_stage', 'observation_joinid'
    var: 'gene_symbols', 'feature_is_filtered', 'feature_name', 'feature_reference', 'feature_biotype', 'feature_length'
    uns: 'cell_type_ontology_term_id_colors', 'citation', 'default_embedding', 'schema_reference', 'schema_version', 'sex_ontology_term_id_colors', 'title'
    obsm: 'X_umap'

Releases

No releases published

Packages

No packages published

Languages