spatialdata-io
spatialdata-io copied to clipboard
cosmx - ValueError: Affine matrix must be homogeneous.
Hi,
I'm trying to read in some CosMx data - I have a dataset formatted into a folder with the CellLabels and CellComposite directories and then the relevant CSV files. When I execute the code below:
adata3 = sp.cosmx(sample_dir,
dataset_id = 'GCIN10692_TMA2')
I get the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[21], line 1
----> 1 adata3 = sp.cosmx(sample_dir,
2 dataset_id = 'GCIN10692_TMA2')
File [/path/to/in839/analysis/init-rocker-renv/venv/lib/python3.12/site-packages/spatialdata_io/readers/cosmx.py:148](http://localhost:8888/lab/tree/venv/lib/python3.12/site-packages/spatialdata_io/readers/cosmx.py#line=147), in cosmx(path, dataset_id, transcripts, imread_kwargs, image_models_kwargs)
146 glob = table[idx, :].obs[[CosmxKeys.X_GLOBAL_CELL, CosmxKeys.Y_GLOBAL_CELL]].values
147 out = estimate_transform(ttype="affine", src=loc, dst=glob)
--> 148 affine_transforms_to_global[fov] = Affine(
149 # out.params, input_coordinate_system=input_cs, output_coordinate_system=output_cs
150 out.params,
151 input_axes=("x", "y"),
152 output_axes=("x", "y"),
153 )
155 table.obsm["global"] = table.obs[[CosmxKeys.X_GLOBAL_CELL, CosmxKeys.Y_GLOBAL_CELL]].to_numpy()
156 table.obsm["spatial"] = table.obs[[CosmxKeys.X_LOCAL_CELL, CosmxKeys.Y_LOCAL_CELL]].to_numpy()
File [/path/to/in839/analysis/init-rocker-renv/venv/lib/python3.12/site-packages/spatialdata/transformations/transformations.py:523](http://localhost:8888/lab/tree/venv/lib/python3.12/site-packages/spatialdata/transformations/transformations.py#line=522), in Affine.__init__(self, matrix, input_axes, output_axes)
521 raise ValueError("Invalid shape for affine matrix.")
522 if not np.array_equal(self.matrix[-1, :-1], np.zeros(len(input_axes))):
--> 523 raise ValueError("Affine matrix must be homogeneous.")
524 assert self.matrix[-1, -1] == 1.0
ValueError: Affine matrix must be homogeneous.
Any recommendations on how to address this?
Cheers