COSIE.downstream_analysis.prepare_image
- prepare_image(adata, molecule_name, basis, swap_xy, invert_x, invert_y, offset)[source]
Prepare a 2D image from molecule expression and spatial coordinates in an AnnData object.
Parameters
- adataAnnData
AnnData object containing spatial coordinates in obsm[basis] and molecule expression in X.
- molecule_namestr
Name of the molecule to visualize.
- basisstr
The key in obsm to use for spatial coordinates (e.g., “spatial”).
- swap_xybool
Whether to swap x and y coordinates.
- invert_xbool
Whether to flip the image horizontally.
- invert_ybool
Whether to flip the image vertically.
- offsetbool
Whether to shift coordinates so that the minimum becomes (0, 0).
Returns
- imagenp.ndarray
2D array of shape (height, width) representing the molecule intensity at each spatial location.