stereo.plots.PlotCollection.cells_plotting

PlotCollection.cells_plotting(color_by='total_counts', color_key=None, bgcolor='#2F2F4F', palette=None, width=None, height=None, fg_alpha=0.5, base_image=None, base_im_to_gray=False, use_raw=True, show=True)[source]

Plot the cells.

Parameters:
  • color_by (Literal['total_counts', 'n_genes_by_counts', 'gene', 'cluster']) – spcify the way of coloring, default to ‘total_counts’. if set to ‘gene’, you need to specify a gene name by color_key. if set to ‘cluster’, you need to specify the key to get cluster result by color_key.

  • color_key (Optional[str]) – the key to get the data to color the plot, it is ignored when the color_by is set to ‘total_counts’ or ‘n_genes_by_counts’.

  • bgcolor (Optional[str]) – set background color.

  • palette (Union[str, list, dict, None]) – color theme, when color_by is ‘cluster’, it can be a palette name, a list of colors whose length equal to the groups, or a dict whose keys are the groups and values are colors, when other color_by is set, it only can be a palette name.

  • width (Optional[int]) – the figure width in pixels.

  • height (Optional[int]) – the figure height in pixels.

  • fg_alpha (Optional[float]) – the transparency of foreground image, between 0 and 1, defaults to 0.5 this is the colored image of the cells.

  • base_image (Optional[str]) – the path of the ssdna image after calibration, defaults to None it will be located behide the image of the cells.

  • base_im_to_gray (bool) – whether to convert the base image to gray scale if base image is RGB/RGBA image.

  • use_raw (bool) – whether to use raw data, defaults to True if .raw is present.

  • show (bool) – show the figure directly or get the figure object, defaults to True. If set to False, you need to call the show method of the figure object to show the figure.

  • reorganize_coordinate

    if the data is merged from several slices, whether to reorganize the coordinates of the obs(cells), if set it to a number, like 2, the coordinates will be reorganized to 2 columns on coordinate system as below:

    data1 data2
    data3 data4
    data5 …
    … …

    if set it to False, the coordinates will not be changed.

  • horizontal_offset_additional – the additional offset between each slice on horizontal direction while reorganizing coordinates.

  • vertical_offset_additional – the additional offset between each slice on vertical direction while reorganizing coordinates.

:return the figure object if show is set to False, otherwise, show the figure directly.

Note

This plot can be exported as PNG, SVG or PDF.

You need the following necessary dependencies to support exporting:

conda install -c conda-forge selenium firefox geckodriver cairosvg

On Linux, you may need to install some additional libraries to support the above dependencies, for example, on Ubuntu, the following libraries need to be installed:

sudo apt-get install libgtk-3-dev libasound2-dev

On others Linux, you may need to install the corresponding libraries according to the error message.

There are two ways to export the plot, one is to manupulate on browser when you run it on jupyter notebook, another is to call the method save_plot of this figure object.

Example code for the second way:

fig = data.plt.cells_plotting(show=False)
fig.show()
fig.save_plot('path/to/save/plot.pdf')