SeqMut.suggest
- SeqMut.suggest(df_seq, df_feat, n=10, region=None, to_aa=None, weight=None, jmd_n_len=10, jmd_c_len=10, constraints=None)[source]
Suggest the top mutations that move a sequence toward the desired CPP / model outcome.
Without a bound
model, mutations are ranked byshift_score=Sum sign(mean_dif) * ΔX(optionally weighted by adf_featcolumn), i.e. how strongly they move features in the direction by which the test class differs from the reference class. With a boundmodelthe ranking switches to the model prediction-shiftdelta_pred(the ML-guided objective), so the suggested mutations are those predicted to raise the target-class score most. This is the single-objective design primitive; combining several mutations into one variant isSeqMut.combine().- Parameters:
df_seq (pd.DataFrame, shape (n_samples, n_seq_info)) – DataFrame containing an
entrycolumn with unique protein identifiers, in the position-based format (sequence,tmd_start,tmd_stop). SeeSequenceFeature.get_df_parts()for the fulldf_seqformat specification.df_feat (pd.DataFrame) – CPP feature set (output of
CPP.run()); its signedmean_difdefines the target direction.n (int, default=10) – Number of top mutations to return.
region (str or list of int, optional) – Restrict the scan (see
SeqMut.scan()).to_aa (list of str, optional) – Substitution alphabet (see
SeqMut.scan()).weight (str, optional) – Optionally weight the shift score by a
df_featcolumn ('feat_importance'or'abs_auc'). IfNone, all features contribute equally. Ignored when amodelis bound (the ranking then usesdelta_pred).jmd_n_len (int, default=10) – Length of JMD-N in number of amino acids.
jmd_c_len (int, default=10) – Length of JMD-C in number of amino acids.
constraints (DesignConstraints, optional) –
Shared design limits (see
DesignConstraints). Itsmutable_positionsandpermitted_substitutionsare the object form ofregionandto_aa, and itsimmutable_positions/forbidden_substitutionsadditionally drop the excluded(pos, to_aa)mutations from the scan. Limits that need a multi-mutation candidate (n_mut_max, the identity bounds, the motifs) apply toSeqMut.combine()andSeqOpt.run(), not to a single-substitution scan. Passingregionorto_aaand aconstraintsobject that sets the same limit differently raises.None(default) applies no limit.Added in version 1.2.0.
- Returns:
df_suggest – The top-
nmutations sorted by descendingshift_score— or by descendingdelta_predwhen amodelis bound (the table then also carries the model prediction-shift columns).- Return type:
pd.DataFrame, shape (n, 8)
- Raises:
ValueError – If
df_seqis not in the position-based format, ifdf_featdoes not match the bound model, ifn/weight/region/to_aa/constraintsare invalid or conflict, or if no scannable mutation is left.
Examples
:meth:
SeqMut.suggestreturns the top mutations that move a sequence toward the test-class CPP profile, ranked byshift_score(sum sign(mean_dif) * ΔX).import aaanalysis as aa aa.options["verbose"] = False df_seq = aa.load_dataset(name="DOM_GSEC", n=10) labels = df_seq["label"].to_list() sf = aa.SequenceFeature() df_parts = sf.get_df_parts(df_seq=df_seq) split_kws = sf.get_split_kws() cpp = aa.CPP(df_parts=df_parts, split_kws=split_kws, verbose=False) df_feat = cpp.run(labels=labels, n_filter=25) seqm = aa.SeqMut() aa.display_df(seqm.suggest(df_seq=df_seq, df_feat=df_feat, n=10, region="tmd"), n_rows=10, show_shape=True)
DataFrame shape: (10, 8)
entry pos from_aa to_aa mutation region delta_cpp shift_score 1 Q8IUW5 74 G A G74A tmd 3.415670 3.415670 2 P05556 744 G A G744A tmd 3.415670 3.415670 3 Q14802 52 G A G52A tmd 3.415660 3.415660 4 P53801 112 G A G112A tmd 3.415660 3.415660 5 Q8IUW5 74 G E G74E tmd 2.904170 2.904170 6 P05556 744 G E G744E tmd 2.904170 2.904170 7 Q14802 52 G E G52E tmd 2.904160 2.904160 8 P53801 112 G E G112E tmd 2.904160 2.904160 9 Q8IUW5 78 C A C78A tmd 2.859590 2.859590 10 P01135 118 C A C118A tmd 2.859580 2.859580 to_aarestricts the substitution alphabet,weightscales the shift score by adf_featcolumn ('abs_auc'or'feat_importance') so more discriminative features count more, andjmd_n_len/jmd_c_lenset the JMD lengths of the split geometry.# Weighted suggestion over a restricted alphabet on the default 10/10 split geometry df_suggest = seqm.suggest(df_seq=df_seq, df_feat=df_feat, n=10, region="tmd", to_aa=["A", "L", "V", "P"], weight="abs_auc", jmd_n_len=10, jmd_c_len=10) aa.display_df(df_suggest, n_rows=10, show_shape=True)
DataFrame shape: (10, 8)
entry pos from_aa to_aa mutation region delta_cpp shift_score 1 Q8IUW5 74 G A G74A tmd 3.415670 1.557450 2 P05556 744 G A G744A tmd 3.415670 1.557450 3 P53801 112 G A G112A tmd 3.415660 1.557446 4 Q14802 52 G A G52A tmd 3.415660 1.557446 5 Q8IUW5 78 C A C78A tmd 2.859590 1.300775 6 P01135 118 C A C118A tmd 2.859580 1.300771 7 Q969W9 60 C A C60A tmd 2.859580 1.300771 8 P53801 116 C A C116A tmd 2.859580 1.300771 9 P53801 112 G L G112L tmd 2.801250 1.278101 10 P05556 744 G L G744L tmd 2.801250 1.278101 Design constraints.
constraintstakes a sharedDesignConstraintsobject that replaces theregion/to_aashorthands and additionally excludes immutable positions and forbidden target residues from the ranking:tmd_start = int(df_seq["tmd_start"].iloc[0]) dc = aa.DesignConstraints(mutable_positions="tmd", permitted_substitutions=["A", "L", "V", "P"], immutable_positions=[tmd_start], forbidden_substitutions=["P"]) df_suggest_dc = seqm.suggest(df_seq=df_seq, df_feat=df_feat, n=10, constraints=dc) aa.display_df(df_suggest_dc, n_rows=10, show_shape=True)
DataFrame shape: (10, 8)
entry pos from_aa to_aa mutation region delta_cpp shift_score 1 P05556 744 G A G744A tmd 3.415670 3.415670 2 Q8IUW5 74 G A G74A tmd 3.415670 3.415670 3 Q14802 52 G A G52A tmd 3.415660 3.415660 4 P53801 112 G A G112A tmd 3.415660 3.415660 5 Q8IUW5 78 C A C78A tmd 2.859590 2.859590 6 P53801 116 C A C116A tmd 2.859580 2.859580 7 P01135 118 C A C118A tmd 2.859580 2.859580 8 Q969W9 60 C A C60A tmd 2.859580 2.859580 9 P05556 744 G L G744L tmd 2.801250 2.801250 10 Q14802 52 G L G52L tmd 2.801250 2.801250