spateo.configuration#

Module Contents#

Classes#

Functions#

shiftedColorMap(cmap[, start, midpoint, stop, name])

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

reset_rcParams()

Reset matplotlib.rcParams to defaults.

spateo_theme([background])

config_spateo_rcParams([background, prop_cycle, ...])

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

set_figure_params([spateo, background, fontsize, ...])

Set resolution/size, styling and format of figures.

set_pub_style([scaler])

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#

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]#
X_LAYER = X[source]#
gen_new_layer_key(key, sep='_') str[source]#
select_layer_data(layer: str, copy: bool = False, make_dense: bool = False) Union[numpy.ndarray, scipy.sparse.spmatrix][source]#
set_layer_data(layer: str, vals: numpy.ndarray, var_indices: Optional[numpy.ndarray] = 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: Optional[str] = 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, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap')[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.

Input#

cmap : The matplotlib colormap to be altered start : Offset from lowest point in the colormap’s range.

Defaults to 0.0 (no lower offset). Should be between 0.0 and midpoint.

midpointThe 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

stopOffset from highest point in the colormap’s range.

Defaults to 1.0 (no upper offset). Should be between midpoint and 1.0.

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='white', prop_cycle=zebrafish_256, fontsize=8, color_map=None, frameon=None)[source]#

Configure matplotlib.rcParams to spateo defaults (based on ggplot style and scanpy). :param 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.

Parameters
prop_cycle : list (default: zebrafish_256)

A list with hex color codes

fontsize : float (default: 6)

Size of font

color_map : plt.cm or None (default: None)

Color map

frameon : bool or None (default: None)

Whether to have frame for the figure.

Returns

Nothing but configure the rcParams globally.

spateo.configuration.set_figure_params(spateo=True, background='white', fontsize=8, figsize=(6, 4), dpi=None, dpi_save=None, frameon=None, vector_friendly=True, color_map=None, format='pdf', transparent=False, ipython_format='png2x')[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.

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

formatting helper function that can be used to save publishable figures

spateo.configuration.set_pub_style_mpltex()[source]#

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