spatialcells.plotting
Module for plotting spatial cells regions.
Access via either spatialcells.plotting
or spatialcells.plt
.
plotBoundary
- spatialcells.plt.plotBoundary(boundary, ax=None, **kwargs)
Plot the boundary.
- Parameters:
boundary – the MultiPolygon boundary of the region
ax – the matplotlib ax object. If None (default), use plt.
kwargs – kwargs for matplotlib.pyplot.plot
plotCommunities
- spatialcells.plt.plotCommunities(adata, ret, communitycolumn, plot_first_n_clusters=10, **kwargs)
Plot largest communities on a scatter plot. Each community is labelled as: (rank in descending number of cells : index of community)
- Parameters:
adata – AnnData object
ret – return value of spc.spa.getCommunities
communitycolumn – column name of the community column in adata.obs
plot_first_n_clusters – plot and number the largest n communities
kwargs – keyword arguments for matplotlib.pyplot.plot
plotRegions
- spatialcells.plt.plotRegions(regions_list, ax=None, add_label=True, label_prefix='', x_offset=0, y_offset=0, fontsize=12, label_bounds=None, colors_list=['k', 'r', 'b', 'g'], fontcolor='black', foreground_linewidth=5, **kwargs)
Plot the regions in the regions_list and label them with their index in the list. labels are placed at the lower left corner of each region. Their position can be adjusted by x_offset and y_offset, and the overall label_bounds.
- Parameters:
regions_list – a list of MultiPolygon regions
add_label – whether to label the regions
ax – the matplotlib ax object.
label_prefix – a prefix to the label of each region
x_offset – the x offset of each label
y_offset – the y offset of the label
fontsize – the fontsize of the label
label_bounds – the bounds of all the label (minx, miny, maxx, maxy). If None, the bounds of the regions_list will be used.
colors_list – a list of colors that will be cycled through for each region.
fontcolor – the fontcolor of the label
foreground_linewidth – the foreground linewidth of the label. Adjusts the thickness of the white border around each label.
kwargs – kwargs for matplotlib.pyplot.plot