commot.pl.plot_cell_communication
- commot.pl.plot_cell_communication(adata, database_name=None, pathway_name=None, lr_pair=None, keys=None, plot_method='cell', background='summary', background_legend=False, clustering=None, summary='sender', cmap='coolwarm', cluster_cmap=None, pos_idx=array([0, 1]), ndsize=1, scale=1.0, normalize_v=False, normalize_v_quantile=0.95, arrow_color='#333333', grid_density=1.0, grid_knn=None, grid_scale=1.0, grid_thresh=1.0, grid_width=0.005, stream_density=1.0, stream_linewidth=1, stream_cutoff_perc=5, filename=None, ax=None)
Plot spatial directions of cell-cell communication.
The cell-cell communication should have been computed by the function
commot.tl.spatial_communication(). The cell-cell communication direction should have been computed by the functioncommot.tl.communication_direction().- Parameters
adata (
AnnData) – The data matrix of shapen_obs×n_var. Rows correspond to cells or positions and columns to genes.database_name (
Optional[str]) – Name of the ligand-receptor interaction database.pathway_name (
Optional[str]) – Name of the signaling pathway to be plotted. Will be used only whenlr_pairandkeysare None. If none ofpathway_name,lr_pair, andkeysare given, the total signaling through all pairs will be plotted.lr_pair – A tuple of ligand name and receptor name. If given,
pathway_namewill be ignored. Will be ignored ifkeysis given.keys – A list of keys for example ‘ligA-recA’ for a LR pair or ‘pathwayX’ for a signaling pathway ‘pathwayX’. If given, pathway_name and lr_pair will be ignored. If more than one is given, the average will be plotted.
plot_method (
str) – ‘cell’ plot vectors on individual cells. ‘grid’ plot interpolated vectors on regular grids. ‘stream’ streamline plot.background (
str) – ‘summary’: scatter plot with color representing total sent or received signal. ‘image’: the image in Visium data. ‘cluster’: scatter plot with color representing cell clusters.background_legend (
bool) – Whether to include the background legend when background is set to summary or cluster.clustering (
Optional[str]) – The key for clustering result. Needed if background is set to cluster. For example, ifclustering=='leiden', the clustering result should be available in.obs['leiden'].summary (
str) – If background is set to ‘summary’, the numerical value to plot for background. ‘sender’: node color represents sender weight. ‘receiver’: node color represents receiver weight.cmap (
str) – matplotlib colormap name for node summary if numerical (background set to ‘summary’), e.g., ‘coolwarm’. plotly colormap name for node color if summary is (background set to ‘cluster’). e.g., ‘Alphabet’.cluster_cmap (
Optional[dict]) – A dictionary that maps cluster names to colors when setting background to ‘cluster’. If given,cmapwill be ignored.pos_idx (
ndarray) – The coordinates to use for plotting (2D plot).ndsize (
float) – The node size of the spots.scale (
float) – The scale parameter passed to the matplotlib quiver functionmatplotlib.pyplot.quiver()for vector field plots. The smaller the value, the longer the arrows.normalize_v (
bool) – Whether the normalize the vector field to uniform lengths to highlight the directions without showing magnitudes.normalize_v_quantile (
float) – The vector length quantile to use to normalize the vector field.arrow_color (
str) – The color of the arrows.grid_density (
float) – The density of grid ifplot_method=='grid'.grid_knn (
Optional[int]) – Ifplot_method=='grid', the number of nearest neighbors to interpolate the signaling directions from spots to grid points.grid_scale (
float) – The scale parameter (relative to grid size) for the kernel function of mapping directions of spots to grid points.grid_thresh (
float) – The threshold of interpolation weights determining whether to include a grid point. A smaller value gives a tighter cover of the tissue by the grid points.grid_width (
float) – The value passed to thewidthparameter of the functionmatplotlib.pyplot.quiver()whenplot_method=='grid'.stream_density (
float) – The density of stream lines passed to thedensityparameter of the functionmatplotlib.pyplot.streamplot()whenplot_method=='stream'.stream_linewidth (
float) – The width of stream lines passed to thelinewidthparameter of the functionmatplotlib.pyplot.streamplot()whenplot_method=='stream'.stream_cutoff_perc (
float) – The quantile cutoff to ignore the weak vectors. Default to 5 that the vectors shorter than the 5% quantile will not be plotted.filename (
Optional[str]) – If given, save to the filename. For example ‘ccc_direction.pdf’.ax (
Optional[Axes]) – An existing matplotlib ax (matplotlib.axis.Axis).
- Returns
ax – The matplotlib ax object of the plot.
- Return type
matplotlib.axis.Axis