Title: | Interface 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: | 0.2.0 |
Built: | 2024-11-25 15:21:48 UTC |
Source: | CRAN |
Note that prior to connecting to an instance, you need to authenticate with
lamin login
. If no slug is provided, the default instance is loaded, which is
set by running lamin connect <slug>
.
connect(slug = NULL)
connect(slug = NULL)
slug |
The instance slug |
## Not run: # first run 'lamin login' to authenticate instance <- connect("laminlabs/cellxgene") instance ## End(Not run)
## Not run: # first run 'lamin login' to authenticate instance <- connect("laminlabs/cellxgene") instance ## End(Not run)
A field in a registry.
type
(character(1)
)
The type of the field.
through
(list()
or NULL
)
The through value of the field.
field_name
(character(1)
)
The field name.
registry_name
(character(1)
)
The registry name.
column_name
(character(1)
)
The column name.
module_name
(character(1)
)
The module name.
is_link_table
(logical(1)
)
Whether the field is a link table.
relation_type
(character(1)
or NULL
)
The relation type. Can be one of: "one-to-many", "many-to-one", "many-to-many".
related_field_name
(character(1)
or NULL
)
The related field name.
related_registry_name
(character(1)
or NULL
)
The related registry name.
related_module_name
(character(1)
or NULL
)
The related module name.
new()
Creates an instance of this R6 class. This class should not be instantiated directly,
but rather by connecting to a LaminDB instance using the connect()
function.
Field$new( type, through, field_name, registry_name, column_name, module_name, is_link_table, relation_type, related_field_name, related_registry_name, related_module_name )
type
The type of the field. Can be one of: "IntegerField", "JSONField", "OneToOneField", "SmallIntegerField", "BigIntegerField", "AutoField", "BigAutoField", "BooleanField", "TextField", "DateTimeField", "ManyToManyField", "CharField", "ForeignKey"
through
If the relation type is one-to-many, many-to-one, or many-to-many, This value will be a named list with keys 'left_key', 'right_key', 'link_table_name'.
field_name
The name of the field in the registry. Example: "name"
.
registry_name
The name of the registry. Example: "user"
.
column_name
The name of the column in the database. Example: "name"
.
module_name
The name of the module. Example: "core"
.
is_link_table
Whether the field is a link table.
relation_type
The type of relation. Can be NULL or one of: "one-to-one", "many-to-one", "many-to-many".
related_field_name
The name of the related field in the related registry. Example: "name"
.
related_registry_name
The name of the related registry. Example: "user"
.
related_module_name
The name of the related module. Example: "core"
.
print()
Print a Field
Field$print(style = TRUE)
style
Logical, whether the output is styled using ANSI codes
to_string()
Create a string representation of a Field
Field$to_string(style = FALSE)
style
Logical, whether the output is styled using ANSI codes
A cli::cli_ansi_string
if style = TRUE
or a character vector
Connect to a LaminDB instance using the connect()
function.
The instance object provides access to the modules and registries
of the instance.
Note that by connecting to an instance via connect()
, you receive
a "richer" version of the Instance class documented here, providing
direct access to all core registries and additional modules.
See the vignette on "Package Architecture" for more information:
vignette("architecture", package = "laminr")
.
is_default
(logical(1)
)
Whether this is the default instance.
new()
Creates an instance of this R6 class. This class should not be instantiated directly,
but rather by connecting to a LaminDB instance using the connect()
function.
Instance$new(settings, api, schema, is_default, py_lamin)
settings
The settings for the instance
api
The API for the instance
schema
The schema for the instance
is_default
Logical, whether this is the default instance
py_lamin
A Python lamindb
module object
get_modules()
Get the modules for the instance.
Instance$get_modules()
A list of Module objects.
get_module()
Get a module by name.
Instance$get_module(module_name)
module_name
The name of the module.
The Module object.
get_module_names()
Get the names of the modules. Example: c("core", "bionty")
.
Instance$get_module_names()
A character vector of module names.
get_settings()
Get instance settings.
Note: This method is intended for internal use only and may be removed in the future.
Instance$get_settings()
The settings for the instance.
get_api()
Get instance API.
Note: This method is intended for internal use only and may be removed in the future.
Instance$get_api()
The API for the instance.
get_py_lamin()
Get the Python lamindb module
Instance$get_py_lamin(check = FALSE, what = "This functionality")
check
Logical, whether to perform checks
what
What the python module is being requested for, used in check messages
Python lamindb module.
track()
Start a run with tracked data lineage
Instance$track(transform = NULL, path = NULL)
transform
UID specifying the data transformation
path
Path to the R script or document to track
Calling track()
with transform = NULL
with return a UID, providing
that UID with the same path with start a run
finish()
Finish a tracked run
Instance$finish()
print()
Print an Instance
Instance$print(style = TRUE)
style
Logical, whether the output is styled using ANSI codes
to_string()
Create a string representation of an Instance
Instance$to_string(style = FALSE)
style
Logical, whether the output is styled using ANSI codes
A cli::cli_ansi_string
if style = TRUE
or a character vector
## Not run: # Connect to an instance db <- connect("laminlabs/cellxgene") # fetch an artifact artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") # describe the artifact artifact$describe() # view field artifact$id # load dataset artifact$load() ## End(Not run)
## Not run: # Connect to an instance db <- connect("laminlabs/cellxgene") # fetch an artifact artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") # describe the artifact artifact$describe() # view field artifact$id # load dataset artifact$load() ## End(Not run)
A LaminDB module containing one or more registries.
name
(character(1)
)
Get the name of the module.
new()
Creates an instance of this R6 class. This class should not be instantiated directly,
but rather by connecting to a LaminDB instance using the connect()
function.
Module$new(instance, api, module_name, module_schema)
instance
The instance the module belongs to.
api
The API for the instance.
module_name
The name of the module.
module_schema
The schema of the module.
get_registries()
Get the registries in the module.
Module$get_registries()
A list of Registry objects.
get_registry()
Get a registry by name.
Module$get_registry(registry_name)
registry_name
The name of the registry.
A Registry object.
get_registry_names()
Get the names of the registries in the module. E.g. c("User", "Artifact")
.
Module$get_registry_names()
A character vector of registry names.
print()
Print a Module
Module$print(style = TRUE)
style
Logical, whether the output is styled using ANSI codes.
to_string()
Create a string representation of a Module
Module$to_string(style = FALSE)
style
Logical, whether the output is styled using ANSI codes
A cli::cli_ansi_string
if style = TRUE
or a character vector
A record from a registry.
new()
Creates an instance of this R6 class. This class should not be instantiated directly,
but rather by connecting to a LaminDB instance using the connect()
function.
Record$new(instance, registry, api, data)
instance
The instance the record belongs to.
registry
The registry the record belongs to.
api
The API for the instance.
data
The data for the record.
delete()
Delete a Record
Record$delete(verbose = FALSE)
verbose
Whether to print details of the API call
TRUE
invisibly if the deletion is successful
print()
Print a Record
Record$print(style = TRUE)
style
Logical, whether the output is styled using ANSI codes
to_string()
Create a string representation of a Record
Record$to_string(style = FALSE)
style
Logical, whether the output is styled using ANSI codes
A cli::cli_ansi_string
if style = TRUE
or a character vector
A registry in a module.
module
(Module)
The instance the registry belongs to.
name
(character(1)
)
The API for the instance.
class_name
(character(1)
)
The class name for the registry.
is_link_table
(logical(1)
)
Whether the registry is a link table.
new()
Creates an instance of this R6 class. This class should not be instantiated directly,
but rather by connecting to a LaminDB instance using the connect()
function.
Registry$new(instance, module, api, registry_name, registry_schema)
instance
The instance the registry belongs to.
module
The module the registry belongs to.
api
The API for the instance.
registry_name
The name of the registry.
registry_schema
The schema for the registry.
get()
Get a record by ID or UID.
Registry$get(id_or_uid, include_foreign_keys = FALSE, verbose = FALSE)
id_or_uid
The ID or UID of the record.
include_foreign_keys
Logical, whether to include foreign keys in the record.
verbose
Logical, whether to print verbose output.
A Record object.
df()
Get a data frame summarising records in the registry
Registry$df(limit = 100, verbose = FALSE)
limit
Maximum number of records to return
verbose
Boolean, whether to print progress messages
A data.frame containing the available records
from_df()
Create a record from a data frame
Registry$from_df(dataframe, key = NULL, description = NULL, run = NULL)
dataframe
The data.frame
to create a record from
key
A relative path within the default storage
description
A string describing the record
run
A Run
object that creates the record
Creating records is only possible for the default instance, requires the
Python lamindb
module and is only implemented for the core Artifact
registry.
A TemporaryRecord
object containing the new record. This is not
saved to the database until temp_record$save()
is called.
from_path()
Create a record from a path
Registry$from_path(path, key = NULL, description = NULL, run = NULL)
path
Path to create a record from
key
A relative path within the default storage
description
A string describing the record
run
A Run
object that creates the record
Creating records is only possible for the default instance, requires the
Python lamindb
module and is only implemented for the core Artifact
registry.
A TemporaryRecord
object containing the new record. This is not
saved to the database until temp_record$save()
is called.
from_anndata()
Create a record from an AnnData
Registry$from_anndata(adata, key = NULL, description = NULL, run = NULL)
adata
The anndata::AnnData object to create a record from
key
A relative path within the default storage
description
A string describing the record
run
A Run
object that creates the record
Creating records is only possible for the default instance, requires the
Python lamindb
module and is only implemented for the core Artifact
registry.
A TemporaryRecord
object containing the new record. This is not
saved to the database until temp_record$save()
is called.
get_fields()
Get the fields in the registry.
Registry$get_fields()
A list of Field objects.
get_field()
Get a field by name.
Registry$get_field(field_name)
field_name
The name of the field.
A Field object.
get_field_names()
Get the field names in the registry.
Registry$get_field_names()
A character vector of field names.
get_record_class()
Get the record class for the registry.
Note: This method is intended for internal use only and may be removed in the future.
Registry$get_record_class()
A Record class.
get_temporary_record_class()
Get the temporary record class for the registry.
Note: This method is intended for internal use only and may be removed in the future.
Registry$get_temporary_record_class()
A TemporaryRecord
class.
print()
Print a Registry
Registry$print(style = TRUE)
style
Logical, whether the output is styled using ANSI codes
A character vector
to_string()
Create a string representation of a Registry
Registry$to_string(style = FALSE)
style
Logical, whether the output is styled using ANSI codes
A cli::cli_ansi_string
if style = TRUE
or a character vector
A container for accessing records with a one-to-many or many-to-many relationship.
new()
Creates an instance of this R6 class. This class should not be instantiated directly,
but rather by connecting to a LaminDB instance using the connect()
function.
RelatedRecords$new(instance, registry, field, related_to, api)
instance
The instance the records list belongs to.
registry
The registry the records list belongs to.
field
The field associated with the records list.
related_to
ID or UID of the parent that records are related to.
api
The API for the instance.
df()
Get a data frame summarising records in the registry
RelatedRecords$df(limit = 100, verbose = FALSE)
limit
Maximum number of records to return
verbose
Boolean, whether to print progress messages
A data.frame containing the available records
print()
Print a RelatedRecords
RelatedRecords$print(style = TRUE)
style
Logical, whether the output is styled using ANSI codes
to_string()
Create a string representation of a RelatedRecords
RelatedRecords$to_string(style = FALSE)
style
Logical, whether the output is styled using ANSI codes
A cli::cli_ansi_string
if style = TRUE
or a character vector