Skip to contents

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).

Adding new objects to a collection

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.

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/child automatically adds the child with key "child").

Super classes

tiledbsoma::SOMAObject -> tiledbsoma::SOMACollectionBase -> SOMACollection

Examples

uri <- withr::local_tempfile(pattern = "soma-collection")

(col <- SOMACollectionCreate(uri))
#> <SOMACollection>
#>   uri: /tmp/Rtmpfr8mYm/soma-collection2a7e66fa9b84
col$add_new_sparse_ndarray("sparse", arrow::float64(), shape = c(100L, 100L))
#> <SOMASparseNDArray>
#>   uri: /tmp/Rtmpfr8mYm/soma-collection2a7e66fa9b84/sparse
#>   dimensions: soma_dim_0, soma_dim_1 
#>   attributes: soma_data 
col$close()

(col <- SOMACollectionOpen(uri))
#> <SOMACollection>
#>   uri: /tmp/Rtmpfr8mYm/soma-collection2a7e66fa9b84
col$names()
#> [1] "sparse"