malariagen_data.ag3.Ag3.plot_frequencies_heatmap#
- Ag3.plot_frequencies_heatmap(df: DataFrame, index: str | List[str] | None = 'label', max_len: int | None = 100, col_width: int = 40, row_height: int = 20, x_label: str | None = 'Cohorts', y_label: str | None = 'Variants', colorbar: bool = True, width: int | None = None, height: int | None = None, text_auto: bool | str = '.0%', aspect: Literal['equal', 'auto'] | None = 'auto', color_continuous_scale: str | List[str] | None = 'Reds', title: str | bool | None = True, show: bool = True, renderer: str | None = None, **kwargs) Figure | None #
Plot a heatmap from a pandas DataFrame of frequencies, e.g., output from snp_allele_frequencies() or gene_cnv_frequencies().
Parameters#
- dfDataFrame
A DataFrame of frequencies, e.g., output from snp_allele_frequencies() or gene_cnv_frequencies().
- indexstr or list of str or None, optional, default: ‘label’
One or more column headers that are present in the input dataframe. This becomes the heatmap y-axis row labels. The column/s must produce a unique index.
- max_lenint or None, optional, default: 100
Displaying large styled dataframes may cause ipython notebooks to crash. If the input dataframe is larger than this value, an error will be raised.
- col_widthint, optional, default: 40
Plot width per column in pixels (px).
- row_heightint, optional, default: 20
Plot height per row in pixels (px).
- x_labelstr or None, optional, default: ‘Cohorts’
X axis label.
- y_labelstr or None, optional, default: ‘Variants’
Y axis label.
- colorbarbool, optional, default: True
If False, do not display a color bar.
- widthint or None, optional
Figure width in pixels (px).
- heightint or None, optional
Figure height in pixels (px).
- text_autobool or str, optional, default: ‘.0%’
If True or a string, single-channel img values will be displayed as text. A string like ‘.2f’ will be interpreted as a texttemplate numeric formatting directive.
- aspect{‘equal’, ‘auto’} or None, optional, default: ‘auto’
Aspect ratio, see also https://plotly.com/python-api- reference/generated/plotly.express.imshow.
- color_continuous_scalestr or list of str or None, optional, default: ‘Reds’
Colormap used to map scalar data to colors (for a 2D image). This parameter is not used for RGB or RGBA images. If a string is provided, it should be the name of a known color scale, and if a list is provided, it should be a list of CSS-compatible colors.
- titlestr or bool or None, optional, default: True
If True, attempt to use metadata from input dataset as a plot title. Otherwise, use supplied value as a title.
- showbool, optional, default: True
If true, show the plot. If False, do not show the plot, but return the figure.
- rendererstr or None, optional
The name of the renderer to use.
- **kwargs
Passed through to px.imshow().
Returns#
- Figure or None
A plotly figure (only returned if show=False).
Notes#
It’s recommended to filter the input DataFrame to just rows of interest, i.e., fewer rows than max_len.