| Title: | 'TileDB' Stack of Matrices, Annotated ('SOMA') |
|---|---|
| Description: | Interface for working with 'TileDB'-based Stack of Matrices, Annotated ('SOMA'): an open data model for representing annotated matrices, like those commonly used for single cell data analysis. It is documented at <https://github.com/single-cell-data>; a formal specification available is at <https://github.com/single-cell-data/SOMA/blob/main/abstract_specification.md>. |
| Authors: | Paul Hoffman [cre, aut] (ORCID: <https://orcid.org/0000-0002-7693-8957>), Aaron Wolen [aut] (ORCID: <https://orcid.org/0000-0003-2542-2202>), Julia Dark [ctb], John Kerl [ctb], TileDB, Inc. [cph, fnd] |
| Maintainer: | Paul Hoffman <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.3.0 |
| Built: | 2026-05-27 06:30:30 UTC |
| Source: | https://github.com/single-cell-data/TileDB-SOMA |
An R6 mapping type for configuring various “parameters”.
Essentially, serves as a nested map where the inner map is a
ScalarMap:
{<param>: {<key>: <value>}}
tiledbsoma::MappingBase -> ConfigList
get()
ConfigList$get(param, key = NULL, default = quote(expr = ))
paramOuter key or “parameter” to fetch
keyInner key to fetch; pass NULL to return the
map for param
defaultDefault value to fetch if key is not found;
defaults to NULL
The value of key for param in the map, or
default if key is not found
set()
ConfigList$set(param, key, value)
paramOuter key or “parameter” to set
keyInner key to set
valueValue to add for key, or NULL to remove
the entry for key; optionally provide only param
and value
as a ScalarMap to update param with the keys and
values from value
\[chainable\] Invisibly returns self with value
added for key in param
setv()
ConfigList$setv(...)
...Ignored
Nothing; setv() is disabled for ConfigList objects
clone()
The objects of this class are cloneable with this method.
ConfigList$clone(deep = FALSE)
deepWhether to make a deep clone.
(cfg <- ConfigList$new()) cfg$set("op1", "a", 1L) cfg cfg$get("op1")(cfg <- ConfigList$new()) cfg$set("op1", "a", 1L) cfg cfg$get("op1")
Access example SOMA objects bundled with the tiledbsoma package.
Use list_datasets() to list the available datasets and
load_dataset() to load a dataset into memory using the appropriate
SOMA class. The extract_dataset() function returns the path to the
extracted dataset without loading it into memory.
list_datasets() extract_dataset(name, dir = tempdir()) load_dataset(name, dir = tempdir(), tiledbsoma_ctx = NULL, context = NULL)list_datasets() extract_dataset(name, dir = tempdir()) load_dataset(name, dir = tempdir(), tiledbsoma_ctx = NULL, context = NULL)
name |
The name of the dataset. |
dir |
The directory where the dataset will be extracted to
(default: |
tiledbsoma_ctx |
Optional (DEPRECATED) TileDB “Context” object
that defaults to |
context |
Optional |
The SOMA objects are stored as tar.gz files in the package's
extdata directory. Calling load_dataset() extracts the
tar.gz file to the specified dir, inspects its metadata to
determine the appropriate SOMA class to instantiate, and returns the
SOMA object.
list_datasets(): returns a character vector of the
available datasets.
extract_dataset(): returns the path to the extracted dataset.
load_dataset(): returns a SOMA object.
list_datasets() dir <- withr::local_tempfile(pattern = "pbmc-small") dir.create(dir, recursive = TRUE) dest <- extract_dataset("soma-exp-pbmc-small", dir) list.files(dest) dir <- withr::local_tempfile(pattern = "pbmc_small") dir.create(dir, recursive = TRUE) (exp <- load_dataset("soma-exp-pbmc-small", dir))list_datasets() dir <- withr::local_tempfile(pattern = "pbmc-small") dir.create(dir, recursive = TRUE) dest <- extract_dataset("soma-exp-pbmc-small", dir) list.files(dest) dir <- withr::local_tempfile(pattern = "pbmc_small") dir.create(dir, recursive = TRUE) (exp <- load_dataset("soma-exp-pbmc-small", dir))
Retrieve the current default SOMAContext used by TileDB-SOMA
operations.
get_default_context()get_default_context()
This function returns the context that was either:
Explicitly set via set_default_context, or
Automatically created when a SOMA object was first created
An error is raised if no default context is set.
The context that will be used for TileDB-SOMA API when no context is provided by the user.
A re-indexer for unique integer indices
new()
Create a new re-indexer
IntIndexer$new(data)
dataInteger keys used to build the index (hash) table
get_indexer()
Get the underlying indices for the target data
IntIndexer$get_indexer(target, nomatch_na = FALSE)
targetData to re-index
nomatch_naSet non-matches to NA instead of -1
A vector of 64-bit integers with target re-indexed
clone()
The objects of this class are cloneable with this method.
IntIndexer$clone(deep = FALSE)
deepWhether to make a deep clone.
(keys <- c(-10000, -100000, 200000, 5, 1, 7)) (lookups <- unlist(replicate(n = 4L, c(-1L, 1:5), simplify = FALSE))) indexer <- IntIndexer$new(keys) indexer$get_indexer(lookups) indexer$get_indexer(lookups, nomatch_na = TRUE)(keys <- c(-10000, -100000, 200000, 5, 1, 7)) (lookups <- unlist(replicate(n = 4L, c(-1L, 1:5), simplify = FALSE))) indexer <- IntIndexer$new(keys) indexer$get_indexer(lookups) indexer$get_indexer(lookups, nomatch_na = TRUE)
Zero-based Wrapper for Sparse Matrices
Zero-based Wrapper for Sparse Matrices
matrixZeroBasedView is a wrapper shim for a matrix or
Matrix::sparseMatrix that allows
elemental matrix access using zero-based indices.
new()
Initialize (lifecycle: maturing).
matrixZeroBasedView$new(x)
xA matrix.
take()
Zero-based matrix element access.
matrixZeroBasedView$take(i = NULL, j = NULL)
iRow index (zero-based).
jColumn index (zero-based).
The specified matrix slice as another matrixZeroBasedView.
dim()
dim.
matrixZeroBasedView$dim()
The dimensions of the matrix.
nrow()
nrow.
matrixZeroBasedView$nrow()
Matrix row count.
ncol()
ncol.
matrixZeroBasedView$ncol()
Matrix column count.
get_one_based_matrix()
Get the one-based R matrix with its original class.
matrixZeroBasedView$get_one_based_matrix()
One-based matrix.
sum()
Perform arithmetic sum between this
matrixZeroBasedView and another matrixZeroBasedView.
matrixZeroBasedView$sum(x)
xthe matrixZeroBasedView to sum.
The result of the sum as a matrixZeroBasedView.
print()
print.
matrixZeroBasedView$print()
Invisibly returns self.
clone()
The objects of this class are cloneable with this method.
matrixZeroBasedView$clone(deep = FALSE)
deepWhether to make a deep clone.
(mat <- Matrix::rsparsematrix(3L, 3L, 0.3)) (mat0 <- matrixZeroBasedView$new(mat)) mat0$take(0, 0) mat0$take(0, 0:2)$get_one_based_matrix()(mat <- Matrix::rsparsematrix(3L, 3L, 0.3)) (mat0 <- matrixZeroBasedView$new(mat)) mat0$take(0, 0) mat0$take(0, 0:2)$get_one_based_matrix()
An R6 mapping type for configuring various “parameters” for multiple
“platforms”, essentially serves a multi-nested map where the inner
map is a ScalarMap contained within a ConfigList
(middle map):
{platform: {param: {key: value}}}
tiledbsoma::MappingBase -> PlatformConfig
platforms()
PlatformConfig$platforms()
The names of the “platforms” (outer keys)
params()
PlatformConfig$params(platform = NULL)
platformThe “platform” to pull parameter names
(middle keys)
for; pass TRUE to return all possible parameter names
The parameter names (middle keys) for platform
get()
PlatformConfig$get( platform, param = NULL, key = NULL, default = quote(expr = ) )
platformThe name of the “platform” (outer key) to fetch
paramThe name of the “paramters” of platform
to fetch; if NULL, returns the
configuration for platform
keyThe “key” (inner key) for param in
platform to fetch; if NULL and param is passed,
returns the map for param
in platform
defaultDefault value to fetch if key is not found;
defaults to null
The value of key for param in platform in the
map, or default if key is not found
get_params()
PlatformConfig$get_params(platform)
platformThe name of the “platform” (outer key) to fetch
The ConfigList for platform
set()
PlatformConfig$set(platform, param, key, value)
platformThe name of the “platform” (outer key) to set
paramName of the “parameter” (middle key) in
platform to set
keyInner key to set
valueValue to add for key, or NULL to remove the
entry for key; optionally provide only platfomr,
param, and value as a ScalarMap to
update param for platform with the keys and values
from value
\[chainable\] Invisibly returns self with value
added for key in param for platform
setv()
PlatformConfig$setv(...)
...Ignored
Nothing; setv() is disabled for
PlatformConfig objects
clone()
The objects of this class are cloneable with this method.
PlatformConfig$clone(deep = FALSE)
deepWhether to make a deep clone.
(cfg <- PlatformConfig$new()) cfg$set("plat1", "op1", "a", 1L) cfg cfg$get("plat1") cfg$get("plat1")$get("op1")(cfg <- PlatformConfig$new()) cfg$set("plat1", "op1", "a", 1L) cfg cfg$get("plat1") cfg$get("plat1")$get("op1")
Configure a default SOMAContext to be used by all TileDB-SOMA
operations when no explicit context is provided.
set_default_context(config = NULL, replace = FALSE)set_default_context(config = NULL, replace = FALSE)
config |
... |
replace |
Allow replacing the existing default context with new configuration parameters. |
This function should be called once at the beginning of your session before opening any SOMA objects if you want to customize the TileDB context parameters that will apply to all subsequent operations. Otherwise, a default context will be created automatically with standard parameters when you first open a SOMA object.
If the global context was already set, an error will be raised unless
replace=True. Setting a new default context will not change the
context for TileDB-SOMA objects that were already created.
Invisibly, the default default context object.
Set the logging level for the R package and underlying C++ library
set_log_level(level)set_log_level(level)
level |
A character value with logging level. May be “trace”, “debug”, “info”, or “warn” |
Invisibly returns NULL
Print version information for tiledb (R package), libtiledbsoma, and TileDB embedded, suitable for assisting with bug reports.
show_package_versions()show_package_versions()
show_package_versions()show_package_versions()
Construct a single-axis query object with a combination of
coordinates and/or value filters for use with SOMAExperimentAxisQuery.
(lifecycle: maturing)
Per dimension, the SOMAAxisQuery can have value of:
None (i.e., coords = NULL and value_filter = NULL) - read all values
Coordinates - a set of coordinates on the axis dataframe index, expressed
in any type or format supported by SOMADataFrame's read() method.
A SOMA value_filter across columns in the axis dataframe, expressed as
string
Or, a combination of coordinates and value filter.
coordsThe coordinates for the query.
value_filterThe value filter for the query.
new()
Create a new SOMAAxisQuery object.
SOMAAxisQuery$new(value_filter = NULL, coords = NULL)
value_filterOptional string containing a logical expression that is used to filter the returned values.
coordsOptional indices specifying the rows to read: either a vector of the appropriate type or a named list of vectors corresponding to each dimension.
clone()
The objects of this class are cloneable with this method.
SOMAAxisQuery$clone(deep = FALSE)
deepWhether to make a deep clone.
tiledb::parse_query_condition() for more information about valid
value filters.
SOMAExperiment Axis Query ResultAccess SOMAExperimentAxisQuery results.
obsarrow::Table containing obs query slice.
vararrow::Table containing var query slice.
measurement_name.
X_layersnamed list of arrow::Tables for each X layer.
new()
Create a new SOMAAxisQueryResult object.
SOMAAxisQueryResult$new(obs, var, X_layers)
obs, vararrow::Table containing obs or var query slice.
X_layersnamed list of arrow::Tables, one for each X layer.
clone()
The objects of this class are cloneable with this method.
SOMAAxisQueryResult$clone(deep = FALSE)
deepWhether to make a deep clone.
Contains a key-value mapping where the keys are string names and
the values are any SOMA-defined foundational or composed type, including
SOMACollection, SOMADataFrame,
SOMADenseNDArray, SOMASparseNDArray, or
SOMAExperiment (lifecycle: maturing).
The SOMACollection class provides a number of type-specific methods for
adding new a object to the collection, such as add_new_sparse_ndarray() and
add_new_dataframe(). These methods will create the new object and add it as
member of the SOMACollection. The new object will always inherit the parent
context (see SOMATileDBContext) and, by default, its platform
configuration (see PlatformConfig). However, the user can override the
default platform configuration by passing a custom configuration to the
platform_config argument.
When working with Carrara URIs (tiledb://workspace/teamspace/...), child
objects created at a URI nested under a parent collection are automatically
added as members of the parent. This means:
You do not need to call add_new_collection() after creating a child
at a nested URI—the child is already a member.
For backward compatibility, calling add_new_collection() on an
already-registered child is a no-op and will not cause an error.
The member name must match the relative URI segment (e.g., creating
at parent_uri/child automatically adds the child with key "child").
tiledbsoma::SOMAObject -> tiledbsoma::SOMACollectionBase -> SOMACollection
tiledbsoma::SOMAObject$class()tiledbsoma::SOMAObject$exists()tiledbsoma::SOMAObject$get_metadata()tiledbsoma::SOMAObject$initialize()tiledbsoma::SOMAObject$is_open()tiledbsoma::SOMAObject$mode()tiledbsoma::SOMAObject$reopen()tiledbsoma::SOMACollectionBase$add_new_collection()tiledbsoma::SOMACollectionBase$add_new_dataframe()tiledbsoma::SOMACollectionBase$add_new_dense_ndarray()tiledbsoma::SOMACollectionBase$add_new_sparse_ndarray()tiledbsoma::SOMACollectionBase$close()tiledbsoma::SOMACollectionBase$create()tiledbsoma::SOMACollectionBase$get()tiledbsoma::SOMACollectionBase$length()tiledbsoma::SOMACollectionBase$names()tiledbsoma::SOMACollectionBase$open()tiledbsoma::SOMACollectionBase$print()tiledbsoma::SOMACollectionBase$remove()tiledbsoma::SOMACollectionBase$set()tiledbsoma::SOMACollectionBase$set_metadata()clone()
The objects of this class are cloneable with this method.
SOMACollection$clone(deep = FALSE)
deepWhether to make a deep clone.
uri <- withr::local_tempfile(pattern = "soma-collection") (col <- SOMACollectionCreate(uri)) col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L)) col$close() (col <- SOMACollectionOpen(uri)) col$names()uri <- withr::local_tempfile(pattern = "soma-collection") (col <- SOMACollectionCreate(uri)) col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L)) col$close() (col <- SOMACollectionOpen(uri)) col$names()
Factory function to create a SOMA collection for writing (lifecycle: maturing).
SOMACollectionCreate( uri, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMACollectionCreate( uri, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
ingest_mode |
Ingestion mode when creating the TileDB object; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp. |
context |
Optional |
A new SOMA collection stored at
uri opened for writing.
uri <- withr::local_tempfile(pattern = "soma-collection") (col <- SOMACollectionCreate(uri)) col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L)) col$close() (col <- SOMACollectionOpen(uri)) col$names()uri <- withr::local_tempfile(pattern = "soma-collection") (col <- SOMACollectionCreate(uri)) col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L)) col$close() (col <- SOMACollectionOpen(uri)) col$names()
Factory function to open a SOMA collection for reading (lifecycle: maturing).
SOMACollectionOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMACollectionOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp;
defaults to the current time. If not |
context |
Optional |
A SOMA collection stored at
uri opened in mode mode.
uri <- withr::local_tempfile(pattern = "soma-collection") (col <- SOMACollectionCreate(uri)) col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L)) col$close() (col <- SOMACollectionOpen(uri)) col$names()uri <- withr::local_tempfile(pattern = "soma-collection") (col <- SOMACollectionCreate(uri)) col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L)) col$close() (col <- SOMACollectionOpen(uri)) col$names()
Context map for TileDB-SOMA objects
handleExternal pointer to the C++ interface
new()
SOMAContext$new(config = NULL)
config...
An instantiated SOMATileDBContext object
get_config()
SOMAContext$get_config()
A character vector with the current config options set on the context.
get_data_protocol()
SOMAContext$get_data_protocol(uri)
uriA URI for a SOMA object
The data protocol to use for the URI.
is_tiledbv2()
SOMAContext$is_tiledbv2(uri)
uriA URI for a SOMA object
TRUE if the URI will use tiledbv2 semantics.
is_tiledbv3()
SOMAContext$is_tiledbv3(uri)
uriA URI for a SOMA object
TRUE if the URI will use tiledbv3 semantics.
clone()
The objects of this class are cloneable with this method.
SOMAContext$clone(deep = FALSE)
deepWhether to make a deep clone.
A SOMA data frame is a multi-column table that must contain a
column called “soma_joinid” of type int64, which
contains a unique value for each row and is intended to act as a join key for
other objects, such as SOMASparseNDArray (lifecycle: maturing).
tiledbsoma::SOMAObject -> tiledbsoma::SOMAArrayBase -> SOMADataFrame
tiledbsoma::SOMAObject$class()tiledbsoma::SOMAObject$exists()tiledbsoma::SOMAObject$get_metadata()tiledbsoma::SOMAObject$initialize()tiledbsoma::SOMAObject$is_open()tiledbsoma::SOMAObject$mode()tiledbsoma::SOMAObject$reopen()tiledbsoma::SOMAObject$set_metadata()tiledbsoma::SOMAArrayBase$allows_duplicates()tiledbsoma::SOMAArrayBase$attributes()tiledbsoma::SOMAArrayBase$attrnames()tiledbsoma::SOMAArrayBase$close()tiledbsoma::SOMAArrayBase$colnames()tiledbsoma::SOMAArrayBase$dimensions()tiledbsoma::SOMAArrayBase$dimnames()tiledbsoma::SOMAArrayBase$index_column_names()tiledbsoma::SOMAArrayBase$is_sparse()tiledbsoma::SOMAArrayBase$ndim()tiledbsoma::SOMAArrayBase$non_empty_domain()tiledbsoma::SOMAArrayBase$open()tiledbsoma::SOMAArrayBase$print()tiledbsoma::SOMAArrayBase$schema()create()
Create a SOMA data frame (lifecycle: maturing).
Note: $create() is considered internal and should not be
called directly; use factory functions
(eg. SOMADataFrameCreate()) instead.
SOMADataFrame$create(
schema,
index_column_names = c("soma_joinid"),
domain = NULL,
platform_config = NULL
)schemaAn Arrow schema.
index_column_namesA vector of column names to use as user-defined index columns. All named columns must exist in the schema, and at least one index column name is required.
domainAn optional list specifying the domain of each
index column. Each slot in the list must have its name being the name
of an index column, and its value being be a length-two vector
consisting of the minimum and maximum values storable in the index
column. For example, if there is a single int64-valued index column
soma_joinid, then domain might be
list(soma_joinid=c(100, 200)) to indicate that values between 100
and 200, inclusive, can be stored in that column. If provided, this
sequence must have the same length as index_column_names, and the
index-column domain will be as specified. Omitting or setting the domain
to NULL is deprecated. See also change_domain which allows
you to expand the domain after create.
platform_configA platform configuration object
Returns self.
write()
Write values to the data frame (lifecycle: maturing).
SOMADataFrame$write(values)
valuesAn Arrow table or
Arrow record batch containing all columns,
including any index columns. The schema for values must match the
schema for the data frame.
Invisibly returns self.
read()
Read a user-defined subset of data, addressed by the data frame indexing column, and optionally filtered (lifecycle: maturing).
SOMADataFrame$read( coords = NULL, column_names = NULL, value_filter = NULL, result_order = "auto", log_level = "auto" )
coordsOptional named list of indices specifying the rows to read; each (named) list element corresponds to a dimension of the same name.
column_namesOptional character vector of column names to return.
value_filterOptional string containing a logical expression that
is used to filter the returned values. See
tiledb::parse_query_condition()
for more information.
result_orderOptional order of read results. This can be one of either
"ROW_MAJOR, "COL_MAJOR", or "auto"' (default).
log_levelOptional logging level with default value of
“warn”.
An Arrow table or TableReadIter
update()
Update (lifecycle: maturing).
SOMADataFrame$update(values, row_index_name = NULL)
valuesA data frame, Arrow table, or Arrow record batch.
row_index_nameAn optional scalar character. If provided, and if
the values argument is a data frame with row names, then the row
names will be extracted and added as a new column to the data frame
prior to performing the update. The name of this new column will be set
to the value specified by row_index_name.
Update the existing SOMADataFrame to add or remove columns based
on the input:
columns present in the current the SOMADataFrame but absent
from the new values will be dropped.
columns absent in current SOMADataFrame but present in the
new values will be added.
any columns present in both will be left alone, with the
exception that if values has a different type for the column,
the entire update will fail because attribute types cannot be changed.
Furthermore, values must contain the same number of rows as the
current SOMADataFrame.
Invisibly returns NULL
levels()
Get the levels for an enumerated (factor) column.
SOMADataFrame$levels(column_names = NULL, simplify = TRUE)
column_namesOptional character vector of column names to pull enumeration levels for; defaults to all enumerated columns.
simplifySimplify the result down to a vector or matrix.
If simplify returns one of the following:
a vector of there is only one enumerated column.
a matrix if there are multiple enumerated columns with the same number of levels.
a named list if there are multiple enumerated columns with differing numbers of levels.
Otherwise, returns a named list.
shape()
Retrieve the shape; as SOMADataFrames are shapeless,
simply raises an error.
SOMADataFrame$shape()
None, instead a .NotYetImplemented() error
is raised.
maxshape()
Retrieve the max shape; as SOMADataFrames are
shapeless, simply raises an error.
SOMADataFrame$maxshape()
None, instead a .NotYetImplemented() error
is raised.
domain()
Returns a named list of minimum/maximum pairs, one per index
column, currently storable on each index column of the data frame. These
can be resized up to maxdomain (lifecycle: maturing).
SOMADataFrame$domain()
Named list of minimum/maximum values.
maxdomain()
Returns a named list of minimum/maximum pairs, one per index column, which are the limits up to which the data frame can have its domain resized (lifecycle: maturing).
SOMADataFrame$maxdomain()
Named list of minimum/maximum values.
tiledbsoma_has_upgraded_domain()
Test if the array has the upgraded resizeable domain feature
from TileDB-SOMA 1.15, the array was created with this support, or it has
had $upgrade_domain() applied to it (lifecycle: maturing).
SOMADataFrame$tiledbsoma_has_upgraded_domain()
Returns TRUE if the array has the upgraded resizable
domain feature; otherwise, returns FALSE.
tiledbsoma_resize_soma_joinid_shape()
Increases the shape of the data frame on the
soma_joinid index column, if it indeed is an index column, leaving
all other index columns as-is. If the soma_joinid is not an index
column, no change is made. This is a special case of
upgrade_domain(), but simpler to keystroke, and
handles the most common case for data frame domain expansion. Raises an
error if the data frame doesn't already have a domain; in that case
please call $tiledbsoma_upgrade_domain().
SOMADataFrame$tiledbsoma_resize_soma_joinid_shape(new_shape)
new_shapeAn integer, greater than or equal to 1 + the
soma_joinid domain slot.
Invisibly returns NULL
tiledbsoma_upgrade_domain()
Allows you to set the domain of a SOMADataFrame,
when the SOMADataFrame does not have a domain set yet. The
argument must be a list of pairs of low/high values for the desired
domain, one pair per index column. For string index columns, you must
offer the low/high pair as c("", ""), or as NULL. If
check_only is True, returns whether the operation would
succeed if attempted, or a reason why it would not. The domain being
requested must be contained within what $maxdomain() returns.
SOMADataFrame$tiledbsoma_upgrade_domain(new_domain, check_only = FALSE)
new_domainA named list, keyed by index-column name, with values being two-element vectors containing the desired lower and upper bounds for the domain.
check_onlyIf true, does not apply the operation, but only reports whether it would have succeeded.
If check_only, returns the empty string if no error is
detected, else a description of the error. Otherwise, invisibly returns
NULL
change_domain()
Allows you to set the domain of a SOMADataFrame, when
the SOMADataFrame already has a domain set yet. The argument must
be a list of pairs of low/high values for the desired domain, one pair
per index column. For string index columns, you must offer the low/high
pair as c("", ""), or as NULL. If check_only is
True, returns whether the operation would succeed if attempted,
or a reason why it would not. The return value from domain must be
contained within the requested new_domain, and the requested
new_domain must be contained within the return value from
$maxdomain() (lifecycle: maturing).
SOMADataFrame$change_domain(new_domain, check_only = FALSE)
new_domainA named list, keyed by index-column name, with values being two-element vectors containing the desired lower and upper bounds for the domain.
check_onlyIf true, does not apply the operation, but only reports whether it would have succeeded.
If check_only, returns the empty string if no error is
detected, else a description of the error. Otherwise, invisibly returns
NULL
clone()
The objects of this class are cloneable with this method.
SOMADataFrame$clone(deep = FALSE)
deepWhether to make a deep clone.
uri <- withr::local_tempfile(pattern = "soma-data-frame") df <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), group = sample(factor(c("g1", "g2")), size = 100L, replace = TRUE), nCount = stats::rbinom(100L, 10L, 0.3) ) (sch <- arrow::infer_schema(df)) (sdf <- SOMADataFrameCreate(uri, sch, domain = list(soma_joinid = c(0, 100)))) sdf$write(arrow::as_arrow_table(df, schema = sch)) sdf$close() (sdf <- SOMADataFrameOpen(uri)) head(as.data.frame(sdf$read()$concat()))uri <- withr::local_tempfile(pattern = "soma-data-frame") df <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), group = sample(factor(c("g1", "g2")), size = 100L, replace = TRUE), nCount = stats::rbinom(100L, 10L, 0.3) ) (sch <- arrow::infer_schema(df)) (sdf <- SOMADataFrameCreate(uri, sch, domain = list(soma_joinid = c(0, 100)))) sdf$write(arrow::as_arrow_table(df, schema = sch)) sdf$close() (sdf <- SOMADataFrameOpen(uri)) head(as.data.frame(sdf$read()$concat()))
Factory function to create a SOMA data frame for writing (lifecycle: maturing).
SOMADataFrameCreate( uri, schema, index_column_names = c("soma_joinid"), domain = NULL, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMADataFrameCreate( uri, schema, index_column_names = c("soma_joinid"), domain = NULL, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
schema |
Arrow schema argument for the SOMA dataframe. |
index_column_names |
A vector of column names to use as user-defined index columns; all named columns must exist in the schema, and at least one index column name is required. |
domain |
An optional list of 2-element vectors specifying the domain of
each index column. Each vector should be a pair consisting of the minimum and
maximum values storable in the index column. For example, if there is a
single int64-valued index column, then |
ingest_mode |
Ingestion mode when creating the TileDB object; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp. |
context |
Optional |
A new SOMA data frame stored at
uri opened for writing.
uri <- withr::local_tempfile(pattern = "soma-data-frame") df <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), group = sample(factor(c("g1", "g2")), size = 100L, replace = TRUE), nCount = stats::rbinom(100L, 10L, 0.3) ) (sch <- arrow::infer_schema(df)) (sdf <- SOMADataFrameCreate(uri, sch, domain = list(soma_joinid = c(0, 100)))) sdf$write(arrow::as_arrow_table(df, schema = sch)) sdf$close() (sdf <- SOMADataFrameOpen(uri)) head(as.data.frame(sdf$read()$concat()))uri <- withr::local_tempfile(pattern = "soma-data-frame") df <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), group = sample(factor(c("g1", "g2")), size = 100L, replace = TRUE), nCount = stats::rbinom(100L, 10L, 0.3) ) (sch <- arrow::infer_schema(df)) (sdf <- SOMADataFrameCreate(uri, sch, domain = list(soma_joinid = c(0, 100)))) sdf$write(arrow::as_arrow_table(df, schema = sch)) sdf$close() (sdf <- SOMADataFrameOpen(uri)) head(as.data.frame(sdf$read()$concat()))
Factory function to open a SOMA data frame for reading (lifecycle: maturing).
SOMADataFrameOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMADataFrameOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp; defaults to the current time. |
context |
Optional |
A SOMA data frame stored at
uri opened in mode mode.
uri <- withr::local_tempfile(pattern = "soma-data-frame") df <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), group = sample(factor(c("g1", "g2")), size = 100L, replace = TRUE), nCount = stats::rbinom(100L, 10L, 0.3) ) (sch <- arrow::infer_schema(df)) (sdf <- SOMADataFrameCreate(uri, sch, domain = list(soma_joinid = c(0, 100)))) sdf$write(arrow::as_arrow_table(df, schema = sch)) sdf$close() (sdf <- SOMADataFrameOpen(uri)) head(as.data.frame(sdf$read()$concat()))uri <- withr::local_tempfile(pattern = "soma-data-frame") df <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), group = sample(factor(c("g1", "g2")), size = 100L, replace = TRUE), nCount = stats::rbinom(100L, 10L, 0.3) ) (sch <- arrow::infer_schema(df)) (sdf <- SOMADataFrameCreate(uri, sch, domain = list(soma_joinid = c(0, 100)))) sdf$write(arrow::as_arrow_table(df, schema = sch)) sdf$close() (sdf <- SOMADataFrameOpen(uri)) head(as.data.frame(sdf$read()$concat()))
SOMADenseNDArray is a dense, N-dimensional array of
a primitive type, with offset (zero-based) int64 integer
indexing on each dimension with domain [0, maxInt64). The
SOMADenseNDArray has a user-defined schema, which includes:
type: a primitive type, expressed as an Arrow type
(e.g., int64, float32, etc),
indicating the type of data contained within the array.
shape: the shape of the array, i.e., number and length of each
dimension. This is a soft limit which can be increased using
$resize() up to the maxshape.
maxshape: the hard limit up to which shape may be
increased using $resize().
All dimensions must have a positive, non-zero length, and there must be 1 or more dimensions.
The default “fill” value for SOMADenseNDArray is the zero or
null value of the array type (e.g.,
arrow::float32() defaults to 0.0).
tiledbsoma::SOMAObject -> tiledbsoma::SOMAArrayBase -> tiledbsoma::SOMANDArrayBase -> SOMADenseNDArray
tiledbsoma::SOMAObject$class()tiledbsoma::SOMAObject$exists()tiledbsoma::SOMAObject$get_metadata()tiledbsoma::SOMAObject$initialize()tiledbsoma::SOMAObject$is_open()tiledbsoma::SOMAObject$mode()tiledbsoma::SOMAObject$reopen()tiledbsoma::SOMAObject$set_metadata()tiledbsoma::SOMAArrayBase$allows_duplicates()tiledbsoma::SOMAArrayBase$attributes()tiledbsoma::SOMAArrayBase$attrnames()tiledbsoma::SOMAArrayBase$close()tiledbsoma::SOMAArrayBase$colnames()tiledbsoma::SOMAArrayBase$dimensions()tiledbsoma::SOMAArrayBase$dimnames()tiledbsoma::SOMAArrayBase$index_column_names()tiledbsoma::SOMAArrayBase$is_sparse()tiledbsoma::SOMAArrayBase$maxshape()tiledbsoma::SOMAArrayBase$ndim()tiledbsoma::SOMAArrayBase$non_empty_domain()tiledbsoma::SOMAArrayBase$open()tiledbsoma::SOMAArrayBase$print()tiledbsoma::SOMAArrayBase$schema()tiledbsoma::SOMAArrayBase$shape()tiledbsoma::SOMANDArrayBase$create()tiledbsoma::SOMANDArrayBase$resize()tiledbsoma::SOMANDArrayBase$set_data_type()tiledbsoma::SOMANDArrayBase$tiledbsoma_has_upgraded_shape()tiledbsoma::SOMANDArrayBase$tiledbsoma_upgrade_shape()read_arrow_table()
Read as an Arrow table (lifecycle: maturing).
SOMADenseNDArray$read_arrow_table( coords = NULL, result_order = "auto", log_level = "auto" )
coordsOptional list of integer vectors, one for each
dimension, with a length equal to the number of values to read. If
NULL, all values are read. List elements can be named when
specifying a subset of dimensions.
result_orderOptional order of read results. This can be one of either
"ROW_MAJOR, "COL_MAJOR", or "auto"' (default).
log_levelOptional logging level with default value of
“warn”.
An Arrow table.
read_dense_matrix()
Read as a dense matrix (lifecycle: maturing).
SOMADenseNDArray$read_dense_matrix( coords = NULL, result_order = "ROW_MAJOR", log_level = "warn" )
coordsOptional list of integer vectors, one for each
dimension, with a length equal to the number of values to read. If
NULL, all values are read. List elements can be named when
specifying a subset of dimensions.
result_orderOptional order of read results. This can be one of either
"ROW_MAJOR, "COL_MAJOR", or "auto"' (default).
log_levelOptional logging level with default value of
“warn”.
A matrix.
write()
Write matrix data to the array (lifecycle: maturing).
Note: The $write() method is currently limited to writing
from two-dimensional matrices (lifecycle: maturing).
SOMADenseNDArray$write(values, coords = NULL)
valuesA matrix. Character dimension names are ignored
because SOMANDArrays use integer indexing.
coordsA list of integer vectors, one for each dimension,
with a length equal to the number of values to write. If NULL,
the default, the values are taken from the row and column names
of values.
Invisibly returns self.
clone()
The objects of this class are cloneable with this method.
SOMADenseNDArray$clone(deep = FALSE)
deepWhether to make a deep clone.
uri <- withr::local_tempfile(pattern = "soma-dense-array") mat <- matrix(stats::rnorm(100L ^ 2L), nrow = 100L, ncol = 100L) mat[1:3, 1:5] (arr <- SOMADenseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMADenseNDArrayOpen(uri)) arr$read_arrow_table()uri <- withr::local_tempfile(pattern = "soma-dense-array") mat <- matrix(stats::rnorm(100L ^ 2L), nrow = 100L, ncol = 100L) mat[1:3, 1:5] (arr <- SOMADenseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMADenseNDArrayOpen(uri)) arr$read_arrow_table()
Factory function to create a SOMA dense ND array for writing (lifecycle: maturing).
SOMADenseNDArrayCreate( uri, type, shape, platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMADenseNDArrayCreate( uri, type, shape, platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
type |
An Arrow type defining the type of each element in the array. |
shape |
A vector of integers defining the shape of the array. |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp. |
context |
Optional |
A new SOMA dense ND array
stored at uri opened for writing.
uri <- withr::local_tempfile(pattern = "soma-dense-array") mat <- matrix(stats::rnorm(100L ^ 2L), nrow = 100L, ncol = 100L) mat[1:3, 1:5] (arr <- SOMADenseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMADenseNDArrayOpen(uri)) arr$read_arrow_table()uri <- withr::local_tempfile(pattern = "soma-dense-array") mat <- matrix(stats::rnorm(100L ^ 2L), nrow = 100L, ncol = 100L) mat[1:3, 1:5] (arr <- SOMADenseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMADenseNDArrayOpen(uri)) arr$read_arrow_table()
Factory function to open a SOMA dense ND array for reading (lifecycle: maturing).
SOMADenseNDArrayOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMADenseNDArrayOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp; defaults to the current time. |
context |
Optional |
A SOMA dense ND array stored at
uri opened in mode mode.
uri <- withr::local_tempfile(pattern = "soma-dense-array") mat <- matrix(stats::rnorm(100L ^ 2L), nrow = 100L, ncol = 100L) mat[1:3, 1:5] (arr <- SOMADenseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMADenseNDArrayOpen(uri)) arr$read_arrow_table()uri <- withr::local_tempfile(pattern = "soma-dense-array") mat <- matrix(stats::rnorm(100L ^ 2L), nrow = 100L, ncol = 100L) mat[1:3, 1:5] (arr <- SOMADenseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMADenseNDArrayOpen(uri)) arr$read_arrow_table()
SOMAExperiment is a specialized
SOMACollection, representing one or more modes of measurement
across a single collection of cells (aka a “multimodal dataset”) with
pre-defined fields: obs and ms (see Active Bindings below
for details) (lifecycle: maturing).
The SOMAExperiment class provides a number of type-specific methods for
adding new a object to the collection, such as add_new_sparse_ndarray() and
add_new_dataframe(). These methods will create the new object and add it as
member of the SOMAExperiment. The new object will always inherit the parent
context (see SOMATileDBContext) and, by default, its platform
configuration (see PlatformConfig). However, the user can override the
default platform configuration by passing a custom configuration to the
platform_config argument.
When working with Carrara URIs (tiledb://workspace/teamspace/...), child
objects created at a URI nested under a parent collection are automatically
added as members of the parent. This means:
You do not need to call add_new_collection() after creating a child
at a nested URI—the child is already a member.
For backward compatibility, calling add_new_collection() on an
already-registered child is a no-op and will not cause an error.
The member name must match the relative URI segment (e.g., creating
at parent_uri/child automatically adds the child with key "child").
tiledbsoma::SOMAObject -> tiledbsoma::SOMACollectionBase -> SOMAExperiment
obsA SOMADataFrame containing primary annotations
on the observation axis. The contents of the soma_joinid column
define the observation index domain, obs_id. All observations for
the SOMAExperiment must be defined in this data frame.
msA SOMACollection of named
SOMAMeasurements.
tiledbsoma::SOMAObject$class()tiledbsoma::SOMAObject$exists()tiledbsoma::SOMAObject$get_metadata()tiledbsoma::SOMAObject$initialize()tiledbsoma::SOMAObject$is_open()tiledbsoma::SOMAObject$mode()tiledbsoma::SOMAObject$reopen()tiledbsoma::SOMACollectionBase$add_new_collection()tiledbsoma::SOMACollectionBase$add_new_dataframe()tiledbsoma::SOMACollectionBase$add_new_dense_ndarray()tiledbsoma::SOMACollectionBase$add_new_sparse_ndarray()tiledbsoma::SOMACollectionBase$close()tiledbsoma::SOMACollectionBase$create()tiledbsoma::SOMACollectionBase$get()tiledbsoma::SOMACollectionBase$length()tiledbsoma::SOMACollectionBase$names()tiledbsoma::SOMACollectionBase$open()tiledbsoma::SOMACollectionBase$print()tiledbsoma::SOMACollectionBase$remove()tiledbsoma::SOMACollectionBase$set()tiledbsoma::SOMACollectionBase$set_metadata()axis_query()
Subset and extract data from a SOMAMeasurement
by querying the obs/var axes.
SOMAExperiment$axis_query(measurement_name, obs_query = NULL, var_query = NULL)
measurement_nameThe name of the measurement to query.
obs_query, var_queryAn SOMAAxisQuery object for the
obs/var axis.
A SOMAExperimentAxisQuery object.
update_obs()
Update the obs data frame to add or remove columns.
See SOMADataFrame$update() for
more details.
SOMAExperiment$update_obs(values, row_index_name = NULL)
valuesA data frame, Arrow table, or Arrow record batch.
row_index_nameAn optional scalar character. If provided, and if
the values argument is a data frame with row names, then the row
names will be extracted and added as a new column to the data frame
prior to performing the update. The name of this new column will be set
to the value specified by row_index_name.
update_var()
Update the var data frame to add or remove columns.
See SOMADataFrame$update() for
more details.
SOMAExperiment$update_var(values, measurement_name, row_index_name = NULL)
valuesA data frame, Arrow table, or Arrow record batch.
measurement_nameThe name of the SOMAMeasurement
whose var will be updated.
row_index_nameAn optional scalar character. If provided, and if
the values argument is a data frame with row names, then the row
names will be extracted and added as a new column to the data frame
prior to performing the update. The name of this new column will be set
to the value specified by row_index_name.
clone()
The objects of this class are cloneable with this method.
SOMAExperiment$clone(deep = FALSE)
deepWhether to make a deep clone.
uri <- withr::local_tempfile(pattern = "soma-experiment") obs <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), obs_id = paste0("cell_", seq_len(100L)) ) sch <- arrow::infer_schema(obs) (exp <- SOMAExperimentCreate(uri)) sdf <- exp$add_new_dataframe( "obs", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(obs, schema = sch)) sdf$close() exp$close() (exp <- SOMAExperimentOpen(uri)) exp$obsuri <- withr::local_tempfile(pattern = "soma-experiment") obs <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), obs_id = paste0("cell_", seq_len(100L)) ) sch <- arrow::infer_schema(obs) (exp <- SOMAExperimentCreate(uri)) sdf <- exp$add_new_dataframe( "obs", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(obs, schema = sch)) sdf$close() exp$close() (exp <- SOMAExperimentOpen(uri)) exp$obs
SOMAExperiment Axis QueryPerform an axis-based query against a SOMAExperiment.
SOMAExperimentAxisQuery allows easy selection and extraction of data from a
single SOMAMeasurement in a SOMAExperiment, by obs/var (axis)
coordinates and/or value filter. The primary use for this class is slicing
SOMAExperiment X layers by obs or var value and/or coordinates.
(lifecycle: maturing)
Slicing on SOMASparseNDArray X matrices is supported;
slicing on SOMADenseNDArray is not supported at this time.
SOMAExperimentAxisQuery query class assumes it can store the full result of
both axis dataframe queries in memory, and only provides incremental access
to the underlying X NDArray. Accessors such as n_obs and n_vars codify
this in the class.
experimentThe parent SOMAExperiment object.
indexerThe SOMAAxisIndexer object.
obs_queryThe obs SOMAAxisQuery object.
var_queryThe var SOMAAxisQuery object.
n_obsThe number of obs axis query results.
n_varsThe number of var axis query results.
obs_dfThe obs SOMADataFrame object.
var_dfThe var SOMADataFrame object for the specified
measurement_name.
msThe SOMAMeasurement object for the specified
measurement_name.
new()
Create a new SOMAExperimentAxisQuery object.
SOMAExperimentAxisQuery$new( experiment, measurement_name, obs_query = NULL, var_query = NULL )
experimentA SOMAExperiment object.
measurement_nameThe name of the measurement to query.
obs_query, var_queryAn SOMAAxisQuery object for the obs/var
axis.
obs()
Retrieve obs TableReadIter
SOMAExperimentAxisQuery$obs(column_names = NULL)
column_namesA character vector of column names to retrieve
var()
Retrieve var arrow::Table
SOMAExperimentAxisQuery$var(column_names = NULL)
column_namesA character vector of column names to retrieve
obs_joinids()
Retrieve soma_joinids as an arrow::Array for obs.
SOMAExperimentAxisQuery$obs_joinids()
var_joinids()
Retrieve soma_joinids as an arrow::Array for var.
SOMAExperimentAxisQuery$var_joinids()
X()
Retrieves an X layer as a SOMASparseNDArrayRead
SOMAExperimentAxisQuery$X(layer_name)
layer_nameThe name of the layer to retrieve.
obsm()
Retrieves an obsm layer as a
SOMASparseNDArrayRead
SOMAExperimentAxisQuery$obsm(layer_name)
layer_nameThe name of the layer to retrieve
varm()
Retrieves a varm layer as a
SOMASparseNDArrayRead
SOMAExperimentAxisQuery$varm(layer_name)
layer_nameThe name of the layer to retrieve
obsp()
Retrieves an obsp layer as a
SOMASparseNDArrayRead
SOMAExperimentAxisQuery$obsp(layer_name)
layer_nameThe name of the layer to retrieve
varp()
Retrieves a varp layer as a
SOMASparseNDArrayRead
SOMAExperimentAxisQuery$varp(layer_name)
layer_nameThe name of the layer to retrieve
read()
Reads the entire query result as a list of
arrow::Tables. This is a low-level routine intended to be used by
loaders for other in-core formats, such as Seurat, which can be created
from the resulting Tables.
SOMAExperimentAxisQuery$read( X_layers = NULL, obs_column_names = NULL, var_column_names = NULL )
X_layersThe name(s) of the X layer(s) to read and return.
obs_column_names, var_column_namesSpecify which column names in
var and obs dataframes to read and return.
to_sparse_matrix()
Retrieve a collection layer as a sparse matrix with named dimensions.
Load any layer from the X, obsm, varm, obsp, or varp
collections as a sparse matrix.
By default the matrix dimensions are named using the soma_joinid values
in the specified layer's dimensions (e.g., soma_dim_0). However,
dimensions can be named using values from any obs or var column that
uniquely identifies each record by specifying the obs_index and
var_index arguments.
For layers in obsm or varm, the column axis (the axis not
indexed by “obs” or “var”) is set to the
range of values present in “soma_dim_1”; this ensures
that gaps in this axis are preserved (eg. when a query for
“obs” that results in selecting entries that are all zero
for a given PC)
SOMAExperimentAxisQuery$to_sparse_matrix( collection, layer_name, obs_index = NULL, var_index = NULL )
collectionThe SOMACollection containing the layer of
interest, either: "X", "obsm", "varm", "obsp", or "varp".
layer_nameName of the layer to retrieve from the collection.
obs_index, var_indexName of the column in obs or var
(var_index) containing values that should be used as dimension labels
in the resulting matrix. Whether the values are used as row or column
labels depends on the selected collection:
| Collection | obs_index |
var_index |
X |
row names | column names |
obsm |
row names | ignored |
varm |
ignored | row names |
obsp |
row and column names | ignored |
varp |
ignored | row and column names |
to_seurat()
Loads the query as a
Seurat object
SOMAExperimentAxisQuery$to_seurat( X_layers = c(counts = "counts", data = "logcounts"), obs_index = NULL, var_index = NULL, obs_column_names = NULL, var_column_names = NULL, obsm_layers = NULL, varm_layers = NULL, obsp_layers = NULL, drop_levels = FALSE, version = NULL )
X_layersA named character of X layers to add to the Seurat assay
where the names are the names of Seurat slots and the values are the
names of layers within X; names should be one of:
“counts” to add the layer as counts
“data” to add the layer as data
“scale.data” to add the layer as scale.data
At least one of “counts” or “data” is required
obs_indexName of column in obs to add as cell names; uses
paste0("cell", obs_joinids()) by default
var_indexName of column in var to add as feature names;
uses paste0("feature", var_joinids()) by default
obs_column_namesNames of columns in obs to add as
cell-level meta data; by default, loads all columns
var_column_namesNames of columns in var to add as
feature-level meta data; by default, loads all columns
obsm_layersNames of arrays in obsm to add as the cell
embeddings; pass FALSE to suppress loading in any dimensional
reductions; by default, loads all dimensional reduction information
varm_layersNamed vector of arrays in varm to load in as
the feature loadings; names must be names of arrays in obsm
(eg. varm_layers = c(X_pca = "PCs")); pass FALSE to
suppress loading in any feature loadings; will try to determine
varm_layers from obsm_layers
obsp_layersNames of arrays in obsp to load in as
Graphs; by default, loads all graphs
drop_levelsDrop unused levels from obs and var
factor columns
versionAssay version to read query in as; by default, will try to infer assay type from the measurement itself
A Seurat object
to_seurat_assay()
Loads the query as a Seurat Assay
SOMAExperimentAxisQuery$to_seurat_assay( X_layers = c(counts = "counts", data = "logcounts"), obs_index = NULL, var_index = NULL, var_column_names = NULL, drop_levels = FALSE, version = NULL )
X_layersA named character of X layers to add to the Seurat assay
where the names are the names of Seurat slots and the values are the
names of layers within X; names should be one of:
“counts” to add the layer as counts
“data” to add the layer as data
“scale.data” to add the layer as scale.data
At least one of “counts” or “data” is required
obs_indexName of column in obs to add as cell names; uses
paste0("cell", obs_joinids()) by default
var_indexName of column in var to add as feature names;
uses paste0("feature", var_joinids()) by default
var_column_namesNames of columns in var to add as
feature-level meta data; by default, loads all columns
drop_levelsDrop unused levels from var factor columns
versionAssay version to read query in as; by default, will try to infer assay type from the measurement itself
An Assay object
to_seurat_reduction()
Loads the query as a Seurat dimensional reduction
SOMAExperimentAxisQuery$to_seurat_reduction( obsm_layer, varm_layer = NULL, obs_index = NULL, var_index = NULL )
obsm_layerName of array in obsm to load as the
cell embeddings
varm_layerName of the array in varm to load as the
feature loadings; by default, will try to determine varm_layer
from obsm_layer
obs_indexName of column in obs to add as cell names; uses
paste0("cell", obs_joinids()) by default
var_indexName of column in var to add as feature names;
uses paste0("feature", var_joinids()) by default
A DimReduc object
to_seurat_graph()
Loads the query as a Seurat graph
SOMAExperimentAxisQuery$to_seurat_graph(obsp_layer, obs_index = NULL)
obsp_layerName of array in obsp to load as the graph
obs_indexName of column in obs to add as cell names; uses
paste0("cell", obs_joinids()) by default
A Graph object
to_single_cell_experiment()
Loads the query as a
SingleCellExperiment object
SOMAExperimentAxisQuery$to_single_cell_experiment( X_layers = NULL, obs_index = NULL, var_index = NULL, obs_column_names = NULL, var_column_names = NULL, obsm_layers = NULL, obsp_layers = NULL, varp_layers = NULL, drop_levels = FALSE )
X_layersA character vector of X layers to add as assays in the
main experiment; may optionally be named to set the name of the resulting
assay (eg. X_layers = c(counts = "raw") will load in X layer
“raw” as assay “counts”); by default, loads
in all X layers
obs_indexName of column in obs to add as cell names; uses
paste0("cell", obs_joinids()) by default
var_indexName of column in var to add as feature names;
uses paste0("feature", var_joinids()) by default
obs_column_namesNames of columns in obs to add as
colData; by default, loads all columns
var_column_namesNames of columns in var to add as
rowData; by default, loads all columns
obsm_layersNames of arrays in obsm to add as the reduced
dimensions; pass FALSE to suppress loading in any reduced
dimensions; by default, loads all reduced dimensions
obsp_layersNames of arrays in obsp to load in as
SelfHits; by default, loads all graphs
varp_layersNames of arrays in varp to load in as
SelfHits; by default, loads all networks
drop_levelsDrop unused levels from obs and var
factor columns
A SingleCellExperiment object
clone()
The objects of this class are cloneable with this method.
SOMAExperimentAxisQuery$clone(deep = FALSE)
deepWhether to make a deep clone.
Factory function to create a SOMA experiment for writing (lifecycle: maturing).
SOMAExperimentCreate( uri, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMAExperimentCreate( uri, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
ingest_mode |
Ingestion mode when creating the TileDB object; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp. |
context |
Optional |
A new SOMA experiment stored at
uri opened for writing.
uri <- withr::local_tempfile(pattern = "soma-experiment") obs <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), obs_id = paste0("cell_", seq_len(100L)) ) sch <- arrow::infer_schema(obs) (exp <- SOMAExperimentCreate(uri)) sdf <- exp$add_new_dataframe( "obs", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(obs, schema = sch)) sdf$close() exp$close() (exp <- SOMAExperimentOpen(uri)) exp$obsuri <- withr::local_tempfile(pattern = "soma-experiment") obs <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), obs_id = paste0("cell_", seq_len(100L)) ) sch <- arrow::infer_schema(obs) (exp <- SOMAExperimentCreate(uri)) sdf <- exp$add_new_dataframe( "obs", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(obs, schema = sch)) sdf$close() exp$close() (exp <- SOMAExperimentOpen(uri)) exp$obs
Factory function to open a SOMA experiment for reading (lifecycle: maturing).
SOMAExperimentOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMAExperimentOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp;
defaults to the current time. If not |
context |
Optional |
A SOMA experiment stored at
uri opened in mode mode.
uri <- withr::local_tempfile(pattern = "soma-experiment") obs <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), obs_id = paste0("cell_", seq_len(100L)) ) sch <- arrow::infer_schema(obs) (exp <- SOMAExperimentCreate(uri)) sdf <- exp$add_new_dataframe( "obs", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(obs, schema = sch)) sdf$close() exp$close() (exp <- SOMAExperimentOpen(uri)) exp$obsuri <- withr::local_tempfile(pattern = "soma-experiment") obs <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), obs_id = paste0("cell_", seq_len(100L)) ) sch <- arrow::infer_schema(obs) (exp <- SOMAExperimentCreate(uri)) sdf <- exp$add_new_dataframe( "obs", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(obs, schema = sch)) sdf$close() exp$close() (exp <- SOMAExperimentOpen(uri)) exp$obs
A SOMAMeasurement is a sub-element of a
SOMAExperiment, and is otherwise a specialized
SOMACollection with pre-defined fields: X, var,
obsm/varm, and obsp/varp (see
Active Bindings below for details) (lifecycle: maturing).
The SOMAMeasurement class provides a number of type-specific methods for
adding new a object to the collection, such as add_new_sparse_ndarray() and
add_new_dataframe(). These methods will create the new object and add it as
member of the SOMAMeasurement. The new object will always inherit the parent
context (see SOMATileDBContext) and, by default, its platform
configuration (see PlatformConfig). However, the user can override the
default platform configuration by passing a custom configuration to the
platform_config argument.
When working with Carrara URIs (tiledb://workspace/teamspace/...), child
objects created at a URI nested under a parent collection are automatically
added as members of the parent. This means:
You do not need to call add_new_collection() after creating a child
at a nested URI—the child is already a member.
For backward compatibility, calling add_new_collection() on an
already-registered child is a no-op and will not cause an error.
The member name must match the relative URI segment (e.g., creating
at parent_uri/child automatically adds the child with key "child").
tiledbsoma::SOMAObject -> tiledbsoma::SOMACollectionBase -> SOMAMeasurement
varA SOMADataFrame containing primary annotations
on the variable axis, for variables in this measurement
(i.e., annotates columns of X). The contents of the
soma_joinid column define the variable index domain,
var_id. All variables for this measurement must be defined in this
data frame.
XA SOMACollection of
SOMASparseNDArrays, each contains measured feature values
indexed by [obsid, varid].
obsmA SOMACollection of
SOMADenseNDArrays containing annotations on the observation
axis. Each array is indexed by obsid and has the same shape as
obs.
obspA SOMACollection of
SOMASparseNDArrays containing pairwise annotations on the
observation axis and indexed with [obsid_1, obsid_2].
varmA SOMACollection of
SOMADenseNDArrays containing annotations on the variable
axis. Each array is indexed by varid and has the same shape as
var.
varpA SOMACollection of
SOMASparseNDArrays containing pairwise annotations on the
variable axis and indexed with [varid_1, varid_2].
tiledbsoma::SOMAObject$class()tiledbsoma::SOMAObject$exists()tiledbsoma::SOMAObject$get_metadata()tiledbsoma::SOMAObject$initialize()tiledbsoma::SOMAObject$is_open()tiledbsoma::SOMAObject$mode()tiledbsoma::SOMAObject$reopen()tiledbsoma::SOMACollectionBase$add_new_collection()tiledbsoma::SOMACollectionBase$add_new_dataframe()tiledbsoma::SOMACollectionBase$add_new_dense_ndarray()tiledbsoma::SOMACollectionBase$add_new_sparse_ndarray()tiledbsoma::SOMACollectionBase$close()tiledbsoma::SOMACollectionBase$create()tiledbsoma::SOMACollectionBase$get()tiledbsoma::SOMACollectionBase$length()tiledbsoma::SOMACollectionBase$names()tiledbsoma::SOMACollectionBase$open()tiledbsoma::SOMACollectionBase$print()tiledbsoma::SOMACollectionBase$remove()tiledbsoma::SOMACollectionBase$set()tiledbsoma::SOMACollectionBase$set_metadata()clone()
The objects of this class are cloneable with this method.
SOMAMeasurement$clone(deep = FALSE)
deepWhether to make a deep clone.
uri <- withr::local_tempfile(pattern = "soma-measurement") var <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), var_id = paste0("feature_", seq_len(100L)) ) sch <- arrow::infer_schema(var) (ms <- SOMAMeasurementCreate(uri)) sdf <- ms$add_new_dataframe( "var", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(var, schema = sch)) sdf$close() ms$close() (ms <- SOMAMeasurementOpen(uri)) ms$varuri <- withr::local_tempfile(pattern = "soma-measurement") var <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), var_id = paste0("feature_", seq_len(100L)) ) sch <- arrow::infer_schema(var) (ms <- SOMAMeasurementCreate(uri)) sdf <- ms$add_new_dataframe( "var", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(var, schema = sch)) sdf$close() ms$close() (ms <- SOMAMeasurementOpen(uri)) ms$var
Factory function to create a SOMA measurement for writing (lifecycle: maturing).
SOMAMeasurementCreate( uri, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMAMeasurementCreate( uri, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
ingest_mode |
Ingestion mode when creating the TileDB object; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp. |
context |
Optional |
A new SOMA measurement stored at
uri opened for writing.
uri <- withr::local_tempfile(pattern = "soma-measurement") var <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), var_id = paste0("feature_", seq_len(100L)) ) sch <- arrow::infer_schema(var) (ms <- SOMAMeasurementCreate(uri)) sdf <- ms$add_new_dataframe( "var", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(var, schema = sch)) sdf$close() ms$close() (ms <- SOMAMeasurementOpen(uri)) ms$varuri <- withr::local_tempfile(pattern = "soma-measurement") var <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), var_id = paste0("feature_", seq_len(100L)) ) sch <- arrow::infer_schema(var) (ms <- SOMAMeasurementCreate(uri)) sdf <- ms$add_new_dataframe( "var", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(var, schema = sch)) sdf$close() ms$close() (ms <- SOMAMeasurementOpen(uri)) ms$var
Factory function to open a SOMA measurement for reading (lifecycle: maturing).
SOMAMeasurementOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMAMeasurementOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp;
defaults to the current time. If not |
context |
Optional |
A SOMA measurement stored at
uri opened in mode mode.
uri <- withr::local_tempfile(pattern = "soma-measurement") var <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), var_id = paste0("feature_", seq_len(100L)) ) sch <- arrow::infer_schema(var) (ms <- SOMAMeasurementCreate(uri)) sdf <- ms$add_new_dataframe( "var", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(var, schema = sch)) sdf$close() ms$close() (ms <- SOMAMeasurementOpen(uri)) ms$varuri <- withr::local_tempfile(pattern = "soma-measurement") var <- data.frame( soma_joinid = bit64::seq.integer64(0L, 99L), var_id = paste0("feature_", seq_len(100L)) ) sch <- arrow::infer_schema(var) (ms <- SOMAMeasurementCreate(uri)) sdf <- ms$add_new_dataframe( "var", sch, "soma_joinid", list(soma_joinid = c(0, 100)) ) sdf$write(arrow::as_arrow_table(var, schema = sch)) sdf$close() ms$close() (ms <- SOMAMeasurementOpen(uri)) ms$var
Utility function to open the corresponding SOMA object given a URI (lifecycle: maturing).
SOMAOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL, tiledb_timestamp = NULL )SOMAOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL, tiledb_timestamp = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
context |
Optional |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp;
defaults to the current time. If not |
A SOMA object
dir <- withr::local_tempfile(pattern = "soma-open") dir.create(dir, recursive = TRUE) uri <- extract_dataset("soma-exp-pbmc-small", dir) (exp <- SOMAOpen(uri)) uri <- extract_dataset("soma-dataframe-pbmc3k-processed-obs", dir) (obs <- SOMAOpen(uri))dir <- withr::local_tempfile(pattern = "soma-open") dir.create(dir, recursive = TRUE) uri <- extract_dataset("soma-exp-pbmc-small", dir) (exp <- SOMAOpen(uri)) uri <- extract_dataset("soma-dataframe-pbmc3k-processed-obs", dir) (obs <- SOMAOpen(uri))
SOMASparseNDArray is a sparse, N-dimensional array with
offset (zero-based) integer indexing on each dimension. The
SOMASparseNDArray has a user-defined schema, which includes:
type: a primitive type, expressed as an Arrow type
(e.g., int64, float32, etc),
indicating the type of data contained within the array.
shape: the shape of the array, i.e., number and length of each
dimension. This is a soft limit which can be increased using
$resize() up to the maxshape.
maxshape: the hard limit up to which shape may be
increased using $resize().
All dimensions must have a positive, non-zero length.
As duplicate index values are not allowed, index values already present in the object are overwritten and new index values are added (lifecycle: maturing).
tiledbsoma::SOMAObject -> tiledbsoma::SOMAArrayBase -> tiledbsoma::SOMANDArrayBase -> SOMASparseNDArray
tiledbsoma::SOMAObject$class()tiledbsoma::SOMAObject$exists()tiledbsoma::SOMAObject$get_metadata()tiledbsoma::SOMAObject$initialize()tiledbsoma::SOMAObject$is_open()tiledbsoma::SOMAObject$mode()tiledbsoma::SOMAObject$reopen()tiledbsoma::SOMAObject$set_metadata()tiledbsoma::SOMAArrayBase$allows_duplicates()tiledbsoma::SOMAArrayBase$attributes()tiledbsoma::SOMAArrayBase$attrnames()tiledbsoma::SOMAArrayBase$close()tiledbsoma::SOMAArrayBase$colnames()tiledbsoma::SOMAArrayBase$dimensions()tiledbsoma::SOMAArrayBase$dimnames()tiledbsoma::SOMAArrayBase$index_column_names()tiledbsoma::SOMAArrayBase$is_sparse()tiledbsoma::SOMAArrayBase$maxshape()tiledbsoma::SOMAArrayBase$ndim()tiledbsoma::SOMAArrayBase$non_empty_domain()tiledbsoma::SOMAArrayBase$open()tiledbsoma::SOMAArrayBase$print()tiledbsoma::SOMAArrayBase$schema()tiledbsoma::SOMAArrayBase$shape()tiledbsoma::SOMANDArrayBase$create()tiledbsoma::SOMANDArrayBase$resize()tiledbsoma::SOMANDArrayBase$set_data_type()tiledbsoma::SOMANDArrayBase$tiledbsoma_has_upgraded_shape()tiledbsoma::SOMANDArrayBase$tiledbsoma_upgrade_shape()read()
Reads a user-defined slice of the SOMASparseNDArray.
SOMASparseNDArray$read( coords = NULL, result_order = "auto", log_level = "auto" )
coordsOptional list of integer vectors, one for each
dimension, with a length equal to the number of values to read. If
NULL, all values are read. List elements can be named when
specifying a subset of dimensions.
result_orderOptional order of read results. This can be one of either
"ROW_MAJOR, "COL_MAJOR", or "auto"' (default).
log_levelOptional logging level with default value of
“warn”.
write()
Write matrix-like data to the array (lifecycle: maturing).
SOMASparseNDArray$write(values, bbox = NULL)
valuesAny matrix-like object coercible to a
TsparseMatrix. Character
dimension names are ignored because SOMANDArrays use integer
indexing.
bboxA vector of integers describing the upper bounds of each
dimension of values. Generally should be NULL.
Invisibly returns self.
nnz()
Retrieve number of non-zero elements (lifecycle: maturing).
SOMASparseNDArray$nnz()
A scalar with the number of non-zero elements.
.write_coordinates()
Write a COO table to the array.
SOMASparseNDArray$.write_coordinates(values)
valuesA data.frame or Arrow table
with data in COO format; must be named with the dimension and attribute
labels of the array.
Invisibly returns self.
clone()
The objects of this class are cloneable with this method.
SOMASparseNDArray$clone(deep = FALSE)
deepWhether to make a deep clone.
In TileDB this is an sparse array with N int64 dimensions
of domain [0, maxInt64) and a single attribute.
uri <- withr::local_tempfile(pattern = "soma-sparse-array") mat <- Matrix::rsparsematrix(100L, 100L, 0.7, repr = "T") mat[1:3, 1:5] (arr <- SOMASparseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMASparseNDArrayOpen(uri)) m2 <- arr$read()$sparse_matrix()$concat() m2[1:3, 1:5]uri <- withr::local_tempfile(pattern = "soma-sparse-array") mat <- Matrix::rsparsematrix(100L, 100L, 0.7, repr = "T") mat[1:3, 1:5] (arr <- SOMASparseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMASparseNDArrayOpen(uri)) m2 <- arr$read()$sparse_matrix()$concat() m2[1:3, 1:5]
Factory function to create a SOMA sparse ND array for writing (lifecycle: maturing).
SOMASparseNDArrayCreate( uri, type, shape, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMASparseNDArrayCreate( uri, type, shape, ingest_mode = c("write", "resume"), platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
type |
An Arrow type defining the type of each element in the array. |
shape |
A vector of integers defining the shape of the array. |
ingest_mode |
Ingestion mode when creating the TileDB object; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp. |
context |
Optional |
A new SOMA sparse ND array
stored at uri opened for writing.
uri <- withr::local_tempfile(pattern = "soma-sparse-array") mat <- Matrix::rsparsematrix(100L, 100L, 0.7, repr = "T") mat[1:3, 1:5] (arr <- SOMASparseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMASparseNDArrayOpen(uri)) m2 <- arr$read()$sparse_matrix()$concat() m2[1:3, 1:5]uri <- withr::local_tempfile(pattern = "soma-sparse-array") mat <- Matrix::rsparsematrix(100L, 100L, 0.7, repr = "T") mat[1:3, 1:5] (arr <- SOMASparseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMASparseNDArrayOpen(uri)) m2 <- arr$read()$sparse_matrix()$concat() m2[1:3, 1:5]
Factory function to open a SOMA sparse ND array for reading (lifecycle: maturing).
SOMASparseNDArrayOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )SOMASparseNDArrayOpen( uri, mode = "READ", platform_config = NULL, tiledbsoma_ctx = NULL, tiledb_timestamp = NULL, context = NULL )
uri |
URI for the TileDB object. |
mode |
One of “ |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) SOMATileDBContext. |
tiledb_timestamp |
Optional Datetime (POSIXct) for TileDB timestamp; defaults to the current time. |
context |
Optional |
A SOMA sparse ND array stored at
uri opened in mode mode.
uri <- withr::local_tempfile(pattern = "soma-sparse-array") mat <- Matrix::rsparsematrix(100L, 100L, 0.7, repr = "T") mat[1:3, 1:5] (arr <- SOMASparseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMASparseNDArrayOpen(uri)) m2 <- arr$read()$sparse_matrix()$concat() m2[1:3, 1:5]uri <- withr::local_tempfile(pattern = "soma-sparse-array") mat <- Matrix::rsparsematrix(100L, 100L, 0.7, repr = "T") mat[1:3, 1:5] (arr <- SOMASparseNDArrayCreate(uri, arrow::float64(), shape = dim(mat))) arr$write(mat) arr$close() (arr <- SOMASparseNDArrayOpen(uri)) m2 <- arr$read()$sparse_matrix()$concat() m2[1:3, 1:5]
Context map for TileDB-backed SOMA objects
tiledbsoma::MappingBase -> tiledbsoma::ScalarMap -> tiledbsoma::SOMAContextBase -> SOMATileDBContext
new()
SOMATileDBContext$new(config = NULL, cached = TRUE)
config...
cachedForce new creation
An instantiated SOMATileDBContext object
keys()
SOMATileDBContext$keys()
The keys of the map
items()
SOMATileDBContext$items()
Return the items of the map as a list
length()
SOMATileDBContext$length()
The number of items in the map
get()
SOMATileDBContext$get(key, default = quote(expr = ))
keyKey to fetch
defaultDefault value to fetch if key is not found;
defaults to NULL
The value of key in the map, or default if
key is not found
set()
SOMATileDBContext$set(key, value)
keyKey to set
valueValue to add for key, or NULL to remove
the entry for key
[chainable] Invisibly returns self with
value added as key
to_tiledb_context()
SOMATileDBContext$to_tiledb_context()
A tiledb_ctx object, dynamically
constructed. Most useful for the constructor of this class.
context()
SOMATileDBContext$context()
A tiledb_ctx object, which is
a stored (and long-lived) result from to_tiledb_context.
clone()
The objects of this class are cloneable with this method.
SOMATileDBContext$clone(deep = FALSE)
deepWhether to make a deep clone.
(ctx <- SOMATileDBContext$new()) ctx$get("sm.mem.reader.sparse_global_order.ratio_array_data") ctx$to_tiledb_context()(ctx <- SOMATileDBContext$new()) ctx$get("sm.mem.reader.sparse_global_order.ratio_array_data") ctx$to_tiledb_context()
SparseReadIter is a class that allows for iteration over
a reads on SOMASparseNDArray.
tiledbsoma::ReadIter -> SparseReadIter
new()
Create (lifecycle: maturing).
SparseReadIter$new(sr, shape, zero_based = FALSE)
srSoma reader pointer.
shapeShape of the full matrix.
zero_basedLogical, if TRUE will make iterator for
Matrix::dgTMatrix-class
otherwise matrixZeroBasedView.
concat()
Concatenate remainder of iterator.
SparseReadIter$concat()
matrixZeroBasedView of Matrix::sparseMatrix.
clone()
The objects of this class are cloneable with this method.
SparseReadIter$clone(deep = FALSE)
deepWhether to make a deep clone.
dir <- withr::local_tempfile(pattern = "matrix-iter") dir.create(dir, recursive = TRUE) (exp <- load_dataset("soma-exp-pbmc-small", dir)) qry <- exp$axis_query("RNA") xqry <- qry$X("data") iter <- xqry$sparse_matrix() stopifnot(inherits(iter, "SparseReadIter")) while (!iter$read_complete()) { block <- iter$read_next() }dir <- withr::local_tempfile(pattern = "matrix-iter") dir.create(dir, recursive = TRUE) (exp <- load_dataset("soma-exp-pbmc-small", dir)) qry <- exp$axis_query("RNA") xqry <- qry$X("data") iter <- xqry$sparse_matrix() stopifnot(inherits(iter, "SparseReadIter")) while (!iter$read_complete()) { block <- iter$read_next() }
TableReadIter is a class that allows for iteration over
a reads on SOMASparseNDArray and SOMADataFrame.
Iteration chunks are retrieved as an Arrow Table.
tiledbsoma::ReadIter -> TableReadIter
concat()
Concatenate remainder of iterator.
TableReadIter$concat()
An Arrow Table.
clone()
The objects of this class are cloneable with this method.
TableReadIter$clone(deep = FALSE)
deepWhether to make a deep clone.
dir <- withr::local_tempfile(pattern = "table-iter") dir.create(dir, recursive = TRUE) (exp <- load_dataset("soma-exp-pbmc-small", dir)) qry <- exp$axis_query("RNA") xqry <- qry$X("data") iter <- xqry$tables() stopifnot(inherits(iter, "TableReadIter")) while (!iter$read_complete()) { block <- iter$read_next() }dir <- withr::local_tempfile(pattern = "table-iter") dir.create(dir, recursive = TRUE) (exp <- load_dataset("soma-exp-pbmc-small", dir)) qry <- exp$axis_query("RNA") xqry <- qry$X("data") iter <- xqry$tables() stopifnot(inherits(iter, "TableReadIter")) while (!iter$read_complete()) { block <- iter$read_next() }
These functions expose the TileDB Core functionality for performance measurements and statistics
tiledbsoma_stats_enable() tiledbsoma_stats_disable() tiledbsoma_stats_reset() tiledbsoma_stats_dump() tiledbsoma_stats_show()tiledbsoma_stats_enable() tiledbsoma_stats_disable() tiledbsoma_stats_reset() tiledbsoma_stats_dump() tiledbsoma_stats_show()
tiledbsoma_stats_enable()/tiledbsoma_stats_disable():
Enable and disable TielDB's internal statistics
tiledbsoma_stats_reset(): Reset all statistics to 0
tiledbsoma_stats_dump(): Dump all statistics as a JSON string
tiledbsoma_stats_show(): Pretty-print the JSON statistics
tiledbsoma_stats_show(): a single-length character vector
with the TileDB statistics encoded in JSON format
All other functions invisibly return NULL
Convert R objects to their appropriate SOMA counterpart
function and methods can be written for it to provide a high-level
R SOMA interface.
write_soma( x, uri, ..., platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )write_soma( x, uri, ..., platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )
x |
An object. |
uri |
URI for resulting SOMA object. |
... |
Arguments passed to other methods |
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) |
context |
Optional |
The URI to the resulting SOMAExperiment generated from
the data contained in x.
# Write a Bioconductor S4 DataFrame object to a SOMA uri <- withr::local_tempfile(pattern = "s4-data-frame") data("pbmc_small", package = "SeuratObject") obs <- suppressWarnings(SeuratObject::UpdateSeuratObject(pbmc_small))[[]] head(obs <- as(obs, "DataFrame")) (sdf <- write_soma(obs, uri, soma_parent = NULL, relative = FALSE)) sdf$close() # Write a Bioconductor SelfHits object to a SOMA uri <- withr::local_tempfile(pattern = "hits") (hits <- S4Vectors::SelfHits( c(2, 3, 3, 3, 3, 3, 4, 4, 4), c(4, 3, 2:4, 2, 2:3, 2), 4, x = stats::rnorm(9L) )) (arr <- write_soma(hits, uri, soma_parent = NULL, relative = FALSE)) arr$close() # Write a character vector to a SOMA uri <- withr::local_tempfile(pattern = "character") (sdf <- write_soma(letters, uri, soma_parent = NULL, relative = FALSE)) sdf$close() # Write a data.frame to a SOMA uri <- withr::local_tempfile(pattern = "data-frame") data("pbmc_small", package = "SeuratObject") head(obs <- suppressWarnings(SeuratObject::UpdateSeuratObject(pbmc_small))[[]]) (sdf <- write_soma(obs, uri, soma_parent = NULL, relative = FALSE)) sdf$close() # Write a BPCells `IterableMatrix` to a SOMA # Write a matrix to a SOMA uri <- withr::local_tempfile(pattern = "matrix") mat <- matrix(stats::rnorm(25L), nrow = 5L, ncol = 5L) (arr <- write_soma(mat, uri, soma_parent = NULL, sparse = FALSE, relative = FALSE)) arr$close() # Write a dense S4 Matrix to a SOMA uri <- withr::local_tempfile(pattern = "s4-matrix") mat <- Matrix::Matrix(stats::rnorm(25L), nrow = 5L, ncol = 5L) (arr <- write_soma(mat, uri, soma_parent = NULL, sparse = FALSE, relative = FALSE)) arr$close() # Write a TsparseMatrix to a SOMA uri <- withr::local_tempfile(pattern = "tsparse-matrix") mat <- Matrix::rsparsematrix(5L, 5L, 0.3, repr = "T") (arr <- write_soma(mat, uri, soma_parent = NULL, relative = FALSE)) arr$close() # Write a CsparseMatrix to a SOMA uri <- withr::local_tempfile(pattern = "csparse-matrix") mat <- Matrix::rsparsematrix(5L, 5L, 0.3, repr = "C") (arr <- write_soma(mat, uri, soma_parent = NULL, relative = FALSE)) arr$close() # Write an RsparseMatrix to a SOMA uri <- withr::local_tempfile(pattern = "rsparse-matrix") mat <- Matrix::rsparsematrix(5L, 5L, 0.3, repr = "R") (arr <- write_soma(mat, uri, soma_parent = NULL, relative = FALSE)) arr$close()# Write a Bioconductor S4 DataFrame object to a SOMA uri <- withr::local_tempfile(pattern = "s4-data-frame") data("pbmc_small", package = "SeuratObject") obs <- suppressWarnings(SeuratObject::UpdateSeuratObject(pbmc_small))[[]] head(obs <- as(obs, "DataFrame")) (sdf <- write_soma(obs, uri, soma_parent = NULL, relative = FALSE)) sdf$close() # Write a Bioconductor SelfHits object to a SOMA uri <- withr::local_tempfile(pattern = "hits") (hits <- S4Vectors::SelfHits( c(2, 3, 3, 3, 3, 3, 4, 4, 4), c(4, 3, 2:4, 2, 2:3, 2), 4, x = stats::rnorm(9L) )) (arr <- write_soma(hits, uri, soma_parent = NULL, relative = FALSE)) arr$close() # Write a character vector to a SOMA uri <- withr::local_tempfile(pattern = "character") (sdf <- write_soma(letters, uri, soma_parent = NULL, relative = FALSE)) sdf$close() # Write a data.frame to a SOMA uri <- withr::local_tempfile(pattern = "data-frame") data("pbmc_small", package = "SeuratObject") head(obs <- suppressWarnings(SeuratObject::UpdateSeuratObject(pbmc_small))[[]]) (sdf <- write_soma(obs, uri, soma_parent = NULL, relative = FALSE)) sdf$close() # Write a BPCells `IterableMatrix` to a SOMA # Write a matrix to a SOMA uri <- withr::local_tempfile(pattern = "matrix") mat <- matrix(stats::rnorm(25L), nrow = 5L, ncol = 5L) (arr <- write_soma(mat, uri, soma_parent = NULL, sparse = FALSE, relative = FALSE)) arr$close() # Write a dense S4 Matrix to a SOMA uri <- withr::local_tempfile(pattern = "s4-matrix") mat <- Matrix::Matrix(stats::rnorm(25L), nrow = 5L, ncol = 5L) (arr <- write_soma(mat, uri, soma_parent = NULL, sparse = FALSE, relative = FALSE)) arr$close() # Write a TsparseMatrix to a SOMA uri <- withr::local_tempfile(pattern = "tsparse-matrix") mat <- Matrix::rsparsematrix(5L, 5L, 0.3, repr = "T") (arr <- write_soma(mat, uri, soma_parent = NULL, relative = FALSE)) arr$close() # Write a CsparseMatrix to a SOMA uri <- withr::local_tempfile(pattern = "csparse-matrix") mat <- Matrix::rsparsematrix(5L, 5L, 0.3, repr = "C") (arr <- write_soma(mat, uri, soma_parent = NULL, relative = FALSE)) arr$close() # Write an RsparseMatrix to a SOMA uri <- withr::local_tempfile(pattern = "rsparse-matrix") mat <- Matrix::rsparsematrix(5L, 5L, 0.3, repr = "R") (arr <- write_soma(mat, uri, soma_parent = NULL, relative = FALSE)) arr$close()
Seurat object to a SOMAWrite a Seurat object to a SOMA
## S3 method for class 'Seurat' write_soma( x, uri, ..., ingest_mode = "write", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )## S3 method for class 'Seurat' write_soma( x, uri, ..., ingest_mode = "write", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )
x |
A |
uri |
URI for resulting SOMA object. |
... |
Arguments passed to other methods |
ingest_mode |
Ingestion mode when creating the SOMA; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) |
context |
Optional |
The URI to the resulting SOMAExperiment generated from
the data contained in x.
Cell-level metadata is written out as a
data frame called “obs” at
the experiment level.
Assays
Seurat Assay objects are written out as
individual measurements:
the “data” matrix is written out as a
sparse array called
“data” within the “X” group.
the “counts” matrix, if not
empty, is written out as a
sparse array called
“counts” within the “X” group.
the “scale.data” matrix, if not
empty, is written out as a
sparse array called
“scale_data” within the “X” group.
feature-level metadata is written out as a
data frame called “var”.
Expression matrices are transposed (cells as rows) prior to writing. All
other slots, including results from extended assays (eg. SCTAssay,
ChromatinAssay) are lost.
Ingestion of very large dense layers, such as scale.data, can be
memory intensive. For better performance, users can remove these layers
prior to ingestion and regenerate them after export, or ingest them
separately as dense arrays for those who need to persist the exact matrix
# Using SeuratObject v5 syntax on a v3 `Assay`
# Cache the layer for separate ingestion, skip if planning to regenerate
mat <- object[["ASSAY"]]$scale.data
# Remove the `scale.data` layer
object[["ASSAY"]]$scale.data <- NULL
# Ingest the smaller object
uri <- write_soma(object, "/path/to/soma")
# Ingest the `scale.data` layer densely; needed only if persistence
# of the data is paramount
# Pad the `scale.data` layer so that its soma join IDs match the experiment
padded <- matrix(
data = vector("numeric", length = prod(dim(object[["ASSAY"]]))),
nrow = nrow(object[["ASSAY"]]),
ncol = ncol(object[["ASSAY"]])
)
rowidx <- match(rownames(mat), rownames(object[["ASSAY"]]))
colidx <- match(colnames(mat), colnames(object[["ASSAY"]]))
padded[rowidx, colidx] <- mat
# Use `write_soma()` to ingest densely and register it within the `uns`
# collection; this may need to be created manually if the original
# object does not contain command logs
exp <- SOMAExperimentOpen(uri, "WRITE")
if (!match("uns", exp$names(), nomatch = 0L)) {
# For `tiledb://` URIs, set the URI for the new collection manually rather
# than relying on `file.path()`
uns <- SOMACollectionCreate(file.path(exp$uri, "uns"))
exp$add_new_collection(uns, "uns")
}
arr <- write_soma(
padded,
"scale_data",
soma_parent = exp$get("uns"),
sparse = FALSE,
key = "scale_data"
)
arr$close()
exp$close()
Please note that dense arrays cannot be read in using the
SOMAExperimentAxisQuery mechanism; use
SOMADenseNDArray$read_dense_matrix, remembering to transpose
before adding back to a Seurat object
Assays
Seurat v5 Assayss are written
out as individual measurements:
the layer matrices are written out as
sparse arrays within the
“X” group.
feature-level metadata is written out as a
data frame called “var”.
Expression matrices are transposed (cells as rows) prior to writing. All
other slots, including results from extended assays (eg. SCTAssay,
ChromatinAssay) are lost.
The following bits of metadata are written in various parts of the measurement
“soma_ecosystem_seurat_assay_version”: written at the
measurement level; indicates the Seurat assay version.
Set to “v5”.
“soma_ecosystem_seurat_v5_default_layers”: written at
the “X” group level; indicates the
default layers.
“soma_ecosystem_seurat_v5_ragged”: written at the
“X/<layer>” array level; with a value of
“ragged”, indicates whether or not the layer is ragged.
“soma_r_type_hint”: written at the
“X/<layer>” array level; indicates the R class and
defining package (for S4 classes) of the original layer.
DimReducs
Seurat DimReduc objects are written out
to the “obsm” and “varm” groups of a
measurement:
cell embeddings are written out as a
sparse matrix in the
“obsm” group.
feature loadings, if not empty,
are written out as a sparse matrix in
the “varm” groups; loadings are padded with NAs
to include all features.
Dimensional reduction names are translated to AnnData-style names (eg.
“pca” becomes X_pca for embeddings and
“PCs” for loadings). All other slots, including projected
feature loadings and jackstraw information, are lost.
Graphs
Seurat Graph objects are
written out as sparse matrices
to the “obsp” group of a
measurement.
SeuratCommands
Seurat command logs are written out
as data frames to the
“seurat_commands” group of a
collection.
uri <- withr::local_tempfile(pattern = "pbmc-small") data("pbmc_small", package = "SeuratObject") suppressWarnings(pbmc_small <- SeuratObject::UpdateSeuratObject(pbmc_small)) uri <- write_soma(pbmc_small, uri) (exp <- SOMAExperimentOpen(uri)) exp$obs exp$get("uns")$get("seurat_commands")$names() (ms <- exp$ms$get("RNA")) ms$var ms$X$names() ms$obsm$names() ms$varm$names() ms$obsp$names() exp$close()uri <- withr::local_tempfile(pattern = "pbmc-small") data("pbmc_small", package = "SeuratObject") suppressWarnings(pbmc_small <- SeuratObject::UpdateSeuratObject(pbmc_small)) uri <- write_soma(pbmc_small, uri) (exp <- SOMAExperimentOpen(uri)) exp$obs exp$get("uns")$get("seurat_commands")$names() (ms <- exp$ms$get("RNA")) ms$var ms$X$names() ms$obsm$names() ms$varm$names() ms$obsp$names() exp$close()
SingleCellExperiment
object to a SOMAWrite a SingleCellExperiment
object to a SOMA
## S3 method for class 'SingleCellExperiment' write_soma( x, uri, ms_name = NULL, ..., ingest_mode = "write", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )## S3 method for class 'SingleCellExperiment' write_soma( x, uri, ms_name = NULL, ..., ingest_mode = "write", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )
x |
An object. |
uri |
URI for resulting SOMA object. |
ms_name |
Name for resulting measurement; defaults to
|
... |
Arguments passed to other methods |
ingest_mode |
Ingestion mode when creating the SOMA; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) |
context |
Optional |
The URI to the resulting SOMAExperiment generated from
the data contained in x.
Reduced dimensions are written out as
sparse matrices within the obsm
group of measurement
named ms_name.
Column-wise relationship matrices are written out as
sparse matrices within the
obsp group of measurement
named ms_name.
Row-wise relationship matrices are written out as
sparse matrices within the
varp group of measurement
named ms_name.
colData
colData is written out as a
data frame called “obs” at
the experiment level.
Each assay matrix is written out as a
sparse matrix within the X group
of measurement named
ms_name. Names for assay matrices within X are taken from the
assay names. Assay matrices are
transposed (samples as rows) prior to writing.
rowData
rowData is written out as a
data frame called “var” at
the measurement level.
uri <- withr::local_tempfile(pattern = "single-cell-experiment") mat <- abs(Matrix::rsparsematrix( 230L, 80L, 0.3, dimnames = list(paste0("feature_", seq_len(230)), paste0("cell_", seq_len(80))) )) (sce <- SingleCellExperiment::SingleCellExperiment( assays = list(counts = mat, logcounts = log2(mat + 1L)), reducedDims = list( pca = matrix(stats::runif(80 * 5L), nrow = 80), tsne = matrix(stats::rnorm(80 * 2L), nrow = 80) ), mainExpName = "RNA" )) uri <- write_soma(sce, uri) (exp <- SOMAExperimentOpen(uri)) exp$close()uri <- withr::local_tempfile(pattern = "single-cell-experiment") mat <- abs(Matrix::rsparsematrix( 230L, 80L, 0.3, dimnames = list(paste0("feature_", seq_len(230)), paste0("cell_", seq_len(80))) )) (sce <- SingleCellExperiment::SingleCellExperiment( assays = list(counts = mat, logcounts = log2(mat + 1L)), reducedDims = list( pca = matrix(stats::runif(80 * 5L), nrow = 80), tsne = matrix(stats::rnorm(80 * 2L), nrow = 80) ), mainExpName = "RNA" )) uri <- write_soma(sce, uri) (exp <- SOMAExperimentOpen(uri)) exp$close()
SummarizedExperiment
object to a SOMAWrite a SummarizedExperiment
object to a SOMA
## S3 method for class 'SummarizedExperiment' write_soma( x, uri, ms_name, ..., ingest_mode = "write", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )## S3 method for class 'SummarizedExperiment' write_soma( x, uri, ms_name, ..., ingest_mode = "write", platform_config = NULL, tiledbsoma_ctx = NULL, context = NULL )
x |
An object. |
uri |
URI for resulting SOMA object. |
ms_name |
Name for resulting measurement. |
... |
Arguments passed to other methods |
ingest_mode |
Ingestion mode when creating the SOMA; choose from:
|
platform_config |
Optional platform configuration. |
tiledbsoma_ctx |
Optional (DEPRECATED) |
context |
Optional |
The URI to the resulting SOMAExperiment generated from
the data contained in x.
colData
colData is written out as a
data frame called “obs” at
the experiment level.
Each assay matrix is written out as a
sparse matrix within the X group
of measurement named
ms_name. Names for assay matrices within X are taken from the
assay names. Assay matrices are
transposed (samples as rows) prior to writing.
rowData
rowData is written out as a
data frame called “var” at
the measurement level.
uri <- withr::local_tempfile(pattern = "summarized-experiment") mat <- abs(Matrix::rsparsematrix( 230L, 80L, 0.3, dimnames = list(paste0("feature_", seq_len(230)), paste0("cell_", seq_len(80))) )) (se <- SummarizedExperiment::SummarizedExperiment(list(counts = mat, logcounts = log2(mat + 1L)))) uri <- write_soma(se, uri, ms_name = "RNA") (exp <- SOMAExperimentOpen(uri)) exp$obs (ms <- exp$ms$get("RNA")) ms$var ms$X$names() exp$close()uri <- withr::local_tempfile(pattern = "summarized-experiment") mat <- abs(Matrix::rsparsematrix( 230L, 80L, 0.3, dimnames = list(paste0("feature_", seq_len(230)), paste0("cell_", seq_len(80))) )) (se <- SummarizedExperiment::SummarizedExperiment(list(counts = mat, logcounts = log2(mat + 1L)))) uri <- write_soma(se, uri, ms_name = "RNA") (exp <- SOMAExperimentOpen(uri)) exp$obs (ms <- exp$ms$get("RNA")) ms$var ms$X$names() exp$close()