tiledbsoma.io.add_X_layer¶
- tiledbsoma.io.add_X_layer(exp: Experiment, measurement_name: str, X_layer_name: str, X_layer_data: ndarray | Dataset | csr_matrix | csc_matrix | CSCDataset | CSRDataset | csr_array | csc_array, ingest_mode: Literal['write', 'schema_only', 'resume'] = 'write', use_relative_uri: bool | None = None, context: SOMATileDBContext | None = None, schema_validation: bool = True) None¶
Add a new X layer to a measurement in the experiment.
This is useful for adding X data, for example from Scanpy’s
scanpy.pp.normalize_total,scanpy.pp.log1p, etc.- Parameters:
exp – The experiment to add the X layer to. Must be open for writing.
measurement_name – Name of the measurement within the experiment.
X_layer_name – Name for the new X layer (e.g., “normalized”, “log1p”).
X_layer_data – Matrix data to store in the X layer. Can be a sparse matrix (e.g., scipy.csr_matrix) or an h5py.Dataset.
ingest_mode – Mode for ingestion. Defaults to “write”.
use_relative_uri – Whether to use relative URIs when storing references. If None, the default behavior is used.
context – TileDB context for the operation. If None, uses the default context.
schema_validation – Whether to validate the matrix schema before adding. Defaults to True.
- Returns:
None
- Raises:
ValueError – If the experiment is not open for writing or if schema validation fails.
Lifecycle
Maturing.