tiledbsoma.io.resize_experiment¶
- tiledbsoma.io.resize_experiment(uri: str, *, nobs: int, nvars: dict[str, int], verbose: bool = False, check_only: bool = False, context: ~tiledbsoma.options._soma_tiledb_context.SOMATileDBContext | None = None, output_handle: ~_io.TextIOWrapper | ~_io.StringIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) bool¶
Resize the elements in the SOMA
Experimentto fit the requested number of observations and variables.A dataframe will be resized if the
soma_joinidcolumn is an index column and the current domain of thesoma_joinidcolumn is smaller than requested size. If the new domain of thesoma_joinidcolumn does not fit inside themaxshape, the resize fails.An N-D array will be resized if either dimension of the new
shapeis larger than the current shape. If either dimension of the newshapeis larger thanmaxshape, the resize fails.The following base elements are resized:
obsdataframe:soma_joinidresized to fitnobs.
For each
measurement_namein the experiment the elements are resized as follows wherenvar[measurement_name]is the current size ifmeasurement_nameor no value is provided by the user:vardataframe:soma_joinidresized to fitnvar[measurement_name].Xarrays:shapeat least (nobs,nvar[measurement_name]).obsmarrays:shapeat least (nobs, currentsoma_dim_1).varmarrays:shapeat least (nvar, currentsoma_dim_1).obsparrays:shapeat least (nobs,nobs).varmarrays:shapeat least (nvar, existingsoma_dim_1).varparrays:shapeat least (nvar,nvar).
Example:
>>> tiledbsoma.io.resize_experiment( 'pbmc3k_unprocessed', nobs=5600, nvars={"data":3204, "raw": 13714}, check_only=True, ) [DataFrame] obs URI file:///data/pbmc3k_unprocessed/obs Dry run for: tiledbsoma_resize_soma_joinid_shape(5600) OK [DataFrame] ms/RNA/var URI file:///data/pbmc3k_unprocessed/ms/RNA/var Dry run for: tiledbsoma_resize_soma_joinid_shape(13714) OK [SparseNDArray] ms/RNA/X/data URI file:///data/pbmc3k_unprocessed/ms/RNA/X/data Dry run for: resize((5600, 13714)) OK
- Parameters:
uri – The URI of a SOMA
Experiment.nobs – The desired new shape of the experiment’s
obsdataframe.nvars – The desired new shapes of the experiment’s
vardataframes. This should be a dict from measurement name to shape, e.g.{"RNA": 10000, "raw": 20000}.verbose – If
True, produce per-array output as the upgrade runs.check_only – If
True, don’t apply the upgrades, but show what would be attempted, and show why each one would fail.context – Optional
SOMATileDBContext.
- Returns:
Trueif all resize operations succeed.Falseif any resize operation fails.