spatialdata.models.PointsModel#
- class spatialdata.models.PointsModel#
Attributes table#
Methods table#
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
, anannotation
pandas.DataFrame
can be provided, as well as afeature_key
column in theannotation
dataframe. Furthermore,numpy.ndarray
is assumed to have shape(n_points, axes)
, withaxes
being “x”, “y” and optionally “z”.If
pandas.DataFrame
, acoordinates
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
isnumpy.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 ifdata
ispandas.DataFrame
. Example: {‘x’: ‘my_x_column’, ‘y’: ‘my_y_column’}. If not provided anddata
ispandas.DataFrame
, andx
,y
and optionallyz
are column names, then they will be used as coordinates.feature_key – Optional, feature key in
annotation
ordata
. Example use case: gene id categorical column describing the gene identity of each point.instance_key – Optional, instance key in
annotation
ordata
. 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 fordask.dataframe.from_array()
.
- Return type:
- Returns:
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