tiledbsoma.Experiment.obs_axis_delete

Experiment.obs_axis_delete(coords: Sequence[None | bytes | Slice[bytes] | Sequence[bytes] | float | Slice[float] | Sequence[float] | int | Slice[int] | Sequence[int] | slice | Slice[slice] | Sequence[slice] | str | Slice[str] | Sequence[str] | datetime64 | Slice[datetime64] | Sequence[datetime64] | TimestampType | Slice[TimestampType] | Sequence[TimestampType] | Array | ChunkedArray | ndarray[tuple[Any, ...], dtype[integer]] | ndarray[tuple[Any, ...], dtype[datetime64]]] = (), *, value_filter: str | None = None, platform_config: Dict[str, Mapping[str, Any]] | object | None = None) None

Delete observations (obs axis elements only) from all predefined sub-objects within an Experiment.

This operation affects all Measurements within an Experiment. Deleted observations are specified:

  • by obs DataFrame soma_joinid: a sequence of soma_joinid or a slice

  • or, by obs DataFrame value filter / query condition

Sub-objects affected by this operation:

  • exp.obs - delete matching DataFrame elements by soma_joinid

  • exp.obs_spatial_presence - delete matching DataFrame elements by soma_joinid

  • exp.ms[*].X[*] - delete matching SparseNDMatrix values, joining on the soma_dim_0 dimension

  • exp.ms[*].obsm[*] - delete matching SparseNDMatrix values, joining on the soma_dim_0 dimension

  • exp.ms[*].obsp[*] - delete matching SparseNDMatrix values, joining on the soma_dim_0 and soma_dim_1 dimension

  • exp.spatial[*].obsl[*] - delete matching DataFrame elements, joining on the soma_joinid dimension

The following sub-objects are unaffected by this operation:

  • exp.ms[*].var

  • exp.ms[*].varm[*]

  • exp.ms[*].varp[*]

  • any user-defined arrays within the collection

If any affected sub-objects are of type DenseNDArray (dense TileDB array), the entire operation results in an error.

Either coords or value_filter must be provided. When both coords and value_filter are provided, the observations that match both constraints will be removed.

For example, to delete observations where n_genes > 1000 and n_counts < 2000:
>>> with tiledbsoma.Experiment.open(experiment_uri, mode="d") as exp:
...     exp.obs_axis_delete(value_filter="n_genes > 1000 and n_counts < 2000")

Note: Deleting observations does not change the size of the current domain or possible enumeration values.

Parameters:
  • coords – A per-dimension Sequence of scalar, slice, sequence of scalar or Arrow IntegerArray <https://arrow.apache.org/docs/python/generated/pyarrow.IntegerArray.html> values defining the region to read.

  • value_filter – An optional [value filter] to apply to the results. Defaults to no filter.