metaspace_converter.to_spatialdata module
- metaspace_converter.to_spatialdata.get_ion_image_to_physical_transformation(dataset)[source]
Get the transformation from the ion image (pixels) to the world coordinate system (micrometers).
- metaspace_converter.to_spatialdata.metaspace_to_spatialdata(dataset=None, dataset_id=None, database=None, fdr=0.1, use_tic=False, metadata_as_obs=False, add_optical_image=True, optical_name_added='optical_image', add_points=True, points_name_added='maldi_points', sm=None, **annotation_filter)[source]
Download a METASPACE dataset as a
SpatialDataobject.See: https://metaspace2020.eu/about
- Parameters:
dataset (
Optional[SMDataset]) – A METASPACE dataset instance. If not provided, thedataset_idmust be given.dataset_id (
Optional[str]) – The unique ID of a dataset on METASPACE, e.g. “2021-09-03_11h43m13s”database (
Optional[tuple[str,str]]) – A single METASPACE database given as a tuple of name and version. Usually it is displayed on METASPACE as “HMDB – v4” which corresponds to("HMDB", "v4").fdr (
float) – Returns only annotations for which the false discovery rate is less or equal to this limit.use_tic (
bool) – When True, the output values will be scaled by the total ion count per pixel and will be in 0.0 to 1.0 range.metadata_as_obs (
bool) – Whether to store metadata in theobsdataframe instead ofuns. For a single METASPACE dataset, metadata is the same for all pixels, so it would be duplicated for allobs. When combining multiple datasets, it would be preserved inobsbut not inuns.add_optical_image (
bool) – Whether to also add the optical image (if one exists) to SpatialData images. If none exists, it is not added, and no error raised.optical_name_added (
str) – Name of the element where to store the image in the SpatialData objectadd_points (
bool) – Whether to also add ion image pixel coordinates as SpatialData points. This allows to spatially visualize the ion image values. If False, only ion intensities are added to the table and coordinates are added toobs.points_name_added (
str) – Name of the element where to store the points in the SpatialData objectsm (
Optional[SMInstance]) – Optionally a cached SMInstanceannotation_filter – Additional keyword arguments passed to the METASPACE API.
- Return type:
- Returns:
- A
SpatialDataobject with ion intensities and metadata:
.tableoptical image:
.images["optical_image"](oroptical_name_added)sampling coordinates:
.points["maldi_points"](orpoints_name_added) in a coordinate system relative to the top-left image corner and physical scale (micrometers)
- A
- Raises:
ValueError – If something is wrong with the input data or parameters
metaspace.sm_annotation_utils.DatasetNotFound – If the dataset ID is not found
ConnectionError – For any other network connectivity problems