pegasus.heatmap
- pegasus.heatmap(data, attrs, groupby=None, matkey=None, gene_zscore=True, on_average=True, switch_axes=False, attrs_cluster=False, attrs_dendrogram=True, attrs_method='ward', attrs_optimal_ordering=True, xlabel_size=10.0, ylabel_size=10.0, legend_fontsize=10.0, xlabel_rotation=90.0, ylabel_rotation=0.0, groupby_cluster=True, groupby_dendrogram=True, groupby_method='ward', groupby_optimal_ordering=True, groupby_precomputed_linkage=None, show_sample_name=None, cbar_labelsize=10.0, panel_size=(10, 10), return_fig=False, dpi=300.0, **kwargs)[source]
Generate a heatmap.
- Parameters
data (
AnnData
orMultimodalData
orUnimodalData
object) – Single-cell expression data.attrs (
str
orList[str]
) – Cell attributes or features to plot. Cell attributes must exist indata.obs
and must be numeric. Features must exist indata.var
. By default, attrs are plotted as columns.groupby (
str
, optional, default:None
) – A categorical variable in data.obs that is used to categorize the cells, e.g. Clusters. By default, data.obs[‘groupby’] is plotted as rows. IfNone
, use data.obs_names instead.matkey (
str
, optional, default:None
) – If matkey is set, select matrix with matkey as keyword in the current modality. Only works for MultimodalData or UnimodalData objects.gene_zscore (
bool
, optional, default:True
) – IfTrue
, compute and then plot z scores for gene expression.on_average (
bool
, optional, default:True
) – IfTrue
, plot cluster average gene expression or z score (i.e. show a Matrixplot); otherwise, plot a general heatmap.switch_axes (
bool
, optional, default:False
) – By default, X axis is for attributes, and Y axis for clusters. If this parameter isTrue
, switch the axes. Moreover, withon_average
beingFalse
, ifswitch_axes
isFalse
,row_cluster
is enforced to beFalse
; ifswitch_axes
isTrue
,col_cluster
is enforced to beFalse
.attrs_cluster (
bool
, optional, default:False
) – Cluster attributes and generate a attribute-wise dendrogram.attrs_dendrogram (
bool
, optional, default:True
) – Only matters if attrs_cluster is True. Show the dendrogram if this option is True.attrs_method (
str
, optional, default:ward
) – Linkage method for attrs, choosing fromsingle
,complete
,average
,weighted
,centroid
,median
andward
.attrs_optimal_ordering (
bool
, optional, default:True
) – Parameter for scipy.cluster.hierarchy.linkage. IfTrue
, the attrs linkage matrix will be reordered so that the distance between successive leaves is minima.xlabel_size (
float
, optional, default: 10.0) – Fontsize for x-axis labels.ylabel_size (
float
, optional, default: 10.0) – Fontsize for y-axis labels.legend_fontsize (
float
, optional, default: 10.0) – Fontsize for legend labels.xlabel_rotation (
float
, optional, default: 90.0) – Rotation of x-axis labels.ylabel_rotation (
float
, optional, default: 0.0) – Rotation of y-axis labels.groupby_cluster (
bool
, optional, default:True
) – Cluster data.obs[‘groupby’] and generate a cluster-wise dendrogram.groupby_dendrogram (
bool
, optional, default:True
) – Only matters if groupby_cluster is True. Show the dendrogram if this option is True.groupby_method (
str
, optional, default:ward
) – Linkage method for groupby, choosing fromsingle
,complete
,average
,weighted
,centroid
,median
andward
.groupby_optimal_ordering (
bool
, optional, default:True
) – Parameter for scipy.cluster.hierarchy.linkage. IfTrue
, the groupby linkage matrix will be reordered so that the distance between successive leaves is minima.groupby_precomputed_linkage (
np.array
, optional, default:None
) – Pass a precomputed linkage.show_sample_name (
bool
, optional, default:None
) – If show sample names as tick labels. IfNone
, show_sample_name ==True
if groupby ==None
and otherwise show_sample_name ==False
.cbar_labelsize (
float
, optional, default: 10.0) – Fontsize of the color bar.panel_size (
Tuple[float, float]
, optional, default:(10, 10)
) – Overall size of the heatmap in(width, height)
form.return_fig (
bool
, optional, default:False
) – Return aFigure
object ifTrue
; returnNone
otherwise.dpi (
float
, optional, default:300.0
) – The resolution in dots per inch.kwargs – Are passed to
seaborn.heatmap
.documentation (.. _colormap) –
- Return type
Optional
[Figure
]- Returns
Figure
object – Amatplotlib.figure.Figure
object containing the heatmap ifreturn_fig == True
; Otherwise, Aseaborn.matrix.ClusterGrid
object is returned.
Examples
>>> pg.heatmap(data, attrs=['CD14', 'TRAC', 'CD34'], groupby='leiden_labels')