tacco.plots.scatter

scatter(adata, keys, position_key=('x', 'y'), group_key=None, colors=None, show_only=None, axsize=(5, 5), padding=0.5, margin=0.0, sharex=False, sharey=False, share_scaling=True, n_cols=1, joint=True, method_labels=None, counts_location=None, compositional=False, normalize=False, point_size=3, cmap=None, cmap_vmin_vmax=None, legend=True, on_data_legend=None, title=None, render=True, rasterized=True, background_color=None, grid=False, noticks=False, axes_labels=None, ax=None)[source]

Scatter plots of annotation.

Parameters:
  • adata – An AnnData including annotation in .obs and/or .obsm. Can also be a mapping of labels to AnnData to specify multiple datasets. The AnnData instances can be replaced also by DataFrame, which are then treated like the .obs of an AnnData.

  • keys – The .obs/.obsm annotation keys to compare. Can be a single string, or a list of strings, or a mapping of the labels of adata to strings or lists of strings. In the list or mapping variant, categorical .obs keys can be replaced by list-likes of numerical .obs keys or gene names can be used.

  • position_key – The .obsm key or array-like of .obs keys with the position space coordinates.

  • group_key – An .obs key with categorical group information to split adata prior to plotting. This works only if adata is a single AnnData instance.

  • colors – A mapping of annotation values to colors. If None, default colors are used.

  • show_only – A subset of annotation values to restrict the plotting to.

  • axsize – Tuple of width and height of a single axis. If one of them is None, it is determined from the aspect ratio of the data. If it is a single scalar value, then this is interpreted as a conversion factor from data units to axsize units and share_scaling is ignored.

  • padding – The absolute padding between the plots.

  • margin – The absolute margin between the outermost data points and the boundary of the plot

  • sharex – Whether to use common x axis for all axes.

  • sharey – Whether to use common y axis for all axes.

  • share_scaling – Whether to have the units in all plots be of the same size in pixels

  • n_cols – Number of “columns” to plot: If larger than 1 splits columns of plots into n_cols columns.

  • joint – Whether to plot only one scatter plot with all annotation categories or only the scatter plots with one annotation category per plot. If None, plot both.

  • method_labels – A mapping from the strings in keys and basis_keys to (shorter) names to show in the plot.

  • counts_location – A string or tuple specifying where the count matrix is stored, e.g. ‘X’, (‘raw’,’X’), (‘raw’,’obsm’,’my_counts_key’), (‘layer’,’my_counts_key’), … For details see counts().

  • compositional – Whether the annotation is to be interpreted as compositional data or as arbitrary numbers. Compositional data is normalized to sum to 1 per observation. Can also be ‘catsize’, which rescales the compositions by the average observed size of an annotation category in terms of the contents of .X, e.g. reads.

  • normalize – Whether to shift the data to non-negative values and normalize them by their maximum.

  • point_size – The size of the points in the plot. Like in matplotlib, this is a measure of point area and provided in units of “squared points” corresponding to (1/72)^2 inch^2 = (25.4/72)^2 mm^2.

  • cmap – A string/colormap to override the colors with. Makes sense mostly for numeric data.

  • cmap_vmin_vmax – A tuple giving the range of values for the colormap.

  • legend – Whether to plot a legend

  • on_data_legend – A mapping from annotation values to (shortened) versions of the labels to use for labels on the plot at the center of the annotation; annotations not occurring in the mapping are used as is; if None, no annotation is plotted on the data.

  • title – The title of the figure

  • render – Whether the scatterplot should be custom rendered using the dpi setting from matplotlib or plotted using a matplotlib’s scatterplot. If True, the different annotations from the same (and overlapping) positions are added up symmetrically, if False, they are plottet on top of each other using an alpha channel proportional to the weight. True also has the advantage that only the scatter part of the figure will be exported as pixelated version if the plot is exported as vectorgraphic, with the rest like labels and axes being exported as a vectorgraphic. This parameter provides control over the type of color averaging in the process of the rendering by specifying one of the modes available in mix_base_colors(), e.g. “xyv” or “rgb”, with “xyv” being equivalent to setting True.

  • rasterized – Whether to rasterize the interior of the plot, even when exported later as vectorgraphic. This leads to much smaller plots for many (data) points. rasterized==False is incompatible with render==True or string. This parameter provides experimental support for plotting pie charts per dot via ´rasterized==”pie”´ and ´render==False´. This is much slower, so only usable for very few points.

  • background_color – The background color to draw the points on.

  • grid – Whether to draw a grid

  • noticks – Whether to switch off ticks on the axes.

  • axes_labels – Labels to write on the axes as an list-like of the two labels.

  • ax – The 2d array of Axes instances to plot on. The array dimensions have to agree with the number of axes which would be created automatically if ax was not supplied. If it is a single instance it is treated as a 1x1 array.

Returns:

A Figure.