dynamo.pl.space

dynamo.pl.space(adata, color=None, genes=[], gene_cmaps=None, space_key='spatial', width=6, marker='.', pointsize=None, dpi=100, ps_sample_num=1000, alpha=0.8, stack_genes=False, stack_genes_threshold=0.01, stack_colors_legend_size=10, figsize=None, *args, **kwargs)[source]

Scatter plot for physical coordinates of each cell.

Parameters:
  • adata (AnnData) – an Annodata object that contain the physical coordinates for each bin/cell, etc.

  • color (Union[List[str], str, None]) – any or any list of column names or gene names, etc. that will be used for coloring cells. If color is not None, stack_genes will be disabled automatically because color can contain non numerical values. Defaults to None.

  • genes (Optional[List[str]]) – the gene list that will be used to plot the gene expression on the same scatter plot. Each gene will have a different color. Can be a single gene name string and we will convert it to a list. Defaults to [].

  • gene_cmaps (Optional[List[str]]) – a list of cmaps for mapping each gene’s values according to a type of cmap when stacking gene colors on the same subplot. The order of each gene’s cmap corresponds to the order in genes. Defaults to None.

  • space_key (str) – the key to space coordinates. Defaults to “spatial”.

  • width (float) – the width of the figure. Would be used when figsize is not specified. Defaults to 6.

  • marker (str) – a string representing some marker from matplotlib https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers. Defaults to “.”.

  • pointsize (Optional[float]) – the size of the points on the scatter plot. Defaults to None.

  • dpi (int) – the resolution of the figure in dots-per-inch. Dots per inches (dpi) determines how many pixels the figure comprises. dpi is different from ppi or points per inches. Note that most elements like lines, markers, texts have a size given in points so you can convert the points to inches. Matplotlib figures use Points per inch (ppi) of 72. A line with thickness 1 point will be 1./72. inch wide. A text with fontsize 12 points will be 12./72. inch heigh. Of course if you change the figure size in inches, points will not change, so a larger figure in inches still has the same size of the elements.Changing the figure size is thus like taking a piece of paper of a different size. Doing so, would of course not change the width of the line drawn with the same pen. On the other hand, changing the dpi scales those elements. At 72 dpi, a line of 1 point size is one pixel strong. At 144 dpi, this line is 2 pixels strong. A larger dpi will therefore act like a magnifying glass. All elements are scaled by the magnifying power of the lens. see more details at answer 2 by @ImportanceOfBeingErnest: https://stackoverflow.com/questions/47633546/relationship-between-dpi-and-figure-size. Defaults to 100.

  • ps_sample_num (int) – the number of bins / cells that will be sampled to estimate the distance between different bin / cells. Defaults to 1000.

  • alpha (float) – the point’s alpha (transparency) value. Defaults to 0.8.

  • stack_genes (bool) – whether to stack all genes on the same ax passed above. Defaults to False.

  • stack_genes_threshold (float) – a threshold for filtering out points values < threshold when drawing each gene. Defaults to 0.01.

  • stack_colors_legend_size (int) – the legend size in stack gene plot. Defaults to 10.

  • figsize (Optional[Tuple[float, float]]) – the size of each subplot. Defaults to None.

Return type:

Union[Axes, List[Axes]]

Returns:

The matplotlib axes of the generated subplots.