tiledbsoma.io.resize_experiment

tiledbsoma.io.resize_experiment(uri: str, *, nobs: int, nvars: ~typing.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

For each dataframe contained within the SOMA Experiment pointed to by the given URI, resizes the domain for the soma_joinid index column (if it is an indexed column) to match the desired new value.

The desired new value may be the same size as at present, or bigger, but not exceeding maxdomain for the soma_joinid index column.

For each N-D array contained within the SOMA Experiment, resizes the shape to match the desired values.

  • For X arrays, the resize is to new nobs x the measurement’s new nvar.

  • For obsm arrays, the resize is to new nobs x the array’s existing soma_dim_1 shape.

  • For obsp arrays, the resize is to new nobs x that same nobs.

  • For varm arrays, the resize is to new nvar x the array’s existing soma_dim_1 shape.

  • For varp arrays, the resize is to new nvar x that same nvar.

In all cases, the desired new shape value may be the same size on the given dimension, or bigger, but not exceeding maxshape for the given dimension.

If any array has not been upgraded, then the experiment’s resize will fail.

Parameters:
  • uri – The URI of a SOMA Experiment.

  • nobs – The desired new shape of the experiment’s obs dataframe.

  • nvars – The desired new shapes of the experiment’s var dataframes. 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.

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