spatialtis.config._Config#

class spatialtis.config._Config[source]#

Global configurations for spatialtis.

Do not directly import this class, import the instance created for you.

>>> from spatialtis import Config

This allows you to set global configuration, so that you don’t have to repeatly pass the same parameters in every function.

To set a config, simple set the attribute.

>>> Config.auto_save = True  # auto save to current directory
>>> Config.auto_save = "my_spatialtis_result"  # save to custom directory

To view your current configs.

>>> Config.view()
       Current configurations of SpatialTis
┌─────────────────────────┬───────────────┬───────┐
│ Options                 │ Attributes    │ Value │
├─────────────────────────┼───────────────┼───────┤
│ Multiprocessing         │ mp            │ True  │
│ Verbose                 │ verbose       │ True  │
│ Progress bar            │ progress_bar  │ False │
│ Auto save               │ auto_save     │ False │
│ Experiment observations │ exp_obs       │ None  │
│ ROI key                 │ roi_key       │       │
│ Cell type key           │ cell_type_key │       │
│ Marker key              │ marker_key    │       │
│ Centroid key            │ centroid_key  │       │
│ Shape key               │ shape_key     │       │
└─────────────────────────┴───────────────┴───────┘
Attributes
exp_obsstr or list of str, default: None

Required. The columns in .obs that tells how your experiments organized, for example, you have different columns [‘patients’, ‘sex’, ‘organ_part’, ‘roi_id’], the last one will be used as roi_key. You can override it by setting roi_key.

centroid_keystr, default: None

Required. The column in .obs or .obsm that store cell coordination, could be array-like or wkt format.

roi_keystr, default: None

Set the roi_key.

shape_keystr, default: None

The columns in .obs that store cell shape, must be in wkt format, use spatialtis.wkt_shapes to transform you data into wkt.

cell_type_keystr, default: None

The columns in .obs that store cell type name, some analyses require cell type name to proceed.

marker_keystr, default: None

The columns in .var that store protein/gene/transcript… name, if not specific, will use .var.index.

mpbool, default: True

To turn on/off multiprocessing. From v0.5.0, this paramter has no effect.

verbosebool, default: True

Control the printed message.

progress_barbool, default True

Control the progress bar.

auto_savebool or str or path, default: False

Set to True will automatically save all images in spatialtis_result fold created at current directory, you can also pass a path to it.

Methods

dumps(data)

Save configurations to anndata

loads(data)

Load configurations from anndata

reset()

Reset to default

view()

Print a table with current configurations

dumps(data)[source]#

Save configurations to anndata

Parameters
dataAnnData

The AnnData object to save the Config

loads(data)[source]#

Load configurations from anndata

Parameters
dataAnnData

The AnnData object to load the Config

reset()[source]#

Reset to default

view()[source]#

Print a table with current configurations