spateo.configuration ==================== .. py:module:: spateo.configuration Attributes ---------- .. autoapisummary:: spateo.configuration.EPS spateo.configuration.MAX spateo.configuration.config spateo.configuration.SKM spateo.configuration.fire_cmap spateo.configuration.darkblue_cmap spateo.configuration.darkgreen_cmap spateo.configuration.darkred_cmap spateo.configuration.darkpurple_cmap spateo.configuration.div_blue_black_red_cmap spateo.configuration.div_blue_red_cmap spateo.configuration.glasbey_white_cmap spateo.configuration.glasbey_dark_cmap spateo.configuration._themes spateo.configuration.zebrafish_colors spateo.configuration.cyc_10 spateo.configuration.cyc_20 spateo.configuration.zebrafish_256 Classes ------- .. autoapisummary:: spateo.configuration.SpateoConfig spateo.configuration.SpateoAdataKeyManager Functions --------- .. autoapisummary:: spateo.configuration.shiftedColorMap spateo.configuration.reset_rcParams spateo.configuration.spateo_theme spateo.configuration.config_spateo_rcParams spateo.configuration.set_figure_params spateo.configuration.set_pub_style spateo.configuration.set_pub_style_mpltex Module Contents --------------- .. py:data:: EPS .. py:data:: MAX .. py:class:: SpateoConfig(logging_level: int = logging.INFO, n_threads: int = os.cpu_count()) .. py:property:: logging_level .. py:property:: n_threads .. py:data:: config .. py:class:: SpateoAdataKeyManager .. py:attribute:: ADATA_TYPE_KEY :value: '__type' .. py:attribute:: ADATA_DEFAULT_TYPE :value: None .. py:attribute:: ADATA_AGG_TYPE :value: 'AGG' .. py:attribute:: ADATA_UMI_TYPE :value: 'UMI' .. py:attribute:: UNS_PP_KEY :value: 'pp' .. py:attribute:: UNS_SPATIAL_KEY :value: 'spatial' .. py:attribute:: UNS_SPATIAL_BINSIZE_KEY :value: 'binsize' .. py:attribute:: UNS_SPATIAL_SCALE_KEY :value: 'scale' .. py:attribute:: UNS_SPATIAL_SCALE_UNIT_KEY :value: 'scale_unit' .. py:attribute:: UNS_SPATIAL_SEGMENTATION_KEY :value: 'segmentation' .. py:attribute:: UNS_SPATIAL_ALIGNMENT_KEY :value: 'alignment' .. py:attribute:: UNS_SPATIAL_QC_KEY :value: 'qc' .. py:attribute:: SPLICED_LAYER_KEY :value: 'spliced' .. py:attribute:: UNSPLICED_LAYER_KEY :value: 'unspliced' .. py:attribute:: STAIN_LAYER_KEY :value: 'stain' .. py:attribute:: LABELS_LAYER_KEY :value: 'labels' .. py:attribute:: MASK_SUFFIX :value: 'mask' .. py:attribute:: MARKERS_SUFFIX :value: 'markers' .. py:attribute:: DISTANCES_SUFFIX :value: 'distances' .. py:attribute:: BINS_SUFFIX :value: 'bins' .. py:attribute:: LABELS_SUFFIX :value: 'labels' .. py:attribute:: SCORES_SUFFIX :value: 'scores' .. py:attribute:: EXPANDED_SUFFIX :value: 'expanded' .. py:attribute:: AUGMENTED_SUFFIX :value: 'augmented' .. py:attribute:: SELECTION_SUFFIX :value: 'selection' .. py:attribute:: BOUNDARY_SUFFIX :value: 'boundary' .. py:attribute:: X_LAYER :value: 'X' .. py:method:: gen_new_layer_key(key: str, sep: str = '_') -> str .. py:method:: select_layer_data(layer: str, copy: bool = False, make_dense: bool = False) -> Union[numpy.ndarray, scipy.sparse.spmatrix] .. py:method:: set_layer_data(layer: str, vals: numpy.ndarray, var_indices: Optional[numpy.ndarray] = None, replace: bool = False) .. py:method:: get_adata_type() -> str .. py:method:: adata_is_type(t: str) -> bool .. py:method:: check_adata_is_type(argname: str = 'adata', optional: bool = False) .. py:method:: init_adata_type(t: Optional[str] = None) .. py:method:: init_uns_pp_namespace() .. py:method:: init_uns_spatial_namespace() .. py:method:: set_uns_spatial_attribute(key: str, value: object) .. py:method:: get_uns_spatial_attribute(key: str) -> object .. py:method:: has_uns_spatial_attribute(key: str) -> bool .. py:method:: get_agg_bounds() -> Tuple[int, int, int, int] Get (xmin, xmax, ymin, ymax) for AGG type anndatas. .. py:data:: SKM .. py:function:: shiftedColorMap(cmap: matplotlib.colors.ListedColormap, start: float = 0, midpoint: float = 0.5, stop: float = 1.0, name: str = 'shiftedcmap') -> matplotlib.colors.ListedColormap 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. :param cmap: The matplotlib colormap to be altered :param 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`. :param 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 :param 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. :param 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. :rtype: newcmap .. py:data:: fire_cmap .. py:data:: darkblue_cmap .. py:data:: darkgreen_cmap .. py:data:: darkred_cmap .. py:data:: darkpurple_cmap .. py:data:: div_blue_black_red_cmap .. py:data:: div_blue_red_cmap .. py:data:: glasbey_white_cmap .. py:data:: glasbey_dark_cmap .. py:data:: _themes .. py:function:: reset_rcParams() Reset `matplotlib.rcParams` to defaults. .. py:data:: zebrafish_colors :value: ['#4876ff', '#85C7F2', '#cd00cd', '#911eb4', '#000080', '#808080', '#008080', '#ffc125',... .. py:data:: cyc_10 .. py:data:: cyc_20 .. py:data:: zebrafish_256 .. py:function:: spateo_theme(background='white') .. py:function:: config_spateo_rcParams(background: str = 'white', prop_cycle: List[str] = zebrafish_256, fontsize: int = 8, color_map: matplotlib.colors.ListedColormap = None, frameon: Optional[bool] = None) -> None 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. :param prop_cycle: A list with hex color codes :param fontsize: Size of font :param color_map: Color map :param frameon: Whether to have frame for the figure. :returns: Nothing but configure the rcParams globally. .. py:function:: set_figure_params(spateo: bool = True, background: str = 'white', fontsize: int = 8, figsize: Tuple[int, int] = (6, 4), dpi: Optional[float] = None, dpi_save: Optional[int] = None, frameon: Optional[bool] = None, vector_friendly: bool = True, color_map: Optional[str] = None, format: str = 'pdf', transparent: bool = False, ipython_format: str = 'png2x') -> None Set resolution/size, styling and format of figures. This function is adapted from: https://github.com/theislab/scanpy/blob/f539870d7484675876281eb1c475595bf4a69bdb/scanpy/_settings.py :param spateo: `bool` (default: `True`) Init default values for :obj:`matplotlib.rcParams` suited for spateo. :param 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. :param fontsize: `[float, float]` or None (default: `6`) :param figsize: `(float, float)` (default: `(6.5, 5)`) Width and height for default figure size. :param dpi: `int` or None (default: `None`) Resolution of rendered figures - this influences the size of figures in notebooks. :param dpi_save: `int` or None (default: `None`) Resolution of saved figures. This should typically be higher to achieve publication quality. :param frameon: `bool` or None (default: `None`) Add frames and axes labels to scatter plots. :param vector_friendly: `bool` (default: `True`) Plot scatter plots using `png` backend even when exporting as `pdf` or `svg`. :param color_map: `str` (default: `None`) Convenience method for setting the default color map. :param format: {'png', 'pdf', 'svg', etc.} (default: 'pdf') This sets the default format for saving figures: `file_format_figs`. :param transparent: `bool` (default: `False`) Save figures with transparent back ground. Sets `rcParams['savefig.transparent']`. :param 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. .. py:function:: set_pub_style(scaler: float = 1) -> None formatting helper function that can be used to save publishable figures :param scaler: The multiplier to universally increase or decrease the font sizes. :returns: Nothing but set up the configuration for saving publishable figures. .. py:function:: set_pub_style_mpltex() formatting helper function based on mpltex package that can be used to save publishable figures