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).
Adding new objects to a collection
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.
Carrara (TileDB v3) behavior
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/childautomatically adds the child with key"child").
Super classes
tiledbsoma::SOMAObject -> tiledbsoma::SOMACollectionBase -> SOMAMeasurement
Active bindings
varA
SOMADataFramecontaining primary annotations on the variable axis, for variables in this measurement (i.e., annotates columns ofX). The contents of thesoma_joinidcolumn define the variable index domain,var_id. All variables for this measurement must be defined in this data frame.XA
SOMACollectionofSOMASparseNDArrays, each contains measured feature values indexed by[obsid, varid].obsmA
SOMACollectionofSOMADenseNDArrayscontaining annotations on the observation axis. Each array is indexed byobsidand has the same shape asobs.obspA
SOMACollectionofSOMASparseNDArrayscontaining pairwise annotations on the observation axis and indexed with[obsid_1, obsid_2].varmA
SOMACollectionofSOMADenseNDArrayscontaining annotations on the variable axis. Each array is indexed byvaridand has the same shape asvar.varpA
SOMACollectionofSOMASparseNDArrayscontaining pairwise annotations on the variable axis and indexed with[varid_1, varid_2].
Methods
Inherited methods
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()
Examples
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))
#> <SOMAMeasurement>
#> uri: /tmp/Rtmpfr8mYm/soma-measurement2a7e6f7de6fb
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))
#> <SOMAMeasurement>
#> uri: /tmp/Rtmpfr8mYm/soma-measurement2a7e6f7de6fb
ms$var
#> <SOMADataFrame>
#> uri: file:///tmp/Rtmpfr8mYm/soma-measurement2a7e6f7de6fb/var
#> dimensions: soma_joinid
#> attributes: var_id