| Title: | Network Aware Stability Selection with Random Forests |
|---|---|
| Description: | An interpretable, network aware random forest feature selection framework for high dimensional and correlated data. It combines module stratified recursive feature elimination, shadow stability selection, and TreeSHAP (Tree SHapley Additive exPlanations) importance, with modules either provided by the user or derived with WGCNA (weighted gene co expression network analysis). The default backend requires a 'Python' environment with 'scikit-learn', 'shap', and 'numpy', which can be configured with mf_setup(). A pure 'R' backend based on 'ranger' is also available. |
| Authors: | Timothy Shen [aut, cre, cph], Christina Ramirez [aut] |
| Maintainer: | Timothy Shen <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-11-20 13:26:28 UTC |
| Source: | https://github.com/cran/mossyforest |
Returns TreeSHAP pairwise interaction strengths for all stable features.
Interaction values are computed during model fitting and stored in the
object, either by the Python backend
(TreeExplainer.shap_interaction_values()) or by the pure R backend
with r_shap = "treeshap". They are not available with
r_shap = "permutation" or when compute_interactions = FALSE.
detect_interaction(object, thresh = 0, all = FALSE, verbose = TRUE, ...)detect_interaction(object, thresh = 0, all = FALSE, verbose = TRUE, ...)
object |
A |
thresh |
Interaction strength threshold. Only pairs whose mean
|
all |
If |
verbose |
If |
... |
Ignored. |
The interaction matrix stored in
object$shap_obj$interaction_matrix is defined as:
where is the TreeSHAP interaction value for the pair
at observation (Lundberg et al., 2018). Diagonal
entries are main effects and off diagonal entries are pairwise interactions.
A data frame with columns FeatureA, FeatureB, and
Interaction_Strength (mean absolute TreeSHAP interaction), sorted
by interaction strength descending. Invisibly when all = TRUE.
Lundberg, S. M., Erion, G., Chen, H., DeGrave, A., Prutkin, J. M., Nair, B., Katz, R., Himmelfarb, J., Bansal, N., & Lee, S.-I. (2020). From local explanations to global understanding with explainable AI for trees. Nature Machine Intelligence, 2, 56-67.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) detect_interaction(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) detect_interaction(fit)
A list containing the top 500 most variable probe sets from the Acute Lymphoblastic Leukemia (ALL) microarray dataset (Chiaretti et al., 2004), along with the corresponding molecular subtype outcome.
data(leukemia)data(leukemia)
A list with two elements:
A numeric matrix with 79 rows (patients) and 500 columns
(Affymetrix HGU95Av2 probe sets, already log-scaled by the
original authors).
An integer vector of length 79: 1 (BCR/ABL subtype) or
0 (NEG, cytogenetically normal), derived from the
mol.biol column of the original ALL phenotype data.
Starting from the ALL Bioconductor package (128 patients, 12 625
probe sets), samples are restricted to the B lineage cases carrying one of
two balanced molecular subtypes which were the BCR/ABL (Philadelphia chromosome, Ph+)
fusion versus cytogenetically normal (NEG). This creates 79 patients (37
BCR/ABL, 42 NEG).Features were then ranked by across sample variance and the top 500
are retained. See data-raw/prep_leukemia.R for the exact preprocessing
steps.
y as a classification outcomey is stored as an integer vector, so mf() treats it as a
regression outcome. For classification, convert it to a factor first. The
first level is the class that SHAP values and directions refer to:
y <- factor(leukemia$y, levels = c(1, 0), labels = c("BCR/ABL", "NEG"))
The Bioconductor ALL package, which is distributed under the
Artistic-2.0 license. This dataset is a subset of its samples and
probe sets; the expression values are unchanged.
Chiaretti, S. et al. (2004). Gene expression profile of adult T cell acute lymphocytic leukemia identifies distinct subsets of patients with different response to therapy and survival. Blood, 103(7), 2771-2778. doi:10.1182/blood-2003-09-3243
Li, X. ALL: A data package. Bioconductor. doi:10.18129/B9.bioc.ALL
Runs the Mossy Forest algorithm.
mf( X, y, module_membership, screen_params = screen_control(), select_params = select_control(), final_ntree = 500L, nodesize = NULL, num_processors = 1L, max_modsize = 5000L, verbose = 1L, seed = as.integer(Sys.time()), compute_interactions = TRUE, backend = "python", r_shap = "permutation" )mf( X, y, module_membership, screen_params = screen_control(), select_params = select_control(), final_ntree = 500L, nodesize = NULL, num_processors = 1L, max_modsize = 5000L, verbose = 1L, seed = as.integer(Sys.time()), compute_interactions = TRUE, backend = "python", r_shap = "permutation" )
X |
A data frame where each column is a feature. |
y |
Response vector (numeric for regression, factor for classification). |
module_membership |
A named character vector assigning each feature in
|
screen_params |
Screening parameters. See
|
select_params |
Selection parameters. See
|
final_ntree |
Number of trees in the final random forest.
Default |
nodesize |
Minimum terminal node size. Defaults to |
num_processors |
Number of parallel threads for random forests.
Default |
max_modsize |
Maximum module size before blockwise pre reduction
is applied (Python backend only). Default |
verbose |
Verbose level. |
seed |
Integer random seed for reproducibility. Defaults to current system time. |
compute_interactions |
Logical. If |
backend |
Computation backend. |
r_shap |
Final SHAP / importance method used when
|
An object of class mossy_forest.
Chernozhukov, V., Chetverikov, D., Demirer, M., Duflo, E., Hansen, C., Newey, W., & Robins, J. (2018). Double/cross-fit residualed machine learning for treatment and structural parameters. The Econometrics Journal, 21(1), C1-C68.
Lundberg, S. M., & Lee, S. I. (2017). A unified model for interpreting predictions. NeurIPS, 30.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) print(fit) head(fit$final_SHAP) ## Not run: # The Python backend (exact TreeSHAP) needs a configured Python environment mf_setup(condaenv = "sfenv") fit_py <- mf(X, y, module_membership = membership, backend = "python") plot_importance(fit_py) ## End(Not run)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) print(fit) head(fit$final_SHAP) ## Not run: # The Python backend (exact TreeSHAP) needs a configured Python environment mf_setup(condaenv = "sfenv") fit_py <- mf(X, y, module_membership = membership, backend = "python") plot_importance(fit_py) ## End(Not run)
Tells Mossy Forest which Python installation to use for its backend.
Call this once at the start of each R session before using mf
with backend = "python". The pure R backend does not need it.
mf_setup(python = NULL, condaenv = NULL, virtualenv = NULL)mf_setup(python = NULL, condaenv = NULL, virtualenv = NULL)
python |
Path to a Python binary. Passed to
|
condaenv |
Name of a conda environment. Passed to
|
virtualenv |
Path to a virtual environment. Passed to
|
The Python environment must have scikit-learn, shap, and
numpy installed. Example setup:
conda create -n sfenv python=3.11 conda activate sfenv pip install scikit-learn shap numpy
Invisible NULL.
## Not run: mf_setup(condaenv = "sfenv") mf_setup(python = "/usr/local/bin/python3") ## End(Not run)## Not run: mf_setup(condaenv = "sfenv") mf_setup(python = "/usr/local/bin/python3") ## End(Not run)
Creates a cumulative SHAP decision plot adapted from the Python shap
package.
plot_decisions(object, ...) ## S3 method for class 'mossy_forest' plot_decisions( object, highlight = NULL, just_shap = FALSE, plot_title = "Decision Plot", geom_point = FALSE, gradient = c("blue", "red"), ... )plot_decisions(object, ...) ## S3 method for class 'mossy_forest' plot_decisions( object, highlight = NULL, just_shap = FALSE, plot_title = "Decision Plot", geom_point = FALSE, gradient = c("blue", "red"), ... )
object |
A |
... |
Ignored. |
highlight |
Row indices or feature names to highlight. |
just_shap |
If |
plot_title |
Plot title. Default |
geom_point |
Add a point at each feature step? Default |
gradient |
Length 2 color vector for the prediction gradient.
Default |
A ggplot2 object (invisibly).
plot_decisions(mossy_forest): Decision plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_decisions(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_decisions(fit)
Ranks stable features by their importance score and displays an elbow
(scree) plot, optionally colored by module membership. The score is mean
|SHAP| for the Python backend and for the pure R backend with
r_shap = "treeshap", and ranger permutation importance for
r_shap = "permutation".
plot_elbow(object, ...) ## S3 method for class 'mossy_forest' plot_elbow( object, main = NULL, xlab = NULL, ylab = NULL, colorName = NULL, color = TRUE, module_labels = NULL, ... )plot_elbow(object, ...) ## S3 method for class 'mossy_forest' plot_elbow( object, main = NULL, xlab = NULL, ylab = NULL, colorName = NULL, color = TRUE, module_labels = NULL, ... )
object |
A |
... |
Ignored. |
main |
Plot title. Default |
xlab |
X axis label. Default |
ylab |
Y axis label. Default |
colorName |
Legend title for module color. Default |
color |
Color points by module membership? Default |
module_labels |
Optional two column data frame of label mappings. Default |
A ggplot2 object (invisibly).
plot_elbow(mossy_forest): Elbow plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_elbow(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_elbow(fit)
Generates a SHAP force plot for one or more observations. Plots are built via shapviz.
plot_force(object, ...) ## S3 method for class 'mossy_forest' plot_force( object, row_id, row_name = NULL, max_display = NULL, fill_colors = c("#59c46b", "#3b528b"), contrast = TRUE, bar_label_size = 3.2, show_annotation = TRUE, ... )plot_force(object, ...) ## S3 method for class 'mossy_forest' plot_force( object, row_id, row_name = NULL, max_display = NULL, fill_colors = c("#59c46b", "#3b528b"), contrast = TRUE, bar_label_size = 3.2, show_annotation = TRUE, ... )
object |
A |
... |
Ignored. |
row_id |
Row index (or indices) for the observation(s) to plot. |
row_name |
Optional name(s) for the observation(s). |
max_display |
Maximum number of features to display. |
fill_colors |
Length 2 vector of colors. Default
|
contrast |
Apply text/arrow contrast? Default |
bar_label_size |
Label size on bars. Default |
show_annotation |
Annotate bars. Default |
A ggplot2 object (invisibly).
plot_force(mossy_forest): Force plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_force(fit, row_id = 1)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_force(fit, row_id = 1)
Generates a feature importance plot from a mossy_forest object.
Three plot types of bar, beeswarm, and both can be used. Plots are built
via shapviz.
plot_importance(object, ...) ## S3 method for class 'mossy_forest' plot_importance( object, kind = "beeswarm", color_bar_title = "Feature Value", max_display = NULL, fill = "#3e568a", sort_features = TRUE, show_numbers = TRUE, viridis_args = list(begin = 0.25, end = 0.75, option = "viridis"), ... )plot_importance(object, ...) ## S3 method for class 'mossy_forest' plot_importance( object, kind = "beeswarm", color_bar_title = "Feature Value", max_display = NULL, fill = "#3e568a", sort_features = TRUE, show_numbers = TRUE, viridis_args = list(begin = 0.25, end = 0.75, option = "viridis"), ... )
object |
A |
... |
Ignored. |
kind |
Plot type: |
color_bar_title |
Title for the color bar in the beeswarm plot.
Default |
max_display |
Maximum number of features to display. |
fill |
Bar/point color Any valid |
sort_features |
Sort features by importance? Default |
show_numbers |
Show numeric SHAP values on the bar plot?
Default |
viridis_args |
Named list of arguments forwarded to |
A ggplot2 object (invisibly).
plot_importance(mossy_forest): Importance plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_importance(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_importance(fit)
Shows the proportion of features per module that were selected as stable, colored by selection status.
plot_modules(object, ...) ## S3 method for class 'mossy_forest' plot_modules( object, main = NULL, xlab = NULL, ylab = NULL, module_labels = NULL, ... )plot_modules(object, ...) ## S3 method for class 'mossy_forest' plot_modules( object, main = NULL, xlab = NULL, ylab = NULL, module_labels = NULL, ... )
object |
A |
... |
Ignored. |
main |
Plot title. Default |
xlab |
X axis label. Default |
ylab |
Y axis label. Default |
module_labels |
Optional two column data frame mapping old module labels
to new display labels. Default |
A ggplot2 object (invisibly).
plot_modules(mossy_forest): Module membership plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_modules(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_modules(fit)
Generates a heatmap of pairwise SHAP based potential interaction strengths for all stable features.
plot_potential_interactions(object, ...) ## S3 method for class 'mossy_forest' plot_potential_interactions(object, ...)plot_potential_interactions(object, ...) ## S3 method for class 'mossy_forest' plot_potential_interactions(object, ...)
object |
A |
... |
Ignored. |
A ggplot2 object (invisibly).
plot_potential_interactions(mossy_forest): Interaction heatmap for a
mossy_forest object (uses exact TreeSHAP interaction values).
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_potential_interactions(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_potential_interactions(fit)
Bar chart of signed importance = direction mean|SHAP|.
Magnitude is mean|SHAP| and the sign is the global effect direction taken from
the Spearman correlation between each feature's value and its SHAP value
(mean(signed SHAP) because contributions cancel, so it
is unusable for direction). Bars to the right increase the average predicted outcome, and bars to the
left decrease it. These are associations in the fitted model, not causal
effects of changing a feature. Features whose direction is ambiguous (non monotone:
) are greyed.
For binary classification, "the outcome" means the probability of
levels(y)[1], the first level of the factor passed as y to
mf. Relevel y first if you want a different reference
class.
plot_signed_importance(object, ...) ## S3 method for class 'mossy_forest' plot_signed_importance( object, top_n = 20L, labels = NULL, pos_color = "#4393c3", neg_color = "#d6604d", amb_color = "#bbbbbb", pos_label = "increase", neg_label = "decrease", amb_label = "ambiguous", main = "Directional feature importance", ... )plot_signed_importance(object, ...) ## S3 method for class 'mossy_forest' plot_signed_importance( object, top_n = 20L, labels = NULL, pos_color = "#4393c3", neg_color = "#d6604d", amb_color = "#bbbbbb", pos_label = "increase", neg_label = "decrease", amb_label = "ambiguous", main = "Directional feature importance", ... )
object |
A |
... |
Ignored. |
top_n |
Show only the |
labels |
Optional named character vector mapping feature names (as in
|
pos_color |
Bar color for positive direction. Default |
neg_color |
Bar color for negative direction. Default |
amb_color |
Bar color for ambiguous features. Default |
pos_label |
Legend text for the positive direction group. Default
|
neg_label |
Legend text for the negative direction group. Default
|
amb_label |
Legend text for the ambiguous group. Default
|
main |
Plot title. Default |
A ggplot2 object (invisibly).
plot_signed_importance(mossy_forest): Signed importance plot for a
mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_signed_importance(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_signed_importance(fit)
Displays the subsample shadow stability selection frequency for each stable feature as a horizontal bar chart. Features are sorted by frequency.
plot_stability(object, ...) ## S3 method for class 'mossy_forest' plot_stability( object, fill = "#3e568a", main = "Shadow Stability Frequencies", ... )plot_stability(object, ...) ## S3 method for class 'mossy_forest' plot_stability( object, fill = "#3e568a", main = "Shadow Stability Frequencies", ... )
object |
A |
... |
Ignored. |
fill |
Bar color. Default |
main |
Plot title. Default |
A ggplot2 object (invisibly).
plot_stability(mossy_forest): Stability frequency plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_stability(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_stability(fit)
Displays the shadow subsample stability frequency curve for each selection pool with a horizontal threshold line and colored points indicating which features were selected.
plot_stability_elbow(object, ...) ## S3 method for class 'mossy_forest' plot_stability_elbow( object, col_selected = "#3e568a", col_unselected = "grey65", col_threshold = "tomato", col_elbow = "#e07b00", show_labels = FALSE, ncol = NULL, main = "Shadow stability selection", ... )plot_stability_elbow(object, ...) ## S3 method for class 'mossy_forest' plot_stability_elbow( object, col_selected = "#3e568a", col_unselected = "grey65", col_threshold = "tomato", col_elbow = "#e07b00", show_labels = FALSE, ncol = NULL, main = "Shadow stability selection", ... )
object |
A |
... |
Ignored. |
col_selected |
Point color for selected features.
Default |
col_unselected |
Point color for unselected features.
Default |
col_threshold |
Color of the horizontal threshold line.
Default |
col_elbow |
Color of the vertical elbow rank line.
Default |
show_labels |
Show feature names on points. Default |
ncol |
Number of columns in the facet grid. |
main |
Plot title. Default |
For shadow_mode = "split", there is one panel for the
correlated pool and one for the unassigned pool (elbow or fixed threshold).
For shadow_mode = "within_module" one panel is shown per module.
The dashed red line marks the stability threshold applied. For unassigned pools with elbow detection the elbow rank is marked with a vertical dotted line.
A ggplot2 object (invisibly).
plot_stability_elbow(mossy_forest): Stability elbow plot for a
mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_stability_elbow(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) plot_stability_elbow(fit)
Generates a SHAP waterfall plot for one or more observations. Plots are built via shapviz.
plot_waterfall(object, ...) ## S3 method for class 'mossy_forest' plot_waterfall( object, row_id, row_name = NULL, max_display = NULL, order_fun = function(s) order(abs(s)), fill_colors = c("#59c46b", "#3b528b"), contrast = TRUE, show_connection = TRUE, show_annotation = TRUE, ... )plot_waterfall(object, ...) ## S3 method for class 'mossy_forest' plot_waterfall( object, row_id, row_name = NULL, max_display = NULL, order_fun = function(s) order(abs(s)), fill_colors = c("#59c46b", "#3b528b"), contrast = TRUE, show_connection = TRUE, show_annotation = TRUE, ... )
object |
A |
... |
Ignored. |
row_id |
Row index (or indices) for the observation(s) to plot. When multiple indices are given, SHAP values are averaged. |
row_name |
Optional name(s) for the observation(s). |
max_display |
Maximum number of features to display. |
order_fun |
Function used to order features. Default orders by absolute SHAP value. |
fill_colors |
Length 2 vector of colors for positive/negative bars.
Default |
contrast |
Apply text/arrow contrast? Default |
show_connection |
Show connections between bars? Default |
show_annotation |
Annotate bars? Default |
A ggplot2 object (invisibly).
plot_waterfall(mossy_forest): Waterfall plot for a mossy_forest object.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_waterfall(fit, row_id = 1)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", r_shap = "treeshap", verbose = 0, seed = 1) plot_waterfall(fit, row_id = 1)
Generates predictions from the final random forest fitted on the stable feature set.
## S3 method for class 'mossy_forest' predict(object, new_data, ...)## S3 method for class 'mossy_forest' predict(object, new_data, ...)
object |
A |
new_data |
A matrix or data frame of new observations. Column names must match the training features. |
... |
Additional arguments passed to |
A ranger prediction object. Predictions always come from the
ranger forest refit on the stable features, whichever backend
selected them.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) predict(fit, X[1:5, ])$predictions# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) predict(fit, X[1:5, ])$predictions
Prints the stable feature set with final feature importance scores and shadow stability selection frequencies.
## S3 method for class 'mossy_forest' print(x, ...)## S3 method for class 'mossy_forest' print(x, ...)
x |
A |
... |
Ignored. |
Invisibly returns x.
# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) print(fit)# A small simulated regression problem with two modules of features set.seed(1) n <- 60 z <- rnorm(n) X <- data.frame(a1 = z + rnorm(n, sd = 0.3), a2 = z + rnorm(n, sd = 0.3), a3 = z + rnorm(n, sd = 0.3), b1 = rnorm(n), b2 = rnorm(n), b3 = rnorm(n)) y <- z + rnorm(n, sd = 0.3) membership <- c(a1 = "A", a2 = "A", a3 = "A", b1 = "B", b2 = "B", b3 = "B") # The pure R backend needs no Python installation fit <- mf(X, y, module_membership = membership, screen_params = screen_control(min_ntree = 50), select_params = select_control(n_reps = 10, min_ntree = 50), final_ntree = 50, backend = "R", verbose = 0, seed = 1) print(fit)
Creates a parameter object controlling the screening (recursive feature
elimination) step of mf.
screen_control( drop_fraction = 0.25, keep_fraction = 0.5, mtry_factor = 1, mtry_rule = "auto", min_ntree = 500L, ntree_factor = 1 )screen_control( drop_fraction = 0.25, keep_fraction = 0.5, mtry_factor = 1, mtry_rule = "auto", min_ntree = 500L, ntree_factor = 1 )
drop_fraction |
Fraction of features dropped at each RFE iteration.
Default |
keep_fraction |
Fraction of features retained per module after
screening. Default |
mtry_factor |
Multiplier applied to the |
mtry_rule |
How |
min_ntree |
Minimum number of trees per screening forest.
Default |
ntree_factor |
Trees per forest = |
An object of class screen_control.
screen_control() screen_control(drop_fraction = 0.1, keep_fraction = 0.3, min_ntree = 200)screen_control() screen_control(drop_fraction = 0.1, keep_fraction = 0.3, min_ntree = 200)
Creates a parameter object controlling the shadow stability selection step
of mf.
select_control( mtry_factor = 1, mtry_rule = "auto", mtry_on_real = FALSE, min_ntree = 500L, ntree_factor = 1, shadow_mode = "split", n_reps = 50L, pi_thr = 0.6, pi_thr_unassigned = NULL, threshold_mode = "pi_thr", shadow_percentile = 95, unassigned_modules = NULL, use_cfres = FALSE, cfres_n_folds = 5L, cfres_ntree = 300L, cfres_scope = "unassigned", early_stop = FALSE, early_stop_tol = 0.01, early_stop_check_every = 10L )select_control( mtry_factor = 1, mtry_rule = "auto", mtry_on_real = FALSE, min_ntree = 500L, ntree_factor = 1, shadow_mode = "split", n_reps = 50L, pi_thr = 0.6, pi_thr_unassigned = NULL, threshold_mode = "pi_thr", shadow_percentile = 95, unassigned_modules = NULL, use_cfres = FALSE, cfres_n_folds = 5L, cfres_ntree = 300L, cfres_scope = "unassigned", early_stop = FALSE, early_stop_tol = 0.01, early_stop_check_every = 10L )
mtry_factor |
|
mtry_rule |
How |
mtry_on_real |
Logical. If |
min_ntree |
Minimum trees per forest. Default |
ntree_factor |
Trees per forest scaling factor. Default |
shadow_mode |
Shadow stability pooling strategy. One of
|
n_reps |
Number of subsample replicates for shadow stability (each draws half the rows without replacement).
Default |
pi_thr |
Stability frequency threshold for correlated pool
features. A feature is selected if its shadow win
rate across replicates exceeds |
pi_thr_unassigned |
Stability threshold for the unassigned pool.
|
threshold_mode |
Selection cutoff rule. |
shadow_percentile |
Percentile of the shadow feature distribution used
as the importance threshold within each replicate.
Default |
unassigned_modules |
Character vector of module names treated as
the unassigned pool (e.g. |
use_cfres |
Logical. If |
cfres_n_folds |
Number of cross fitting folds for cfRes
residualization. Default |
cfres_ntree |
Trees per fold forest in cfRes residualization.
Default |
cfres_scope |
Scope of cfRes residualization. |
early_stop |
Logical. If |
early_stop_tol |
Convergence tolerance for |
early_stop_check_every |
Replicates per batch. Convergence is checked
between batches. Default |
An object of class select_control.
select_control() # cross fitted residualization of the outcome, with a stricter threshold select_control(n_reps = 20, pi_thr = 0.7, use_cfres = TRUE)select_control() # cross fitted residualization of the outcome, with a stricter threshold select_control(n_reps = 20, pi_thr = 0.7, use_cfres = TRUE)
A list containing World Bank development indicators and life expectancy for 181 countries in 2020.
data(wdi)data(wdi)
A list with three elements:
A numeric matrix with 181 rows (countries) and 501 columns of World Bank development indicators for 2020, filtered to those present for at least 80% of countries and with residual gaps median imputed. Row names are country short names.
A numeric vector of length 181 of life expectancy at birth
(total, in years). All life table derived series (life expectancy,
mortality, survival, and death counts) were removed from X.
A named character vector mapping each indicator code in
colnames(X) to its human readable World Bank indicator name.
World Bank datasets are published under the Creative Commons Attribution 4.0 International license (CC BY 4.0, https://datacatalog.worldbank.org/public-licenses). Credit: World Bank, World Development Indicators. Changes made: the data were subset, filtered and median imputed as described above. Some indicators are compiled by the World Bank from other agencies, so check the original source before redistributing them separately.
The World Development Indicators bulk database
(https://databank.worldbank.org/). See data-raw/prep_wdi.R
for the exact download and preprocessing steps.
World Bank. World Development Indicators. Washington, DC: The World Bank Group.
Creates a parameter object for the WGCNA co expression network step used
by wmf.
WGCNA_control(power = 6, min_features = 20, ...)WGCNA_control(power = 6, min_features = 20, ...)
power |
Soft thresholding power passed to
|
min_features |
Minimum module size, passed to
|
... |
Additional arguments forwarded to
|
An object of class WGCNA_control.
WGCNA_control() # extra arguments are passed on to WGCNA::blockwiseModules() WGCNA_control(power = 8, min_features = 30, deepSplit = 2)WGCNA_control() # extra arguments are passed on to WGCNA::blockwiseModules() WGCNA_control(power = 8, min_features = 30, deepSplit = 2)
Runs a Weighted Gene Co expression Network Analysis (WGCNA) to derive
module membership, then passes the result to mf.
wmf( X, y, WGCNA_params = WGCNA_control(power = 6), screen_params = screen_control(), select_params = select_control(), final_ntree = 500L, nodesize = NULL, num_processors = 1L, max_modsize = 5000L, verbose = 1L, seed = as.integer(Sys.time()), backend = "python", r_shap = "permutation", compute_interactions = TRUE )wmf( X, y, WGCNA_params = WGCNA_control(power = 6), screen_params = screen_control(), select_params = select_control(), final_ntree = 500L, nodesize = NULL, num_processors = 1L, max_modsize = 5000L, verbose = 1L, seed = as.integer(Sys.time()), backend = "python", r_shap = "permutation", compute_interactions = TRUE )
X |
A data frame where each column is a feature. |
y |
Response vector (numeric for regression, factor for classification). |
WGCNA_params |
WGCNA parameters. See |
screen_params |
Screening parameters. See
|
select_params |
Selection parameters. See
|
final_ntree |
Number of trees in the final random forest.
Default |
nodesize |
Minimum terminal node size. Defaults to |
num_processors |
Number of parallel threads for random forests.
Default |
max_modsize |
Maximum module size before blockwise pre reduction
is applied (Python backend only). Default |
verbose |
Verbose level. |
seed |
Integer random seed for reproducibility. Defaults to current system time. |
backend |
Computation backend. |
r_shap |
Final SHAP / importance method used when
|
compute_interactions |
Logical. If |
An object of class mossy_forest with an additional
$WGCNA_object slot containing the raw WGCNA output.
Zhang, B., & Horvath, S. (2005). A general framework for weighted gene co expression network analysis. Statistical Applications in Genetics and Molecular Biology, 4(1), Article 17.
# Two blocks of correlated features; WGCNA finds the modules set.seed(1) n <- 30 z1 <- rnorm(n); z2 <- rnorm(n) block <- function(k, zz) as.data.frame(replicate(k, zz + rnorm(n, sd = 0.4))) X <- cbind(block(10, z1), block(10, z2)) colnames(X) <- paste0("g", seq_len(ncol(X))) y <- z1 - z2 + rnorm(n, sd = 0.3) fit <- wmf(X, y, WGCNA_params = WGCNA_control(power = 6, min_features = 6), screen_params = screen_control(min_ntree = 30), select_params = select_control(n_reps = 3, min_ntree = 30), final_ntree = 30, backend = "R", verbose = 0, seed = 1) table(fit$WGCNA_object$colors)# Two blocks of correlated features; WGCNA finds the modules set.seed(1) n <- 30 z1 <- rnorm(n); z2 <- rnorm(n) block <- function(k, zz) as.data.frame(replicate(k, zz + rnorm(n, sd = 0.4))) X <- cbind(block(10, z1), block(10, z2)) colnames(X) <- paste0("g", seq_len(ncol(X))) y <- z1 - z2 + rnorm(n, sd = 0.3) fit <- wmf(X, y, WGCNA_params = WGCNA_control(power = 6, min_features = 6), screen_params = screen_control(min_ntree = 30), select_params = select_control(n_reps = 3, min_ntree = 30), final_ntree = 30, backend = "R", verbose = 0, seed = 1) table(fit$WGCNA_object$colors)