plot_graph_feature_heatmap
Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- plot_graph_feature_heatmap(table: pd.DataFrame, *, subjects: Sequence[str] | None = None, features: Sequence[str] | None = None, n_features: int = 40, feature_group: Literal['single', 'pair', 'all'] = 'single', select: Literal['variance', 'sample'] = 'variance', sample_seed: int = 0, zscore: bool = True, reference: 'pd.DataFrame' | None = None, star_significant: bool = False, star_alpha: float = 0.05, star_test: Literal['ttest_rel'] = 'ttest_rel', star_mtc: Literal['fdr_bh', 'bonferroni', 'none'] = 'fdr_bh', cbar_label: str | None = None, subject_col: str = 'subject_id', title: str | None = None, ax: Any | None = None) Figure[source]
Draw a subject x graph-feature heatmap (not habitat x texture).
Columns in a graph table mix incompatible units (counts, ratios, path lengths).
zscore=True(default) standardizes each selected feature across the selected subjects so a row is a relative profile, not a raw magnitude. Raw mixed units are not comparable; passzscore=Falseonly when every drawn column already shares one scale. Signedzscore=Falsevalues use a zero-centered diverging map.For a lattice comparison (for example 5-voxel minus 8-voxel), pass the 5-voxel frame as
tableand the 8-voxel frame asreference. The function aligns subjects and shared feature columns, plotstable - reference, and (whenzscore=True) column-z-scores that raw difference. Do not pass a precomputed (or already z-scored) delta astabletogether withreference— that would subtract twice.star_significant=Truemarks features (x-tick labels), not cells. Each plotted column gets a paired t-test (scipy.stats.ttest_relof the two source tables; equivalent to a one-sample t of the raw difference against 0). Columns with fewer than 3 finite pairs or a constant difference are skipped. Multiple testing defaults to Benjamini-Hochberg FDR across the plotted features (scipy.stats.false_discovery_control, then statsmodels, then Bonferroni). Significant names get a trailing ASCII asterisk. Starring requiresreference; a lone precomputed delta cannot reconstruct the pairing. Defaultstar_significant=Falseso generic heatmaps stay unmarked.Visualization parameters (who / which features / how many) are first-class: pass
subjectsand either an explicitfeatureslist orn_features+feature_group+select. The default cap is 40 columns so the full ~400-feature bank is never dumped onto one figure.This is a different figure from
plot_habitat_feature_heatmap()(habitats x radiomics features).- Parameters:
table – Wide frame, one row per subject. Identifier column defaults to
subject_id. Domain FeatureTable frames usesubject— passsubject_col='subject'. Whenreferenceis set this is the minuend (e.g. 5-voxel).subjects – Subject ids to show, in y-axis order.
Nonekeeps every row. Missing ids raiseHABITAPIError.features – Exact column list. When set, it overrides
n_features,select, andfeature_group.n_features – Column cap when
featuresis omitted (default 40).feature_group –
'single'(single_h*),'pair'(pair_h*), or'all'(those plusgraph_num_*).graph_num_*is excluded fromsingle/pair.select – When
featuresis omitted, take the top-k columns by cross-subject variance ('variance') or a reproducible random subset ('sample', seeded bysample_seed). Withreference, variance is of the raw difference.sample_seed – RNG seed for
select='sample'.zscore – Column-wise z-score across the selected subjects (default
True). Requires at least two subjects.Falsedraws the (possibly subtracted) values as-is.reference – Optional paired frame (e.g. 8-voxel). When set, the plotted matrix is aligned
table - reference. Required whenstar_significant=True.star_significant – If True, append an ASCII asterisk to x-tick labels of features that stay significant after
star_mtc. Default False; ignored pairing is never inferred from a precomputed delta alone.star_alpha – Significance threshold after correction (default 0.05).
star_test – Paired test. Only
'ttest_rel'is supported.star_mtc – Multiple-testing method over plotted features:
'fdr_bh'(default),'bonferroni', or'none'.cbar_label – Optional colorbar label.
Noneuses a default from the scale (Z-scored differencewhenreferenceandzscoreare both set).subject_col – Identifier column name (default
'subject_id').title – Optional English figure title.
Nonebuilds one from the group and whether values are z-scored.ax – Optional existing axes.
Nonecreates a new figure.
- Returns:
The matplotlib
Figure. The caller decides whether to save it.- Raises:
HABITAPIError – Missing subjects / columns, empty selection, invalid knobs,
star_significant=Truewithoutreference, orzscore=Truewith fewer than two rows.OptionalDependencyError – When matplotlib is not installed.