Classes for visualizing expression data (genometools.expression.visualize
)¶
ExpHeatmap |
An expression heatmap. |
SampleCorrelationHeatmap |
A sample correlation heatmap. |
Expression heatmaps (ExpHeatmap
)¶
-
class
genometools.expression.visualize.
ExpHeatmap
(matrix, gene_annotations=None, sample_annotations=None, colorscale=None, colorbar_label=u'Expression', title=None)[source]¶ An expression heatmap.
An expression heatmap visualizes a gene expression matrix, which is a two-dimensional numerical array with rows corresponding to genes, and columns corresponding to samples.
Parameters: - matrix (
ExpMatrix
) – Seematrix
attribute. - gene_annotations (list of
HeatmapGeneAnnotation
, or None, optional) – A list of gene annotations. [None] - sample_annotations (list of
HeatmapSampleAnnotation
, or None, optional) – A list of sample annotations. [None] - colorscale (list or None, optional) – A plotly colorscale (see
read_colorscale()
). If None, load the default red-blue colorscale that is included in this package. [None] - colorbar_label (str or None, optional) – The colorbar label. If None, “Expression” will be used. [None]
- title (str or None, optional) – The figure title. If None, the figure will have no title.
Notes
This class provides an intermediate layer between the underlying expression data, which is represented by an
ExpMatrix
object, and the visualization itself, which corresponds to a plotly figure. Its purpose is to store specific additional data such as the figure title, colorbar label, and (visual) annotations, but no data that only concerns the layout or visual appearance of the figure (e.g., its dimensions, margins, font choices, or the expression values corresponding to the lower and upper end of the colorscale. This information is provided by the user when he/she calls theget_figure()
function, and is not stored anywhere beside the plotly figure object itself.Gene and sample annotations are represented by
HeatmapGeneAnnotation
andHeatmapSampleAnnotations
objects, which can be used to highlight individual rows and columns in the heatmap, respectively.-
get_figure
(emin=None, emax=None, width=800, height=400, margin_left=100, margin_bottom=60, margin_top=30, margin_right=0, colorbar_size=0.4, xaxis_label=None, yaxis_label=None, xaxis_nticks=None, yaxis_nticks=None, xtick_angle=30, font=u'"Droid Serif", "Open Serif", serif', font_size=12, title_font_size=None, show_sample_labels=True, **kwargs)[source]¶ Generate a plotly figure of the heatmap.
Parameters: - emin (int, float, or None, optional) – The expression value corresponding to the lower end of the colorscale. If None, determine, automatically. [None]
- emax (int, float, or None, optional) – The expression value corresponding to the upper end of the colorscale. If None, determine automatically. [None]
- margin_left (int, optional) – The size of the left margin (in px). [100]
- margin_right (int, optional) – The size of the right margin (in px). [0]
- margin_top (int, optional) – The size of the top margin (in px). [30]
- margin_bottom (int, optional) – The size of the bottom margin (in px). [60]
- colorbar_size (int or float, optional) – The sze of the colorbar, relative to the figure size. [0.4]
- xaxis_label (str or None, optional) – X-axis label. If None, use
ExpMatrix
default. [None] - yaxis_label (str or None, optional) – y-axis label. If None, use
ExpMatrix
default. [None] - xtick_angle (int or float, optional) – X-axis tick angle (in degrees). [30]
- font (str, optional) – Name of font to use. Can be multiple, separated by comma, to specify a prioritized list. [‘ “Droid Serif”, “Open Serif”, “serif”’]
- font_size (int or float, optional) – Font size to use throughout the figure, in points. [12]
- title_font_size (int or float or None, optional) – Font size to use for labels on axes and the colorbar. If None,
use
font_size
value. [None] - show_sample_labels (bool, optional) – Whether to show the sample labels. [True]
Returns: The plotly figure.
Return type: plotly.graph_objs.Figure
- matrix (
Heatmap annotations¶
-
class
genometools.expression.visualize.
HeatmapGeneAnnotation
(gene, color, **kwargs)[source]¶ An
ExpHeatmap
gene (row) annotation.-
gene
¶ (property) The gene to be annotated.
-
-
class
genometools.expression.visualize.
HeatmapSampleAnnotation
(sample, color, **kwargs)[source]¶ An
ExpHeatmap
sample (column) annotation.-
sample
¶ (property) The sample to be annotated.
-
Sample correlation heatmaps (SampleCorrelationHeatmap
)¶
-
class
genometools.expression.visualize.
SampleCorrelationHeatmap
(corr_matrix, sample_annotations=None, block_annotations=None, colorscale=None, colorbar_label=None)[source]¶ A sample correlation heatmap.
Correlation heatmap annotations¶
-
class
genometools.expression.visualize.
HeatmapBlockAnnotation
(start_index, end_index, **kwargs)[source]¶ A
SampleCorrelationHeatmap
block annotation.