Plotting

UniCell Deconvolve - Cell Type Deconvolution For Transcriptomic Data.

ucdeconvolve.pl.base_clustermap(adata: AnnData, groupby: str = 'leiden', category: Optional[str] = None, key: str = 'ucdbase', n_top_celltypes: int = 30, max_filter: float = 0.1, **kwargs) Optional

Plot Clustered heatmap of top celltype predictions grouped by a column in ‘adata.obs’

Parameters:
  • adata – The annotated dataset with deconvolution data

  • groupby – What column in ‘adata.obs’ to group celltype predictions by (i.e. ‘leiden’).

  • category – Which category of prediction data to use if split, or all of not split.

  • key – Key for deconvolution results, default is ‘ucdbase’

  • n_top_celltypes – Number of top celltypes per category to take and plot. Smaller means only the most common types.

  • kwargs – Keyword attributes for clustermap. See seaborn.clustermap for details.

Return type:

A clustermap

ucdeconvolve.pl.embedding(adata: AnnData, basis: str = 'X_umap', color: Optional[Union[str, List[str]]] = None, key: str = 'ucdbase', category: Optional[str] = None, **kwargs) Optional[object]

Plot Deconvolution

Wrapper for scanpy function ‘sc.pl.embedding’ to help plot deconvolution results. Follows the parameter conventions of its wrapped function with some exceptions noted below.

Functions to read the results from the deconvolution run given by key, subset to category and then appends them to the ‘adata.obs’ dataframe of a copy of the passed adata object, allowing standard plotting module to the visualize the results.

Parameters:
  • adata – anndata object to plot

  • basis – The embedding to plot using, for example ‘X_pca’ or ‘X_umap’ if calculated and present.

  • color – Refers to the cell type we want to plot contained within the category of split and result specificed by key. Can be one or more.

  • key – location of data in obsm and uns to plot containing numerical data and headers, respectively. Can be either ‘ucdbase’ or ‘ucdselect’.

  • category – if the data results are split, indicate which split to use for plotting. defaults to ‘all’ assuming that we did not split the output. valid categories are ‘all’, ‘primary’, ‘cell_lines’, and ‘cancer’.

  • kwargs – attributes to pass along to ‘sc.pl.embedding’, see documentation for details.

Return type:

Plot(s)

ucdeconvolve.pl.explain_boxplot(adata: AnnData, key: str = 'ucdexplain', celltypes: Optional[Union[str, List[str]]] = None, n_top_genes: int = 16, ncols: int = 5, figsize: Tuple[int, int] = (3, 3), dpi: int = 150, titlewidth: int = 24, barcolor: str = 'lightblue', ax: Optional[Axes] = None, return_fig: bool = False) Optional[Axes]

Plot Boxplots of Feature Attributions By Gene

Parameters:
  • adata – Annotated dataset with ucdexplain results.

  • key – UCDExplain results key, default is ‘ucdexplain’

  • celltypes – The celltypes from the given run to plot. if none then plots all.

  • n_top_genes – Number of top attribution genes to plot.

  • ncols – Number of columns to plot for multiple celltypes before creating a new row

  • figsize – Size of individual subplot figure

  • dpi – Pixel density of plot

  • titlewidth – Width of subplot title before newline

  • barcolor – Color of bars

  • ax – Optional axes to plot on.

  • return_fig – Return figure or not

Returns:

fig – Figure with underlying subplots

Return type:

plt.Figure

ucdeconvolve.pl.explain_clustermap(adata: AnnData, key: Union[str, List[str]] = 'ucdexplain', n_top_genes: int = 64, **kwargs) Optional[Axes]

Plot Explanation Results as Clustermap

Plot Clustered heatmap of top feature attribution predictions grouped by the celltypes passed to the ucd.tl.explain function.

Parameters:
  • adata – The annotated dataset with deconvolution data

  • key – Key for deconvolution results, default is ‘ucdexplain’.

  • n_top_genes – Number of top feature attributes (genes) per celltype

  • kwargs – Keyword attributes for clustermap. See seaborn.clustermap for details.

Return type:

A clustermap

ucdeconvolve.pl.spatial(adata: AnnData, color: Optional[Union[str, List[str]]] = None, key: str = 'ucdbase', category: Optional[str] = None, labels: Optional[List[str]] = None, colormaps: Optional[List[ListedColormap]] = None, cbar_nrows: int = 4, title: str = '', **kwargs) Optional[object]

Plot Spatial

Wrapper for scanpy function ‘sc.pl.spatial’ to help plot deconvolution results on spatial data. Follows parameter conventions of wrapped function with some exceptions.

Functions to read the results from the deconvolution run given by key, subset to category and then appends them to the ‘adata.obs’ dataframe of a copy of the passed adata object, allowing standard plotting module to the visualize the results.

Parameters:
  • adata – anndata object to plot

  • color – Refers to the cell type(s) we want to plot contained within the category of split and result specificed by key. Can be one or more. If more than one string is passed we try to plot an overlapped plot.

  • key – location of data in obsm and uns to plot containing numerical data and headers, respectively. Can be either ‘ucdbase’ or ‘ucdselect’.

  • category – if the data results are split, indicate which split to use for plotting. defaults to ‘all’ assuming that we did not split the output. valid categories are ‘all’, ‘primary’, ‘cell_lines’, and ‘cancer’.

  • labels – Labels for each color being plotted when using the overlapping colormap spatial function.

  • colormaps – Optional custom colormaps to use for each color.

  • cbar_nrows – Number of rows to spread cbars across, default is 3.

  • kwargs – attributes to pass along to ‘sc.pl.spatial’, see documentation for details.

Return type:

Plot(s)