Setting configurations in SpatialTis

[1]:
from spatialtis import CONFIG

To check the what configurations can be set and what’s the current value, just print the CONFIG

[2]:
print(CONFIG)
Current configurations of SpatialTis 
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Options           Value          ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ OS                Darwin         │
│ MP                True           │
│ WORKING_ENV       jupyter        │
│ VERBOSE           True           │
│ PBAR              True           │
│ AUTO_SAVE         False          │
│ EXP_OBS           None           │
│ ROI_KEY           None           │
│ CELL_TYPE_KEY     None           │
│ MARKER_KEY        marker         │
│ NEIGHBORS_KEY     cell_neighbors │
│ CENTROID_KEY      centroid       │
│ AREA_KEY          area           │
│ SHAPE_KEY         cell_shape     │
│ ECCENTRICITY_KEY  eccentricity   │
└──────────────────┴────────────────┘

There are a few points to be noticed!

<ol>
    <li>
        Options in CONFIG are all <strong>CAPITALIZED</strong>
    </li>
    <li>
        The changes happen on the fly!
    </li>
    <li>
        Can be overwritted by <strong>local parameter</strong>
    </li>
</ol>

For example, If you turn on multi processing, every functions supported parallelism will execute using multi-CPUs afterwards. This happen on the fly.

[3]:
CONFIG.MP = True

However, if you don’t want to use parallelism in some analysis, you can turn it off only in that analysis.

import spatialtis as st
st.spatial_distribution(data, mp=False)

Or you want to turn it off for every function afterwards.

[4]:
CONFIG.MP = False

Setting CONFIG.EXP_OBS and CONFIG.ROI_KEY

EXP_OBS represents experiment observations, this is used to tell SpatialTis how your data grouped.

[5]:
CONFIG.EXP_OBS = ['ROI', 'Patient', 'Stage']

However, SpatialTis has no idea which level is ROI. By default it will assume the last one is the ROI level, but this is not the case here.

[6]:
CONFIG.ROI_KEY
[6]:
'Stage'

We need to explicit set the key of ROI

[7]:
CONFIG.ROI_KEY = 'ROI'
print(f"ROI key: {CONFIG.ROI_KEY}", f"EXP_OBS: {CONFIG.EXP_OBS}", sep="\n")
ROI key: ROI
EXP_OBS: ['Patient', 'Stage', 'ROI']

Now SpatialTis got how your data grouped correctly!

Setting Keys

To work with analysis in SpatialTis, it’s very important to know where your data is stored.

Remember to specific those keys.

  • CELL_TYPE_KEY

  • MARKER_KEY

  • NEIGHBORS_KEY

  • CENTROID_KEY

  • AREA_KEY

  • SHAPE_KEY

  • ECCENTRICITY_KEY

Setting CONFIG.WORKING_ENV

As of 0.3.0, SpatialTis will auto-detect your working environment. In jupyter, terminal or None

Settting CONFIG.VERBOSE and CONFIG.PBAR

This is to control the display of logging and progress bar,

If you don’t want SpatialTis to print anything

[8]:
CONFIG.VERBOSE = False

This will also turn off progress bar, if you just don’t want progress bar

[9]:
CONFIG.PBAR = False