| Title: | Adversarial Random Forests for Omics Synthesis |
|---|---|
| Description: | We extend Adversarial Random Forests to a high-dimensional framework. The method partitions the feature space into regions where the assumption of feature independence within tree leaves is more likely to hold. Region-specific adversarial random forest models are trained to capture local dependence structures, while an additional adversarial random forest is fitted to a meta-space representation to model dependencies between regions. New observations are generated by first sampling from the meta-space model and then conditionally sampling from each region-specific model. The proposed methodology is described in Fouodo et al. (2026) <doi:10.64898/2026.09.09.750490>. |
| Authors: | Cesaire J. K. Fouodo [aut, cre], Jan Kapar [aut], Marvin N. Wright [aut] |
| Maintainer: | Cesaire J. K. Fouodo <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-09-28 16:09:16 UTC |
| Source: | https://github.com/cran/harf |
ELBOW DETECTION
elbow_detection(scores)elbow_detection(scores)
scores |
vector |
PCA built on fast.rsvd
fast.pca(X, K = 50)fast.pca(X, K = 50)
X |
matrix |
K |
number of principal components |
projection of X on principal top principal components
RANDOM PROJECTION SVD
fast.rsvd(A, K)fast.rsvd(A, K)
A |
matrix |
K |
rank |
list with components U S and V
This function extends the adversarial random forest (ARF) algorithm to high-dimensional settings. It partitions high-dimensional data into isolated regions and fits ARF models within each region and on a latent space representing region joint distribution to capture within and between region feature dependencies.
h_arf( omx_data, cli_lab_data = NULL, target = NULL, feature_ordering = NULL, omx_onset_data = NULL, num_trees = 10, min_node_size = 5, correlation_method = "spearman", correlation_mat = NULL, num_btwn_pcs = 2, num_onset_pcs = 2, chunk_size = 10, oob = FALSE, family = "truncnorm", finite_bounds = "no", alpha = 0, epsilon = 0, parallel = FALSE, export_cor_mat = FALSE, verbose = FALSE )h_arf( omx_data, cli_lab_data = NULL, target = NULL, feature_ordering = NULL, omx_onset_data = NULL, num_trees = 10, min_node_size = 5, correlation_method = "spearman", correlation_mat = NULL, num_btwn_pcs = 2, num_onset_pcs = 2, chunk_size = 10, oob = FALSE, family = "truncnorm", finite_bounds = "no", alpha = 0, epsilon = 0, parallel = FALSE, export_cor_mat = FALSE, verbose = FALSE )
omx_data |
A data.frame containing omics data where rows represent samples (e.g. patients or cells) and columns represent features (e.g., gene or protein expressions). |
cli_lab_data |
A data.frame of clinical or laboratory data. For example, this may be a data.frame where rows represent cell types (for single cell data or additional clinical patient information, e.g. disease status, age, sex, BMI, etc). |
target |
Optional name of the target variable in |
feature_ordering |
Optional vector of feature names specifying the order of features in the synthesized data. If NULL, features are ordered according to their original order in |
omx_onset_data |
Optional data.frame of conditional onset omics features. This can be used to condition the synthesis on specific omics features (e.g. expression of a gene of interest). If provided, dimension reduction will be performed on these features and the resulting components will be included as additional meta features for training the meta adversarial model. |
num_trees |
Number of trees to grow in each Adversarial Random Forest (ARF) model. |
min_node_size |
Minimum number of samples required to split an internal node in the ARF model. |
correlation_method |
Methods to compute correlation between features. Options include "pearson", "spearman", and "kendall". Default is "spearman". |
correlation_mat |
Optional pre-computed correlation matrix between features. If provided, this will be used instead of computing correlations from |
num_btwn_pcs |
Number of principal components to use for between cluster variability. Default is 2. |
num_onset_pcs |
Number of principal components to use for onset features. Default is 2. |
chunk_size |
Size of feature chunks to process at a time. Default is 10. |
oob |
Logical indicating whether to use out-of-bag samples for density estimation. Default is FALSE. Also see |
family |
Distribution to use for density estimation of continuous features. See |
finite_bounds |
Impose finite bounds on all continuous variables? If "local", infinite bounds are set to empirical extrema within leaves. If "global", infinite bounds are set to global empirical extrema. if "no" (the default), infinite bounds are left unchanged. See |
alpha |
Optional pseudocount for Laplace smoothing in density estimation. See |
epsilon |
Optional slack parameter on empirical bounds. See |
parallel |
Logical indicating whether to use parallel processing. Default is TRUE. |
export_cor_mat |
Logical indicating whether to export the correlation matrix used for clustering. Default is FALSE. |
verbose |
Logical indicating whether to print progress messages. Default is FALSE. |
An isoARF object containing the fitted adversarial models, and clustering information.
Watson et al. (2023). Adversarial Random Forests. Proceedings of the International Conference on Machine Learning (PMLR 206). https://proceedings.mlr.press/v206/watson23a.html
Fouodo et al. (2026). Adversarial random forests for omics synthesis. bioRxiv preprint doi:10.64898/2026.09.09.750490
h_forge, arf::adversarial_rf, arf::forde
data(single_cell) harf_model <- h_arf( omx_data = single_cell[ , - which(colnames(single_cell) == "cell_type")], cli_lab_data = data.frame(cell_type = single_cell$cell_type) ) # Unconditional sampling from harf_model set.seed(123) synth_single_cell <- h_forge( harf_obj = harf_model, n_synth = nrow(single_cell) ) # Conditional resampling from harf_model set.seed(142) lung_single_cell <- h_forge( harf_obj = harf_model, n_synth = sum(single_cell$cell_type == "lung"), evidence = data.frame(cell_type = "lung") )data(single_cell) harf_model <- h_arf( omx_data = single_cell[ , - which(colnames(single_cell) == "cell_type")], cli_lab_data = data.frame(cell_type = single_cell$cell_type) ) # Unconditional sampling from harf_model set.seed(123) synth_single_cell <- h_forge( harf_obj = harf_model, n_synth = nrow(single_cell) ) # Conditional resampling from harf_model set.seed(142) lung_single_cell <- h_forge( harf_obj = harf_model, n_synth = sum(single_cell$cell_type == "lung"), evidence = data.frame(cell_type = "lung") )
This function uses a high-dimensional ARF model to generate synthetic data.
h_forge( harf_obj, n_synth, evidence = NULL, omx_onset_data = NULL, evidence_row_mode = c("separate", "or"), round = TRUE, sample_NAs = FALSE, nomatch = c("force", "na"), verbose = TRUE, stepsize = 0, parallel = FALSE )h_forge( harf_obj, n_synth, evidence = NULL, omx_onset_data = NULL, evidence_row_mode = c("separate", "or"), round = TRUE, sample_NAs = FALSE, nomatch = c("force", "na"), verbose = TRUE, stepsize = 0, parallel = FALSE )
harf_obj |
A pre-trained harf model. |
n_synth |
Number of synthetic samples to generate. |
evidence |
Optional set of conditioning events. This will be further passed
to the |
omx_onset_data |
Optional data.frame of conditional onset omics features. |
evidence_row_mode |
Interpretation of rows in multi-row evidence.
See |
round |
Round continuous variables to their respective maximum precision
in the real data set? See |
sample_NAs |
Sample NAs respecting the probability for missing values in
the original data? See |
nomatch |
What to do if no leaf matches a condition in evidence? Options are to force sampling from a random leaf ("force") or return NA ("na"). The default is "force". |
verbose |
What to do if no leaf matches a condition in |
stepsize |
How many rows of evidence should be handled at each step?
See |
parallel |
Compute in parallel? See |
A data.table containing the generated synthetic omics data.
Césaire Fouodo
Watson et al. (2023). Adversarial Random Forests. Proceedings of the International Conference on Machine Learning (PMLR 206). https://proceedings.mlr.press/v206/watson23a.html
Fouodo et al. (2026). Adversarial random forests for omics synthesis. bioRxiv preprint doi:10.64898/2026.09.09.750490
forge for details on the forging process.
data(single_cell) harf_model <- h_arf( omx_data = single_cell[ , - which(colnames(single_cell) == "cell_type")], cli_lab_data = data.frame(cell_type = single_cell$cell_type) ) # Unconditional sampling from harf_model set.seed(123) synth_single_cell <- h_forge( harf_obj = harf_model, n_synth = nrow(single_cell) ) # Conditional resampling from harf_model set.seed(142) lung_single_cell <- h_forge( harf_obj = harf_model, n_synth = sum(single_cell$cell_type == "lung"), evidence = data.frame(cell_type = "lung") )data(single_cell) harf_model <- h_arf( omx_data = single_cell[ , - which(colnames(single_cell) == "cell_type")], cli_lab_data = data.frame(cell_type = single_cell$cell_type) ) # Unconditional sampling from harf_model set.seed(123) synth_single_cell <- h_forge( harf_obj = harf_model, n_synth = nrow(single_cell) ) # Conditional resampling from harf_model set.seed(142) lung_single_cell <- h_forge( harf_obj = harf_model, n_synth = sum(single_cell$cell_type == "lung"), evidence = data.frame(cell_type = "lung") )
A small example of the TCGA-KICH dataset used to demonstrate functions in the harf package.
kichkich
A data frame.
Data derived from The Cancer Genome Atlas Kidney Chromophobe Collection (TCGA-KICH).
A small example of single cell dataset used to demonstrate and test
functions in the harf package.
data(single_cell)data(single_cell)
An object of class data.frame with 1652 rows and 81 columns.
Data derived from the RNAseqDB repository maintained by Memorial Sloan Kettering Cancer Center (https://github.com/mskcc/RNAseqDB).