PyComplexHeatmap.dotHeatmap module

class PyComplexHeatmap.dotHeatmap.DotClustermapPlotter(data=None, x=None, y=None, value=None, hue=None, s=None, c=None, marker='o', alpha=1, color_legend_kws={}, cmap_legend_kws={}, dot_legend_kws={}, dot_legend_marker='o', aggfunc=<function mean>, value_na=0, hue_na='NA', s_na=0, c_na=0, x_order=None, y_order=None, spines=False, grid='minor', max_s=None, **kwargs)[source]

Bases: ClusterMapPlotter

DotClustermap (Heatmap) plotter, inherited from ClusterMapPlotter. Plot dot heatmap (clustermap) with annotation and legends.

Parameters:
  • data (dataframe) – pandas dataframe or numpy array.

  • x (str) – The column name in data.columns to be shown on the columns of heatmap / clustermap.

  • y (str) – The column name in data.columns to be shown on the rows of heatmap / clustermap.

  • value (str) – The column name in data.columns to control the sizes, or color of scatter (dot).

  • hue (str, optional.) – The column name in data.columns to control the color, cmap, markers of scatter (dot).

  • s (str or int, optional.) – The column name in data.columns to control the size of scatter (dot). If s is None, value will be used to control the sizes of dot. This parameter will overwrite value.

  • c (str, optional.) – The column name in data.columns to control the color of scatter (dot). c can also be one color str, such as ‘red’. If c is not given, colors of the dot will be determined by cmap or colors.

  • marker (str or dict, optional.) – Please go to: https://matplotlib.org/stable/api/markers_api.html to see all available markers. Such as ‘.’,’,’,’o’,’v’,’^’,’<’,’>’,’1’,’2’,’3’,’4’,’8’,’s’,’p’,’P’,’*’,’h’,’H’,’+’,’x’,’X’,’D’,’d’,’|’,’_’, default marker is ‘o’. If marker is a string, it should be a marker to control the markers of scatter (dot). marker could also be a name of the column from data.columns.tolist() If marker is a dict, the keys should be the values from data[hue].values, and values should be marker.

  • colors (dict.) – Keys should be the values from data[hue].values, and values should be color. It will be only used to control the colors of markers in figure legend.

  • cmap (str or dict, optional.) – If cmap is a dict, the keys should be the values from data[hue].values, and values should be cmap. If cmap is a string, it should be colormap, such as ‘Set1’.

  • color_legend_kws (dict) – legend_kws passed to plot_color_dict_legend

  • cmap_legend_kws (dict) – legend_kws passed to plot_cmap_legend

  • dot_legend_kws (dict) – legend_kws passed to plot_marker_legend

  • value_na (float or int) – used to fill na for data.pivot_table(index=self.y,columns=self.x,values=self.value,aggfunc=self.aggfunc).fillna(self.value_na)

  • hue_na – float, str or int used to fill na for data.pivot_table(index=self.y,columns=self.x,values=self.hue,aggfunc=self.aggfunc).fillna(self.hue_na)

  • s_na – floator int used to fill na for data.pivot_table(index=self.y,columns=self.x,values=self.s,aggfunc=self.aggfunc).fillna(self.s_na)

  • c_na (float, int or str) – used to fill na for data.pivot_table(index=self.y,columns=self.x,values=self.c,aggfunc=self.aggfunc).fillna(self.c_na)

  • x[y]_order (list) – use together with row[col]_cluster=False, to force order the dot heatmap as given by x[y]_order.

  • aggfunc (function) – when there are multiple values for the same x and y, using aggfunc (default is np.mean) to aggregate them. aggfunc will be called in data.pivot(index=y,columns=x,values=value,aggfunc=aggfunc)

  • spines (bool) – Whether show spines of the axes or not [False]

  • grid (None or str) – major, minor or None.

  • max_s (float) – max size of the dot in scatter, default is None, will be inferred automatically.

  • alpha (float [0,1]) – coefficient to scale the size of dot in figure legend, valid for marker and dot in legend.

  • kwargs (dict) – Other kwargs passed to ClusterMapPlotter and dotHeatmap2d, such as max_s, vmin, vmax.

Return type:

DotClustermapPlotter.

collect_legends()[source]
format_data(data, mask=None, z_score=None, standard_scale=None)[source]
plot_matrix(row_order, col_order)[source]
post_processing()[source]
PyComplexHeatmap.dotHeatmap.dotHeatmap2d(data, hue=None, vmin=None, vmax=None, ax=None, colors=None, cmap=None, max_s=None, spines=False, c_na='black', **kwargs)[source]

Plot dot heatmap using a dataframe matrix as input.

Parameters:
  • data (pd.DataFrame) – input matrix (pandas.DataFrame)

  • hue (pd.DataFrame) – hue to control the colors and cmap of the dot.

  • vmin (float) – minimal size for the dot.

  • vmax (float) – maximal size for the dot

  • ax (ax) – ax

  • colors (dict) – colors to control the dot, keys should be the value in hue. if colors is a str, then colors will overwrite the parameter c.

  • cmap (str of dict) – control the colormap of the dot, if cmap is a dict, keys should be the values from hue dataframe. If cmap is a str (such as ‘Set1’), the parameter colors will overwrite the colors of dots. If cmap was a dict, then this paramter will overwrite the colors, and colors can only control the colors for markers.

  • s (int, float, or dataframe) – control the sizes of dot.

  • c (dataframe, or str) – control the colors of dots.

  • marker (str, dataframe or dict) – when marker is a dict, hue must not be None, and keys are categorical values from hue, values should be marker.

  • kwargs (dict) – such as s,c,marker, s,marker and colors can also be pandas.DataFrame. other kwargs passed to plt.scatter

Return type:

axes

PyComplexHeatmap.dotHeatmap.scale(values, vmin=None, vmax=None)[source]