AAPredPlot

class AAPredPlot[source]

Bases: object

Plotting class for AAPred evaluation and prediction results [Breimann25].

The single home for prediction figures, dispatched by kind from three methods:

  • predict_sample() visualizes single-protein positional predictions: the per-residue profile (kind='window') and the domain boundary-sensitivity curve (kind='domain').

  • predict_group() visualizes across-samples predictions: score histograms (kind='hist'), ranked candidates (kind='ranking'), per-protein rank scatters (kind='rank_scatter'), two-predictor scatters (kind='scatter'), and survival curves (kind='cutoff').

  • group_cluster() clusters the sample group by explanation similarity: the hierarchically clustered sample x sample correlation heatmap (kind='clustermap').

  • eval() visualizes model/feature-set evaluation: metric bars per model (kind='eval') and grouped benchmark comparisons (kind='comparison').

Warning

Experimental. This class is part of the new v1.1.0 prediction layer and is under active development; its API (signatures, defaults, return objects) may change between minor releases without the usual deprecation cycle. Pin a version if you depend on the current behaviour.

Added in version 1.1.0.

See also

  • AAPred: the logic class whose results this visualizes.

Methods

eval(df_eval, *[, kind, ax, figsize, ...])

Visualize model / feature-set evaluation, dispatched by kind.

group_cluster(X, *[, kind, labels, ...])

Cluster the sample group by how its members relate, dispatched by kind.

predict_group(data, *[, kind, ax, figsize, ...])

Visualize across-samples prediction scores, dispatched by kind.

predict_sample([data, kind, ax, figsize, ...])

Visualize single-protein positional predictions as a multi-track sequence viewer.

__init__()[source]

Notes

The figures are built on Matplotlib and seaborn. A small set of shared modification functions recurs across the predict_group plots (only the main ones are listed):

See also

Examples

The AAPredPlot class visualizes AAPred results. We first build the feature matrix and an evaluation table:

The big picture — three methods, by what you look at. AAPredPlot visualizes AAPred results:

  • ``predict_sample`` — a local view of one protein: a multi-track sequence viewer (prediction profile + CPP importance + subcategory profiles + your annotation tracks + the sequence). Kinds: window, domain.

  • ``predict_group`` — a global view across many proteins: the distribution and ranking of per-protein scores. Kinds: hist, ranking, scatter, cutoff, clustermap.

  • ``eval`` — model / feature-set evaluation: metric bars per model, or grouped benchmark comparisons. Kinds: eval, comparison.

local vs. global (predict_sample vs. predict_group) mirrors per-sample SHAP vs. dataset-wide importance.

import aaanalysis as aa
aa.options["verbose"] = False  # Disable verbosity

# DOM_GSEC example dataset + its feature set (see [Breimann25]_)
df_seq = aa.load_dataset(name="DOM_GSEC")
labels = df_seq["label"].to_list()
df_feat = aa.load_features(name="DOM_GSEC").head(20)

# Build the CPP feature matrix
sf = aa.SequenceFeature()
df_parts = sf.get_df_parts(df_seq=df_seq)
X = sf.feature_matrix(features=df_feat["feature"], df_parts=df_parts)

aap = aa.AAPred(random_state=42)
df_eval = aap.eval(X, labels)

The evaluation table is shown as a grouped bar plot:

import matplotlib.pyplot as plt
aa.plot_settings()
aap_plot = aa.AAPredPlot()
aap_plot.eval(df_eval, baseline=0.5)
plt.tight_layout()
plt.show()
../_images/aap_plot_1_output_4_0.png