spateo.configuration¶
Attributes¶
Classes¶
Functions¶
|
Function to offset the "center" of a colormap. Useful for |
Reset matplotlib.rcParams to defaults. |
|
|
|
|
Configure matplotlib.rcParams to spateo defaults (based on ggplot style and scanpy). |
|
Set resolution/size, styling and format of figures. |
|
formatting helper function that can be used to save publishable figures |
formatting helper function based on mpltex package that can be used to save publishable figures |
Module Contents¶
- class spateo.configuration.SpateoConfig(logging_level: int = logging.INFO, n_threads: int = os.cpu_count())[source]¶
- class spateo.configuration.SpateoAdataKeyManager[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]¶
- 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.zebrafish_colors = ['#4876ff', '#85C7F2', '#cd00cd', '#911eb4', '#000080', '#808080', '#008080', '#ffc125',...[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.