dynamo.pl.bubble
- dynamo.pl.bubble(adata, genes, group, gene_order=None, group_order=None, layer=None, theme=None, cmap=None, color_key=None, color_key_cmap='Spectral', background='white', pointsize=None, vmin=0, vmax=100, sym_c=False, alpha=0.8, edgecolor=None, linewidth=0, type='violin', sort='diagnoal', transpose=False, rotate_xlabel='horizontal', rotate_ylabel='horizontal', figsize=None, save_show_or_return='show', save_kwargs={}, **kwargs)[source]
Bubble plots generalized to velocity, acceleration, curvature.
It supports either the dot or violin plot mode. This function is loosely based on https://github.com/QuKunLab/COVID-19/blob/master/step3_plot_umap_and_marker_gene_expression.ipynb
- Parameters:
adata (
AnnData
) – an AnnData object.genes (
List
[str
]) – the gene list, i.e. marker gene or top acceleration, curvature genes, etc.group (
str
) – the column key in adata.obs that will be used to group cells.gene_order (
Optional
[List
[str
]]) – the gene groups order that will show up in the resulting bubble plot. If None, the order of genes would be used. Defaults to None.group_order (
Optional
[List
[str
]]) – the cells groups order that will show up in the resulting bubble plot. If None, adata.obs[‘group’] would be used. Defaults to None.layer (
Optional
[str
]) – the layer of data to use for the bubble plot. Defaults to None.theme (
Optional
[Literal
['blue'
,'red'
,'green'
,'inferno'
,'fire'
,'viridis'
,'darkblue'
,'darkred'
,'darkgreen'
]]) –a color theme to use for plotting. A small set of predefined themes are provided which have relatively good aesthetics. Available themes are:
’blue’
’red’
’green’
’inferno’
’fire’
’viridis’
’darkblue’
’darkred’
’darkgreen’.
Defaults to None.
cmap (
Optional
[str
]) – the name of a matplotlib colormap to use for coloring or shading points. If no labels or values are passed this will be used for shading points according to density (largely only of relevance for very large datasets). If values are passed this will be used for shading according the value. Note that if theme is passed then this value will be overridden by the corresponding option of the theme. Defaults to None.color_key (
Union
[dict
,_SupportsArray
[dtype
],_NestedSequence
[_SupportsArray
[dtype
]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]],None
]) – a way to assign colors to categoricals. This can either be an explicit dict mapping labels to colors (as strings of form ‘#RRGGBB’), or an array like object providing one color for each distinct category being provided in labels. Either way this mapping will be used to color points according to the label. Note that if theme is passed then this value will be overridden by the corresponding option of the theme. Defaults to None.color_key_cmap (
Optional
[str
]) – the name of a matplotlib colormap to use for categorical coloring. If an explicit color_key is not given a color mapping for categories can be generated from the label list and selecting a matching list of colors from the given colormap. Note that if theme is passed then this value will be overridden by the corresponding option of the theme. Defaults to “Spectral”.background (
Optional
[str
]) – the color of the background. Usually this will be either ‘white’ or ‘black’, but any color name will work. Ideally one wants to match this appropriately to the colors being used for points etc. This is one of the things that themes handle for you. Note that if theme is passed then this value will be overridden by the corresponding option of the theme. Defaults to “white”.pointsize (
Optional
[float
]) – the scale of the point size. Actual point cell size is calculated as 500.0 / np.sqrt(adata.shape[0]) * pointsize. Defaults to None.vmin (
float
) – the percentage of minimal value to consider. Defaults to 0.vmax (
float
) – the percentage of maximal value to consider. Defaults to 100.sym_c (
bool
) – whether do you want to make the limits of continuous color to be symmetric, normally this should be used for plotting velocity, jacobian, curl, divergence or other types of data with both positive or negative values. Defaults to False.alpha (
float
) – alpha value of the plot. Defaults to 0.8.edgecolor (
Optional
[str
]) – the color of the edge of the dots when type is to be dot. Defaults to None.linewidth (
float
) – the width of the edge of the dots when type is to be dot. Defaults to 0.type (
Literal
['violin'
,'dot'
]) – the type of the bubble plot, one of “violin” or “dot”. Defaults to “violin”.sort (
str
) – the method for sorting genes. Not implemented. Defaults to “diagnoal”.transpose (
bool
) – whether to transpose the row/column of the resulting bubble plot. Gene and cell types are on x/y-axis by default. Defaults to False.rotate_xlabel (
Union
[float
,Literal
['vertical'
,'horizontal'
]]) – the angel to rotate the x-label or “horizontal” or “vertical”. Defaults to “horizontal”.rotate_ylabel (
Union
[float
,Literal
['vertical'
,'horizontal'
]]) – the angel to rotate the y-label or “horizontal” or “vertical”.. Defaults to “horizontal”.figsize (
Optional
[Tuple
[float
,float
]]) – the size of the figure. Defaults to None.save_show_or_return (
Literal
['save'
,'show'
,'return'
]) – whether to save, show or return the figure. Can be one of “save”, “show”, or “return”. Defaults to “show”.save_kwargs (
Dict
[str
,Any
]) – a dictionary that will be passed to the save_show_ret function. By default, it is an empty dictionary and the save_show_ret function will use the {“path”: None, “prefix”: ‘scatter’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs.. Defaults to {}.
- Raises:
ValueError – group is not a column name of adata.obs
ValueError – gene name in genes is not found in adata.vars.
ValueError – group_order is not a subset of adata.obs[group].
ValueError – gene_order is not a subset of adata.var_names.intersection(set(genes)).to_list().
- Return type:
- Returns:
None would be returned by default. If save_show_or_return is set to be return, the matplotlib figure and axes would be returned.