spateo.configuration#

Module Contents#

Classes#

Functions#

shiftedColorMap(→ matplotlib.colors.ListedColormap)

Function to offset the "center" of a colormap. Useful for

reset_rcParams()

Reset matplotlib.rcParams to defaults.

spateo_theme([background])

config_spateo_rcParams(→ None)

Configure matplotlib.rcParams to spateo defaults (based on ggplot style and scanpy).

set_figure_params(, dpi, dpi_save, frameon, ...)

Set resolution/size, styling and format of figures.

set_pub_style(→ None)

formatting helper function that can be used to save publishable figures

set_pub_style_mpltex()

formatting helper function based on mpltex package that can be used to save publishable figures

Attributes#

spateo.configuration.EPS[source]#
spateo.configuration.MAX[source]#
class spateo.configuration.SpateoConfig(logging_level: int = logging.INFO, n_threads: int = os.cpu_count())[source]#
property logging_level[source]#
property n_threads[source]#
spateo.configuration.config[source]#
class spateo.configuration.SpateoAdataKeyManager[source]#
ADATA_TYPE_KEY = '__type'[source]#
ADATA_DEFAULT_TYPE[source]#
ADATA_AGG_TYPE = 'AGG'[source]#
ADATA_UMI_TYPE = 'UMI'[source]#
UNS_PP_KEY = 'pp'[source]#
UNS_SPATIAL_KEY = 'spatial'[source]#
UNS_SPATIAL_BINSIZE_KEY = 'binsize'[source]#
UNS_SPATIAL_SCALE_KEY = 'scale'[source]#
UNS_SPATIAL_SCALE_UNIT_KEY = 'scale_unit'[source]#
UNS_SPATIAL_SEGMENTATION_KEY = 'segmentation'[source]#
UNS_SPATIAL_ALIGNMENT_KEY = 'alignment'[source]#
UNS_SPATIAL_QC_KEY = 'qc'[source]#
SPLICED_LAYER_KEY = 'spliced'[source]#
UNSPLICED_LAYER_KEY = 'unspliced'[source]#
STAIN_LAYER_KEY = 'stain'[source]#
LABELS_LAYER_KEY = 'labels'[source]#
MASK_SUFFIX = 'mask'[source]#
MARKERS_SUFFIX = 'markers'[source]#
DISTANCES_SUFFIX = 'distances'[source]#
BINS_SUFFIX = 'bins'[source]#
LABELS_SUFFIX = 'labels'[source]#
SCORES_SUFFIX = 'scores'[source]#
EXPANDED_SUFFIX = 'expanded'[source]#
AUGMENTED_SUFFIX = 'augmented'[source]#
SELECTION_SUFFIX = 'selection'[source]#
BOUNDARY_SUFFIX = 'boundary'[source]#
X_LAYER = 'X'[source]#
gen_new_layer_key(key: str, sep: str = '_') str[source]#
select_layer_data(layer: str, copy: bool = False, make_dense: bool = False) numpy.ndarray | scipy.sparse.spmatrix[source]#
set_layer_data(layer: str, vals: numpy.ndarray, var_indices: numpy.ndarray | None = None, replace: bool = False)[source]#
get_adata_type() str[source]#
adata_is_type(t: str) bool[source]#
check_adata_is_type(argname: str = 'adata', optional: bool = False)[source]#
init_adata_type(t: str | None = None)[source]#
init_uns_pp_namespace()[source]#
init_uns_spatial_namespace()[source]#
set_uns_spatial_attribute(key: str, value: object)[source]#
get_uns_spatial_attribute(key: str) object[source]#
has_uns_spatial_attribute(key: str) bool[source]#
get_agg_bounds() Tuple[int, int, int, int][source]#

Get (xmin, xmax, ymin, ymax) for AGG type anndatas.

spateo.configuration.SKM[source]#
spateo.configuration.shiftedColorMap(cmap: matplotlib.colors.ListedColormap, start: float = 0, midpoint: float = 0.5, stop: float = 1.0, name: str = 'shiftedcmap') matplotlib.colors.ListedColormap[source]#

Function to offset the “center” of a colormap. Useful for data with a negative min and positive max, and you want the middle of the colormap’s dynamic range to be at zero.

Parameters:
cmap

The matplotlib colormap to be altered

start

Offset from the lowest point in the colormap’s range. Defaults to 0.0 (no lower offset). Should be between 0.0 and midpoint.

midpoint

