dotools_py.pl.heatmap#
- dotools_py.pl.heatmap(adata, group_by, features, groups_order=None, layer=None, logcounts=True, figsize=(5, 6), ax=None, swap_axes=True, title=None, title_fontproperties=None, palette='Reds', ticks_fontproperties=None, xticks_rotation=None, yticks_rotation=None, cluster_x_axis=False, cluster_y_axis=False, legend_title='LogMean(nUMI)\\nin group', path=None, filename='Heatmap.svg', show=True, add_stats=False, test='wilcoxon', correction_method='benjamini-hochberg', df_pvals=None, stats_x_size=None, square_x_size=None, pval_cutoff=0.05, log2fc_cutoff=0.0, z_score=None, clustering_method='complete', clustering_metric='euclidean', linewidth=0.1, vmin=0.0, vcenter=None, vmax=None, square=True, **kargs)[source]#
Heatmap of the mean expression of genes across a groups.
Generate a heatmap of showing the average nUMI for a set of genes in different groups. Differential gene expression analysis between the different groups can be performed.
- Parameters:
- adata
AnnData Annotated data matrix.
- group_by
str|list Name of a categorical column in
adata.obsto groupby.- features
str|list cA valid feature in
adata.var_namesor column inadata.obswith continuous values.- groups_order
list(default:None) Order for the categories in
adata.obs[group_by].- z_score
Literal['var','group'] (default:None) Apply z-score transformation.
- path
str|PathLike[str] |Path(default:None) Path to the folder to save the figure.
- filename
str(default:'Heatmap.svg') Name of file to use when saving the figure.
- layer
str(default:None) Name of the AnnData object layer that wants to be plotted. By default,
adata.Xis plotted. If layer is set to a valid layer name, then the layer is plotted.- swap_axes
bool(default:True) Whether to swap the axes or not.
- palette
str(default:'Reds') String denoting matplotlib colormap.
- title
str(default:None) Title for the figure.
- title_fontproperties
Dict[Literal['size','weight'],str|int] (default:None) Dictionary which should contain ‘size’ and ‘weight’ to define the fontsize and fontweight of the title of the figure.
- clustering_method
str(default:'complete') Linkage method to use for calculating clusters. See scipy.cluster.hierarchy.linkage.
- clustering_metric
str(default:'euclidean') Distance metric to use for the data. See scipy.spatial.distance.pdist.
- cluster_x_axis
bool(default:False) Hierarchically clustering the x-axis.
- cluster_y_axis
bool(default:False) Hierarchically clustering the y-axis.
- ax
Axes|None(default:None) Matplotlib axes to use for plotting. If not set, a new figure will be generated.
- figsize
tuple(default:(5, 6)) Figure size, the format is (width, height).
- linewidth
float(default:0.1) Linewidth for the border of cells.
- ticks_fontproperties
Dict[Literal['size','weight'],str|int] (default:None) Dictionary which should contain ‘size’ and ‘weight’ to define the fontsize and fontweight of the font of the x/y-axis.
- xticks_rotation
int(default:None) Rotation of the x-ticks.
- yticks_rotation
int(default:None) Rotations of the y-ticks.
- vmin
float(default:0.0) The value representing the lower limit of the color scale.
- vcenter
float(default:None) The value representing the center of the color scale.
- vmax
float(default:None) The value representing the upper limit of the color scale.
- legend_title
str(default:'LogMean(nUMI)\\nin group') Title for the colorbar.
- add_stats
bool(default:False) Add statistical annotation. Will add a square with an ‘*’ in the center if the expression is significantly different in a group with respect to the others.
- df_pvals
DataFrame(default:None) Dataframe with the pvals. Should be
gene x grouporgroup x genein case of swap_axes isFalse.- stats_x_size
float(default:None) Scaling factor to control the size of the asterisk.
- square_x_size
dict(default:None) Size and thickness of the square.
- test
Literal['wilcoxon','t-test'] (default:'wilcoxon') Name of the method to test for significance.
- correction_method
Literal['benjamini-hochberg','bonferroni'] (default:'benjamini-hochberg') Correction method for multiple testing.
- pval_cutoff
float(default:0.05) Cutoff for the p-value.
- log2fc_cutoff
float(default:0.0) Minimum cutoff for the log2FC.
- square
bool(default:True) Whether to make the cell square or not.
- show
bool(default:True) If set to
False, returns a dictionary with the matplotlib axes.- logcounts
bool(default:True) whether the input is logcounts or not.
- kargs
Additional arguments pass to sns.heatmap.
- adata
- Return type:
- Returns:
Depending on
show, returns the plot if set toTrueor a dictionary with the axes.
Example
import dotools_py as do adata = do.dt.example_10x_processed() do.pl.heatmap(adata, 'annotation', ['CD4', 'CD79A'], add_stats=True)