domain_to_parquet#

domain_to_parquet(domain, name_of_file=None, path_to_save=None, save_summary=True, return_dataframe=False)#

Export a domain object as a parquet file. All object properties will be saved as columns in the parquet file including labels and collections associated with the object. Optionally, the function can return the pandas dataframe that was saved to the parquet file. If the domain contains shape objects, the dataframe will include the vertices of the shapes instead of the shape centroids. There will be an additional column ‘hole_id’ to identify vertices that belong to internal holes of shapes.

Parameters:
domainmuspan.domain

The domain object to be exported as csv.

name_of_filestr or None, optional

The name of the saved parquet file. If None, the domain’s name will be used. Default is None.

path_to_savestr or None, optional

The path to the folder where the file will be saved. If None, the current directory will be used. Default is None.

save_summarybool, optional

If True, a summary message will be printed after saving the file. Default is True.

return_dataframebool, optional

If True, the pandas.dataframe will be returned. Default is False.

Returns:
pandas.DataFrame

The dataframe that was saved to the parquet file. Only returned if return_df is True.

Raises:
ValueError

If domain is not of type muspan.domain. If path_to_save is not a string or None. If name_of_file is not a string or None.

Examples

import muspan as ms

# load an example domain
example_domain = ms.datasets.load_example_domain('Xenium-Healthy-Colon')

# save the domain locally to the current working directory with a specified file name
path_to_save = '.'
name_of_file = 'saved_example_domain.parquet'

# save the domain
ms.io.domain_to_parquet(example_domain, name_of_file=name_of_file, path_to_save=path_to_save)