The new center of the colormap. Defaults to 0.5 (no shift). Should be between 0.0 and 1.0. In general, this should be 1 - vmax / (vmax + abs(vmin)) For example if your data range from -15.0 to +5.0, and you want the center of the colormap at 0.0, midpoint should be set to 1 - 5/(5 + 15)) or 0.75

stop

Offset from the highest point in the colormap’s range. Defaults to 1.0 (no upper offset). Should be between midpoint and 1.0.

name

the colormap name of the shifted colormap that will be registered.

Returns:

a new colormap that has the middle point of the colormap shifted.

Return type:

newcmap

spateo.configuration.fire_cmap[source]#
spateo.configuration.darkblue_cmap[source]#
spateo.configuration.darkgreen_cmap[source]#
spateo.configuration.darkred_cmap[source]#
spateo.configuration.darkpurple_cmap[source]#
spateo.configuration.div_blue_black_red_cmap[source]#
spateo.configuration.div_blue_red_cmap[source]#
spateo.configuration.glasbey_white_cmap[source]#
spateo.configuration.glasbey_dark_cmap[source]#
spateo.configuration._themes[source]#
spateo.configuration.reset_rcParams()[source]#

Reset matplotlib.rcParams to defaults.

spateo.configuration.zebrafish_colors = ['#4876ff', '#85C7F2', '#cd00cd', '#911eb4', '#000080', '#808080', '#008080', '#ffc125',...[source]#
spateo.configuration.cyc_10[source]#
spateo.configuration.cyc_20[source]#
spateo.configuration.zebrafish_256[source]#
spateo.configuration.spateo_theme(background='white')[source]#
spateo.configuration.config_spateo_rcParams(background: str = 'white', prop_cycle: List[str] = zebrafish_256, fontsize: int = 8, color_map: matplotlib.colors.ListedColormap = None, frameon: bool | None = None) None[source]#

Configure matplotlib.rcParams to spateo defaults (based on ggplot style and scanpy).

Parameters:
background

The background color of the plot. By default, we use the white ground which is suitable for producing figures for publication. Setting it to black background will be great for presentation.

prop_cycle

A list with hex color codes

fontsize

Size of font

color_map

Color map

frameon

Whether to have frame for the figure.

Returns:

Nothing but configure the rcParams globally.

spateo.configuration.set_figure_params(spateo: bool = True, background: str = 'white', fontsize: int = 8, figsize: Tuple[int, int] = (6, 4), dpi: float | None = None, dpi_save: int | None = None, frameon: bool | None = None, vector_friendly: bool = True, color_map: str | None = None, format: str = 'pdf', transparent: bool = False, ipython_format: str = 'png2x') None[source]#
Set resolution/size, styling and format of figures.

This function is adapted from: https://github.com/theislab/scanpy/blob/f539870d7484675876281eb1c475595bf4a69bdb/scanpy/_settings.py

Parameters:
spateo

bool (default: True) Init default values for matplotlib.rcParams suited for spateo.

background

str (default: white) The background color of the plot. By default we use the white ground which is suitable for producing figures for publication. Setting it to black background will be great for presentation.

fontsize

[float, float] or None (default: 6)

figsize

(float, float) (default: (6.5, 5)) Width and height for default figure size.

dpi

int or None (default: None) Resolution of rendered figures - this influences the size of figures in notebooks.

dpi_save

int or None (default: None) Resolution of saved figures. This should typically be higher to achieve publication quality.

frameon

bool or None (default: None) Add frames and axes labels to scatter plots.

vector_friendly

bool (default: True) Plot scatter plots using png backend even when exporting as pdf or svg.

color_map

str (default: None) Convenience method for setting the default color map.

format

{‘png’, ‘pdf’, ‘svg’, etc.} (default: ‘pdf’) This sets the default format for saving figures: file_format_figs.

transparent

bool (default: False) Save figures with transparent back ground. Sets rcParams[‘savefig.transparent’].

ipython_format

list of str (default: ‘png2x’) Only concerns the notebook/IPython environment; see IPython.core.display.set_matplotlib_formats for more details.

Returns:

Nothing but update the figure configurations.

spateo.configuration.set_pub_style(scaler: float = 1) None[source]#

formatting helper function that can be used to save publishable figures

Parameters:
scaler

The multiplier to universally increase or decrease the font sizes.

Returns:

Nothing but set up the configuration for saving publishable figures.

spateo.configuration.set_pub_style_mpltex()[source]#

formatting helper function based on mpltex package that can be used to save publishable figures