Package 'laminr'

Title: Client for 'LaminDB'
Description: Interact with 'LaminDB'. 'LaminDB' is an open-source data framework for biology. This package allows you to query and download data from 'LaminDB' instances.
Authors: Robrecht Cannoodt [aut, cre] , Luke Zappia [aut] , Data Intuitive [aut], Lamin Labs [aut, cph]
Maintainer: Robrecht Cannoodt <[email protected]>
License: Apache License (>= 2)
Version: 1.0.0
Built: 2025-03-10 17:20:09 UTC
Source: https://github.com/laminlabs/laminr

Help Index


Get current LaminDB instance

Description

Get the currently connected LaminDB instance

Usage

get_current_lamin_instance()

Details

This is done via a system call to ⁠lamin settings⁠ to avoid importing Python lamindb

Value

The slug of the current LaminDB instance, or NULL invisibly if no instance is found


Get current LaminDB user

Description

Get the currently logged in LaminDB user

Usage

get_current_lamin_user()

Details

This is done via a system call to ⁠lamin settings⁠ to avoid importing Python lamindb

Value

The handle of the current LaminDB user, or NULL invisibly if no user is found


Import Python modules

Description

This function can be used to import LaminDB Python modules with additional checks and nicer error messages.

Usage

import_module(module)

Arguments

module

The name of the Python module to import

Value

An object representing a Python package

Examples

## Not run: 
# Import lamindb to start interacting with an instance
ln <- import_module("lamindb")

# Import other LaminDB modules
bt <- import_module("bionty")
wl <- import_module("wetlab")
cc <- import_module("clincore")

# Import any Python module
np <- import_module("numpy")

## End(Not run)

Install LaminDB

Description

Create a Python environment containing lamindb or install lamindb into an existing environment.

Usage

install_lamindb(
  ...,
  envname = "r-lamindb",
  extra_packages = NULL,
  new_env = identical(envname, "r-lamindb"),
  use = TRUE
)

Arguments

...

Additional arguments passed to reticulate::py_install()

envname

String giving the name of the environment to install packages into

extra_packages

A vector giving the names of additional Python packages to install

new_env

Whether to remove any existing virtualenv with the same name before creating a new one with the requested packages

use

Whether to attempt use the new environment

Details

See vignette("setup", package = "laminr") for further details on setting up a Python environment

Value

NULL, invisibly

Examples

## Not run: 
install_lamindb()

# Add additional packages to the environment
install_lamindb(extra_packages = c("bionty", "wetlab"))

# Install into a different environment
install_lamindb(envvname = "your-env")

## End(Not run)

Connect to a LaminDB instance

Description

Connect to a LaminDB instance by calling ⁠lamin connect⁠ on the command line

Usage

lamin_connect(instance)

Arguments

instance

Either a slug giving the instance to connect to (⁠<owner>/<name>⁠) or an instance URL (⁠https://lamin.ai/owner/name⁠)

Details

Running this will set the LaminDB auto-connect option to True so you auto-connect to instance when importing Python lamindb.

Examples

## Not run: 
lamin_connect("laminlabs/cellxgene")

## End(Not run)

LaminDB delete

Description

Delete a LaminDB entity. Currently only supports instances.

Usage

lamin_delete(instance, force = FALSE)

Arguments

instance

Identifier for the instance to delete (e.g. "owner/name")

force

Whether to force deletion without asking for confirmation

Examples

## Not run: 
lamin_init("to-delete")
lamin_delete("to-delete")

## End(Not run)

Disconnect from a LaminDB instance

Description

Disconnect from the current LaminDB instance by calling ⁠lamin connect⁠ on the command line

Usage

lamin_disconnect()

Examples

## Not run: 
lamin_disconnect()

## End(Not run)

Initialise LaminDB

Description

Initialise a new LaminDB instance

Usage

lamin_init(storage, name = NULL, db = NULL, modules = NULL)

lamin_init_temp(
  name = "laminr-temp",
  db = NULL,
  modules = NULL,
  add_timestamp = TRUE,
  envir = parent.frame()
)

Arguments

storage

A local directory, AWS S3 bucket or Google Cloud Storage bucket

name

A name for the instance

db

A Postgres database connection URL, use NULL for SQLite.

modules

A vector of modules to include (e.g. "bionty")

add_timestamp

Whether to append a timestamp to name to make it unique

envir

An environment passed to withr::defer()

Details

For lamin_init_temp(), a time stamp is appended to name (if add_timestamp = TRUE) and then a new instance is initialised with lamin_init() using a temporary directory. A lamin_delete() call is registered as an exit handler with withr::defer() to clean up the instance when envir finishes.

The lamin_init_temp() function is mostly for internal use and in most cases users will want lamin_init().

Examples

## Not run: 
lamin_init("mydata", modules = c("bionty", "wetlab"))

## End(Not run)

Log into LaminDB

Description

Log in as a LaminDB user

Usage

lamin_login(user = NULL, api_key = NULL)

Arguments

user

Handle for the user to login as

api_key

API key for a user

Details

Depending on the input, one of these commands will be run (in this order):

  1. If user is set then ⁠lamin login <user>⁠

  2. Else if api_key is set then set the LAMIN_API_KEY environment variable temporarily with withr::with_envvar() and run ⁠lamin login⁠

  3. Else if there is a stored user handle run ⁠lamin login <handle>⁠

  4. Else if the LAMIN_API_KEY environment variable is set run ⁠lamin login⁠

Otherwise, exit with an error


Log out of LaminDB

Description

Log out of LaminDB

Usage

lamin_logout()

Save to a LaminDB instance

Description

Save a file or folder to a LaminDB instance by calling ⁠lamin save⁠ on the command line

Usage

lamin_save(filepath, key = NULL, description = NULL, registry = NULL)

Arguments

filepath

Path to the file or folder to save

key

The key for the saved item

description

The description for the saved item

registry

The registry for the saved item

Details

See ⁠lamin save --help⁠ for details of what database entries are created for different file types

Examples

## Not run: 
my_file <- tempfile()
lamin_save(my_file)

## End(Not run)