spatialdata.models.PointsModel#

class spatialdata.models.PointsModel#

Attributes table#

ATTRS_KEY

FEATURE_KEY

INSTANCE_KEY

NPARTITIONS

TRANSFORM_KEY

Methods table#

parse(data, **kwargs)

Validate (or parse) points data.

validate(data)

Validate data.

Attributes#

PointsModel.ATTRS_KEY = 'spatialdata_attrs'#
PointsModel.FEATURE_KEY = 'feature_key'#
PointsModel.INSTANCE_KEY = 'instance_key'#
PointsModel.NPARTITIONS = 1#
PointsModel.TRANSFORM_KEY = 'transform'#

Methods#

classmethod PointsModel.parse(data, **kwargs)#

Validate (or parse) points data.

Parameters:
  • data (Any) –

    Data to parse:

    • If numpy.ndarray, an annotation pandas.DataFrame can be provided, as well as a feature_key column in the annotation dataframe. Furthermore, numpy.ndarray is assumed to have shape (n_points, axes), with axes being “x”, “y” and optionally “z”.

    • If pandas.DataFrame, a coordinates mapping can be provided with key as valid axes (‘x’, ‘y’, ‘z’) and value as column names in dataframe. If the dataframe already has columns named ‘x’, ‘y’ and ‘z’, the mapping can be omitted.

  • annotation – Annotation dataframe. Only if data is numpy.ndarray. If data is an array, the index of the annotations will be used as the index of the parsed points.

  • coordinates – Mapping of axes names (keys) to column names (valus) in data. Only if data is pandas.DataFrame. Example: {‘x’: ‘my_x_column’, ‘y’: ‘my_y_column’}. If not provided and data is pandas.DataFrame, and x, y and optionally z are column names, then they will be used as coordinates.

  • feature_key – Optional, feature key in annotation or data. Example use case: gene id categorical column describing the gene identity of each point.

  • instance_key – Optional, instance key in annotation or data. Example use case: cell id column, describing which cell a point belongs to. This argument is likely going to be deprecated: scverse/spatialdata#503.

  • transformations – Transformations of points.

  • kwargs (Any) – Additional arguments for dask.dataframe.from_array().

Return type:

DataFrame

Returns:

: dask.dataframe.core.DataFrame

Notes

The order of the columns of the dataframe returned by the parser is not guaranteed to be the same as the order of the columns in the dataframe passed as an argument.

classmethod PointsModel.validate(data)#

Validate data.

Parameters:

data (DataFrame) – dask.dataframe.core.DataFrame to validate.

Return type:

None

Returns:

: None