
Add interactions to a trajectory model
add_interactions.RdThis function adds significant interactions to a given trajectory model if they do not already exist. It identifies significant interactions based on the provided threshold and updates the model features with logistic features derived from these interactions. The trajectory model is then re-learned with the new features.
Usage
add_interactions(
traj_model,
interaction_threshold = 0.001,
max_motif_n = NULL,
max_add_n = NULL,
max_n = NULL,
lambda = 1e-05,
alpha = 1,
seed = 60427,
interactions = NULL,
ignore_feats = c("TT", "CT", "GT", "AT", "TC", "CC", "GC", "AC", "TG", "CG", "GG",
"AG", "TA", "CA", "GA", "AA"),
force = FALSE,
logist_interactions = FALSE,
use_cv = FALSE,
nfolds = 10,
family = "binomial",
rescale_pred = FALSE,
only_sig_motifs = FALSE,
only_sig_add_motifs = TRUE,
interaction_scale_factor = 1,
min_signal_correlation = NULL
)Arguments
- traj_model
The trajectory model object.
- interaction_threshold
threshold for the selecting features to create interactions. IQ learns a linear model on the features and selects the features with coefficients above this threshold. Default: 0.001
- max_motif_n
maximum number of motifs to consider for interactions. If NULL, all motifs above the interaction_threshold will be considered. Default: NULL
- max_add_n
maximum number of additional features to consider for interactions. If NULL, all additional features above the interaction_threshold will be considered. Default: NULL
- max_n
maximum number of interactions to consider. If NULL, all interactions will be considered. If set, the interactions will be selected based on correlation with the signal in the training data. Default: (motif models + additional features) * 10
- lambda
The lambda value to use for relearning. If NULL, the lambda value from the trajectory model is used.
- alpha
The elastic net mixing parameter for glmnet. alpha=1 is the lasso penalty, alpha=0 is the ridge penalty. Default: 1
- seed
random seed for reproducibility.
- interactions
A precomputed interaction matrix. If provided, the function will not compute the interactions. Default: NULL
- ignore_feats
A character vector of features to ignore when creating interactions. Default: dinucleotides
- force
If TRUE, the function will add interactions even if they already exist. Default: FALSE
- logist_interactions
Logical indicating whether to transform interactions to logistic functions. Default: FALSE
- use_cv
Logical indicating whether to use cross-validation for lambda selection. Default is FALSE.
- nfolds
Number of folds for cross-validation. Default is 10.
- family
The family to use for the glmnet model. Either "binomial" (default) or "gaussian" for linear regression.
- rescale_pred
Logical indicating whether to rescale the predicted values. Default is TRUE.
- only_sig_motifs
Logical indicating whether to only consider significant motifs for interactions. Default: FALSE
- interaction_scale_factor
A multiplier applied to the normalized interaction matrix before it is joined into the model features. Default: 1 (no scaling). Values >1 make interactions more prominent relative to motif features; values <1 down-weight them.
- min_signal_correlation
If non-NULL, after the
max_ncorrelation-based top-N cap, drop any interaction column whose absolute correlation with the trainingdiff_scoreis belowmin_signal_correlation * max(|cor|). For example,min_signal_correlation = 1/8keeps only interactions whose |cor| exceeds 1/8 of the best interaction's |cor|, mirroring Akhiad's manual post-hoc filter. Default: NULL (no filter).