PerturbClaw: Differential Attribution Aggregation Under Structural Uncertainty
1. Motivation
A recurring problem across many domains is measuring the relative importance of one feature within a large group, and then determining whether that localized feature influences its environment macroscopically. The question is not merely which features are important in aggregate, but whether a small component of a complex system — when perturbed — produces changes that propagate outward in meaningful ways. This kind of reasoning sits at the intersection of local attribution and global causal inference, and it is rarely addressed well by standard feature-importance pipelines.
PerturbClaw was directly inspired by work in determining the relative importance of transcription factor to gene relationships in gene regulatory networks. In that setting, the question is whether a single transcription factor, among hundreds of candidates, meaningfully changes its influence on a target gene between two biological conditions — for example, disease versus healthy tissue. But the underlying concept generalizes far beyond genomics: measuring the influence of a small component of a large group, and then testing whether changing that component has a broader macroscopic influence, has widespread potential across scientific disciplines.
Inspired by work from Dibaeinia et al. (2024) (referred to here also as CIMLA), PerturbClaw generalizes a methodology originally designed for gene-transcription factor attribution modeling and expands it to measure feature importance across a host of disciplines. Given data from two conditions (e.g. disease vs. control, treated vs. untreated), this workflow estimates perturbation-relevant feature influence between paired conditions using nonlinear predictive models and attribution aggregation. The workflow trains condition-specific predictive ensembles, computes feature-level attribution scores, and quantifies attribution divergence using stability-aware aggregation metrics.
Under the assumptions described in Dibaeinia et al. (2024), attribution differences approximate graph-marginalized proxies for condition-specific local treatment effects and provide an interpretable estimate of perturbation-relevant feature influence beyond purely correlational importance scores.
Concrete domains where this question arises include:
- Genomics: regulatory influence may differ between disease and control conditions; identifying which transcription factors changed their influence on target genes is a core unsolved problem
- Neuroscience: stimulus conditions may alter which features of neural activity are most relevant to a behavioral outcome
- Climate modeling: relationships between atmospheric variables and regional outcomes shift across eras, and identifying which variables changed their predictive role is essential for attribution
- Materials science: processing conditions change which material properties most strongly predict performance outcomes
Static feature-importance pipelines are often insufficient for all of these settings. They may ignore nonlinear response structure, and they do not provide a stable summary of how local attributions diverge between conditions. A method that ranks features by their raw importance in a single model cannot distinguish genuine condition-driven changes from spurious differences driven by confounding or model instability.
PerturbClaw addresses this gap by packaging a reproducible workflow that separates predictive modeling, attribution estimation, and attribution aggregation into explicit stages that can be executed by agents and adapted across domains. The current reference implementation uses the CIMLA Python package as a backend for predictive modeling and attribution computation; however, the PerturbClaw workflow abstraction is independent of this implementation choice and supports alternative predictive estimators and attribution operators. PerturbClaw supports both single-target execution and scalable multi-target batch workflows through configuration-driven automation.
2. Method
Attribution grounding
The causal grounding used in PerturbClaw draws on the theoretical framework developed by Dibaeinia, Ojha & Sinha (2024), which was originally formulated for gene regulatory network inference. PerturbClaw's contribution is to recognize that this framework describes a general computational pattern — comparing condition-specific attribution landscapes over a shared evaluation set — that is not intrinsically biological and can be instantiated wherever paired tabular conditions and a continuous outcome exist. What follows presents the theoretical foundation as developed by Dibaeinia et al. (2024), followed by an explicit account of how PerturbClaw extends and generalizes it.
The inferential challenge. The goal is to reason about causal influence — how much does feature directly determine ? — using only observational data. Pearl's do-calculus (Pearl, 2009) provides the formal language: the observational quantity conflates direct causal effects with confounding paths, whereas isolates the downstream causal effect by severing all incoming arrows to . This distinction is the foundation of the Local Treatment Effect defined below.
Local Treatment Effect (Dibaeinia et al., 2024, Definition 1). For feature and target , the LTE at state is:
{t,g}(\mathbf{x}) = E!\left[Y_g \mid \mathrm{do}(X_t = x_t),, \mathrm{do}(\mathbf{X}{-t} = \mathbf{x}{-t})\right] - E!\left[Y_g \mid \mathrm{do}(X_t = \hat{x}t),, \mathrm{do}(\mathbf{X}{-t} = \mathbf{x}{-t})\right]
Intervening on all features simultaneously blocks backdoor paths through other observed features and isolates 's direct structural contribution. The LTE is analogous to the Conditional Average Treatment Effect (CATE) in the causal inference literature, with playing the role of treatment, the outcome, and covariates held fixed by intervention rather than by conditioning. In Dibaeinia et al. (2024), is a transcription factor and is a target gene. PerturbClaw treats this as a general template: can be any input feature and any continuous outcome — an atmospheric variable predicting regional temperature, a protein level predicting cell viability, a policy indicator predicting an economic outcome, or any other paired tabular setting. The causal reasoning is identical across all of these; only the domain label changes.
From LTE to estimable proxy (Dibaeinia et al., 2024, Section 3). Two obstacles prevent direct LTE estimation: the baseline is arbitrary, and the true causal DAG is unobserved. Dibaeinia et al. (2024) resolve both by marginalization. Averaging over the baseline marginal removes baseline dependence:
{t,g}(\mathbf{x}) = E{\hat{x}t \sim P(X_t)}!\left[\mathrm{LTE}{t,g}(\mathbf{x}, \hat{x}_t)\right]
Averaging further over all causal DAGs in which has a direct edge to removes graph dependence, yielding the graph-marginalized proxy :
t,,\psi}!\left[\mathrm{LTE}{t,g}(\mathbf{x},, \hat{x}_t,, \psi)\right]
Note that is a statistical proxy, not the true causal effect: it averages over all allowed graphs, including unrealistic ones. Dibaeinia et al. (2024) are explicit that this is a first step toward full causal identification.
The SHAP connection (Dibaeinia et al., 2024, Main Theorem). Under three assumptions — (1) correctly specifies , (2) is Markov with respect to the true DAG, and (3) the SHAP background distribution matches — the SHAP value approximates :
t,,\psi}!\left[\mathrm{LTE}{t,g}(\mathbf{x},, \hat{x}_t,, \psi)\right]
The Shapley formula (Lundberg & Lee, 2017; Shapley, 1953) computes this as:
where S\right]. Intuitively, averaging over coalitions resembles the graph marginalization in {t,g}, though this structural resemblance should be understood as motivation rather than formal equivalence.
Where PerturbClaw extends this framework. Dibaeinia et al. (2024) apply this theory to differential gene regulatory network inference in single-cell RNA sequencing data. PerturbClaw makes a different claim: that the computational pattern — fit condition-specific nonlinear models, compute SHAP attributions on a shared evaluation set, aggregate differences via RMS — is a general-purpose workflow whose validity does not depend on the biological context. PerturbClaw packages this pattern as a domain-independent executable workflow, with explicit separation between the theoretical grounding (drawn from Dibaeinia et al., 2024, with attribution), the backend implementation (currently the CIMLA package), and the workflow abstraction itself, which is independent of both and is PerturbClaw's primary contribution. A future version of PerturbClaw could substitute any attribution backend satisfying the three stated assumptions without altering the workflow structure or its causal rationale.
Caveats. The Markov condition is frequently violated in real systems through feedback, pleiotropy, and unmeasured common causes. Latent confounders not captured in are not removed by the intervention on observed features and can distort . Selecting attribution data strategically — restricting to matched samples, homogeneous subpopulations, or time-aligned observations — can reduce the influence of latent confounders and improve the interpretability of RAD scores across domains.
The PerturbClaw workflow
PerturbClaw implements a domain-independent workflow template for estimating perturbation-relevant feature influence under partially observed causal structure. The workflow separates predictive modeling, attribution estimation, and attribution aggregation into independent reproducible stages, allowing substitution of model classes, attribution methods, and aggregation metrics across scientific domains. The current reference implementation uses the CIMLA Python package as a backend; however, the PerturbClaw workflow abstraction is independent of this implementation choice and is designed to support alternative predictive estimators and attribution operators as they become available.
The workflow follows a five-stage pipeline: predict → attribute → aggregate → compare → rank
Step 1 — Predict. Paired-condition matrices are loaded, normalized to zero mean and unit variance, and partitioned into train and test sets using a configurable split ratio. Normalization ensures that features on different measurement scales do not dominate the predictive model due to magnitude alone. If the target variable also appears as an input feature, its column is randomly permuted to prevent the model from exploiting direct self-prediction. This permutation step is inherited from the CIMLA backend (Dibaeinia et al., 2024) and is applicable wherever target leakage is a risk. For large datasets that exceed available memory, the workflow supports a Dask-backed data path with HDF5 caching and batched iteration throughout the pipeline.
Step 2 — Attribute. Two independent nonlinear predictive models are trained: on condition 0 (control) and on condition 1 (case). Independence is essential — the models must not share weights, parameters, or training data — because the attribution comparison in Step 3 is only interpretable if each model has learned the predictive structure of its own condition without influence from the other. The reference implementation exposes two model classes through the CIMLA backend: Random Forest (RF), implemented via scikit-learn with 3-fold GridSearchCV over hyperparameter grids covering tree depth, feature subsampling rate, and minimum leaf size; and Neural Network (MLP with dropout), implemented via Keras/TensorFlow with configurable hidden layer widths, dropout rate, L2 regularization, and mini-batch training. Both are universal approximators capable of capturing nonlinear relationships between features and outcomes that linear methods would miss. Model quality is evaluated on held-out test data using and MSE; a test for either condition is a warning signal that the predictive model may be too noisy to yield reliable attribution scores.
Step 3 — Aggregate. Both trained models and are evaluated on the same attribution dataset — by default, the case-condition samples. This shared evaluation is a deliberate design choice: by holding the input distribution constant and varying only the model, the resulting attribution difference is attributable to a shift in predictive structure between conditions rather than to a difference in sample composition. For RF models, TreeSHAP (Lundberg et al., 2020) is used to compute exact Shapley values in polynomial time by exploiting the tree structure. For NN models, DeepSHAP is used, which approximates Shapley values using a background reference distribution sampled from the training data. In both cases, the result is two attribution matrices and , each of shape , where rows are samples and columns are features. The per-sample, per-feature attribution difference forms the raw material for the aggregation step.
Step 4 — Compare. The attribution differences are aggregated into a single scalar per feature using the RMS attribution divergence statistic (RAD):
{t,g} = \sqrt{\frac{1}{|X|}\sum{\mathbf{x} \in X}!\left[\phi_t(f_1, \mathbf{x}) - \phi_t(f_0, \mathbf{x})\right]^2}
The choice of RMS rather than a signed mean is principled: relationships often shift heterogeneously across the sample population — some samples show a positive attribution shift for feature , others negative. A signed mean would cancel these opposing shifts and could report near-zero divergence even when large sample-level changes are occurring. RMS captures the magnitude of per-sample attribution change regardless of direction, making it sensitive to heterogeneous shifts that a mean-based statistic would mask. The RAD statistic is fully domain-agnostic: it makes no assumptions about what features or targets represent, and its interpretation — feature 's attributional influence changed substantially between conditions — is equally valid whether is a transcription factor, an atmospheric variable, a drug concentration, or an economic indicator.
Step 5 — Rank. Features are ranked in descending order of . When the workflow is run across multiple targets — the typical use case, since a single run produces scores for one target at a time — rankings are aggregated across targets by averaging per-feature RAD scores, and a final ranked list identifies the features that most consistently changed their attributional influence across the full set of outcomes. High-ranking features are candidates for follow-up analysis: experimental validation in scientific domains, policy investigation in social science settings, or targeted data collection in engineering applications. The RAD score should be interpreted as a prioritization tool rather than a definitive causal claim — it identifies where condition-driven attribution shifts are largest, which is where causal investigation is most warranted.
3. Skill Design and Executability
The SKILL.md is structured as an agent-executable workflow with explicit commands, expected outputs, and validation steps:
- Install dependencies and create the conda environment
- Prepare paired-condition CSV inputs and a target definition
- Configure a YAML file for RF or NN execution
- Run the backend command
cimla --config config.yaml - Verify outputs with
python verify_output.pyand rank features by
This design aligns with the Claw4S review emphasis on executability, reproducibility, and clarity for agents. The package includes a lightweight example run, a verification script, and a synthetic batch workflow for submission-safe demonstrations. The current executable backend is inherited from the upstream CIMLA package. For submission accuracy, the package documents the validated backend stack as Python 3.8.12 with the legacy CIMLA dependency set, rather than claiming a modernized environment that has not been verified.
Example run
The run_example.sh script executes the full PerturbClaw workflow on the provided example data end-to-end:
conda activate perturbclaw_env
bash run_example.sh
python verify_output.pyExpected output files in example_results/:
global_feature_importance.csv # RAD scores — one per input feature
performance_group1.csv # R2/MSE on train and test, condition 0
performance_group2.csv # R2/MSE on train and test, condition 1A well-fit model should have on the test set. If is near zero for both conditions, the target may not be predictable from these features and results should be interpreted cautiously.
Synthetic batch workflow
For submission-safe demonstrations without real identifiers or real measurements, the package includes a fully synthetic workflow:
bash run_synthetic_pipeline.shThis path uses only synthetic entity names (TF001...TF200, GENE001...GENE200) and synthetic measurements. Default synthetic dataset parameters:
- 200 synthetic features (
TF001...TF200) - 200 synthetic targets (
GENE001...GENE200) - 600 samples in condition 0
- 800 samples in condition 1
4. Validated Backend Environment
| Package | Version |
|---|---|
| Python | 3.8.12 |
| tensorflow | 2.2.0 |
| scikit-learn | 0.24.2 |
| shap | 0.39.0 |
| pandas | 1.3.3 |
| xgboost | 1.5.0 |
Validated execution is currently tied to the legacy CIMLA stack. The inspected working environment is Linux-based. Apple Silicon (osx-arm64) support is not claimed by this package and may require Docker, x86 emulation, or upstream maintenance by the original CIMLA authors.
5. Generalizability
PerturbClaw is explicitly framed as a domain-general workflow abstraction. The workflow requires only paired conditions, tabular predictors, a continuous outcome, and an attribution-capable predictive model. Example applications:
- Drug response: condition 0 = untreated cells, condition 1 = drug-treated; features = protein levels; target = cell viability
- Climate science: condition 0 = pre-2000 climate, condition 1 = post-2000; features = atmospheric variables; target = regional temperature
- Economics: condition 0 = pre-policy period, condition 1 = post-policy; features = economic indicators; target = unemployment rate
- Neuroscience: condition 0 = baseline stimulus, condition 1 = active stimulus; features = neural firing rates; target = behavioral outcome
- Materials science: condition 0 = standard processing, condition 1 = modified processing; features = material properties; target = yield strength
The core question — which features differ most in attributional influence between two conditions? — is domain-agnostic, and provides a portable aggregation target for that question.
6. Evidence and Positioning
The reference implementation is grounded in the empirical results reported by Dibaeinia et al. (2024), where the underlying method was evaluated on synthetic and real biological datasets. On synthetic scRNA-seq data generated by the SERGIO simulator with known ground-truth regulatory networks, the method outperforms all competing approaches (GENIE3-diff, BoostDiff, DoubleML-diff, co-expression baselines) in both AUROC and AUPRC. The advantage is largest in the high-confounding condition, where competing methods degrade substantially while the attribution-based approach maintains high performance.
PerturbClaw does not claim to replace those experiments; instead, it turns the methodological pattern into an executable, reusable workflow suitable for CLAW-style review and adaptation across domains. For this submission package, emphasis is placed on executable reproducibility, portability through synthetic paired-condition data, clarity of the predict–attribute–aggregate–compare–rank decomposition, and faithful documentation of the validated dependency stack.
7. Limitations
The workflow should not be interpreted as exact causal identification. The attribution differences are assumption-dependent proxies, and latent confounding or model misspecification can distort them. Specifically:
- averages the LTE over all allowed causal diagrams, including unrealistic ones — making it a statistical proxy rather than the true causal effect in the underlying network. Selecting attribution data strategically — for example, by restricting to matched samples, homogeneous subpopulations, or time-aligned observations — can reduce the influence of latent confounders and improve the interpretability of RAD scores across domains.
- Latent confounders such as unmeasured subpopulation structure are not fully removed by the intervention on observed features.
- SHAP-based attribution is computationally expensive for large feature sets; sampling and batching strategies are important in practice.
There is also an implementation-level limitation: the reference backend depends on a legacy Python 3.8.12 stack and has been validated in a Linux environment. Cross-platform support, especially on Apple Silicon, should be treated as a separate engineering problem rather than assumed from the current package.
References
- Dibaeinia P., Ojha A., Sinha S. (2024). Interpretable AI for inference of causal molecular relationships from omics data. Science Advances, 11(7), eadk0837.
- Pearl, J. (2009). Causality: Models, Reasoning, and Inference. Cambridge University Press.
- Lundberg, S.M. & Lee, S.I. (2017). A unified approach to interpreting model predictions. NeurIPS.
- Lundberg, S.M. et al. (2020). From local explanations to global understanding with explainable AI for trees. Nature Machine Intelligence (TreeSHAP).
- Dibaeinia P. & Sinha S. (2020). SERGIO: a single-cell expression simulator guided by gene regulatory networks. Cell Systems.
- Shapley, L.S. (1953). A value for n-person games. Contributions to the Theory of Games.
Reproducibility: Skill File
Key execution commands:
conda env create -f environment.yml
conda activate perturbclaw_env
pip install CIMLA
bash run_example.sh
python verify_output.py
bash run_synthetic_pipeline.shAll commands are run from the submission directory. No API keys or GPU are required for the RF backend. The synthetic workflow is the recommended demonstration path for external review.
Reproducibility: Skill File
Use this skill file to reproduce the research with an AI agent.
---
Workflow type: reproducible attribution-aggregation pipeline
Target venue: CLAW4S
name: perturbclaw_differential_attribution
title: "PerturbClaw: Differential Attribution Aggregation Under Structural Uncertainty"
description: This workflow estimates perturbation-relevant feature influence between paired conditions using nonlinear predictive models and attribution aggregation. The workflow trains condition-specific predictive ensembles, computes feature-level attribution scores, and quantifies attribution divergence using stability-aware aggregation metrics. In this reference implementation aggregation is performed using the RMS attribution divergence statistic, though alternative aggregation operators may be substituted.
category: attribution-aggregation
language: python
allowed-tools: Bash(python *), Bash(conda *), Bash(pip *), Bash(bash *), Bash(git *), Bash(curl *)
inputs:
- condition0_data.csv
- condition1_data.csv
- features.csv
- target.csv
outputs:
- example_results/global_feature_importance.csv
- example_results/performance_group1.csv
- example_results/performance_group2.csv
execution:
command: bash run_example.sh
verify:
command: python verify_output.py
requirements:
- python=3.8.12
- numpy=1.23.5
- pandas=1.3.3
- scikit-learn=0.24.2
- shap==0.39.0
- tensorflow==2.2.0
- xgboost==1.5.0
- pyyaml==5.4.1
- joblib==1.4.2
- CIMLA @ git+https://github.com/PayamDiba/CIMLA.git@d013aa5a431987a3c74b9f0a6036dde017d854d0
reference: "Dibaeinia, Ojha & Sinha. Science Advances, 2024. DOI: 10.1126/sciadv.adk0837"
repository: https://github.com/PayamDiba/CIMLA
commit: d013aa5a431987a3c74b9f0a6036dde017d854d0
---
# PerturbClaw: Differential Attribution Aggregation Under Structural Uncertainty
Inspired by work from Dibaeinia et al. (2024) (referred to here also as CIMLA), PerturbClaw generalizes a methodology
meant for gene-transcription factor attribution modeling and expands it to measure
feature importance in a host of disciplines. Given data from two conditions
(e.g. disease vs. control, treated vs. untreated), this workflow estimates perturbation-relevant
feature influence between paired
conditions using nonlinear predictive models and attribution aggregation. The
workflow trains condition-specific predictive ensembles, computes feature-level
attribution scores, and quantifies attribution divergence using stability-aware
aggregation metrics.
Under the assumptions described in Dibaeinia et al. (2024), attribution differences approximate graph-marginalized proxies for
condition-specific local treatment effects and provide an interpretable estimate of perturbation-relevant feature influence
beyond purely correlational importance scores.
## Workflow abstraction
PerturbClaw implements a domain-independent workflow template for estimating
perturbation-relevant feature influence under partially observed causal structure.
The workflow separates predictive modeling, attribution estimation, and attribution
aggregation into independent reproducible stages, allowing substitution of model
classes, attribution methods, and aggregation metrics across scientific domains.
The current reference implementation uses the CIMLA python package as a backend
for predictive modeling and attribution computation; however, the PerturbClaw
workflow abstraction is independent of this implementation choice and supports
alternative predictive estimators and attribution operators. PerturbClaw supports both
single-target execution and scalable multi-target batch workflows through
configuration-driven automation.
## Workflow stages
The workflow follows a five-stage structure:
predict → attribute → aggregate → compare → rank
PerturbClaw applies to any tabular dataset containing paired conditions and a
continuous outcome variable, including applications in genomics, neuroscience,
climate modeling, and materials science.
---
## Validated backend environment
The current reference implementation depends on the upstream CIMLA package and
therefore inherits its legacy backend constraints. This skill is validated
against an inspected working backend environment with Python `3.8.12`,
`tensorflow==2.2.0`, `scikit-learn==0.24.2`, `shap==0.39.0`,
`pandas==1.3.3`, and `xgboost==1.5.0`.
The inspected working backend environment is Linux-based. Apple Silicon support
is not claimed in this submission package. On `osx-arm64`, execution may require
Docker, x86 emulation, or upstream maintenance by the original CIMLA authors.
## Prerequisites
### Step 0 -- Set up environment
```bash
# Create and activate conda environment
conda env create -f environment.yml
conda activate perturbclaw_env
# Install the CIMLA backend, making sure the legacy packages are correct
pip install CIMLA
# Verify installation
python -c "import CIMLA; print('CIMLA installed successfully')"
```
---
## Input data format
Four CSV files are required:
| File | Description | Shape |
|------|-------------|-------|
| `condition0_data.csv` | Feature matrix, condition 0 (control) | cells x features |
| `condition1_data.csv` | Feature matrix, condition 1 (case) | cells x features |
| `features.csv` | Input feature names, one per row | m x 1 |
| `target.csv` | Target output variable name | 1 x 1 |
Requirements:
- All values must be numeric
- Both condition files must have identical column names
- The target variable column must appear in both condition files
- No missing values -- impute before running
The workflow assumes both condition matrices share identical feature columns and differ only in sample membership.
To test immediately with provided example data, skip to Step 1 --
example CSVs are already in `example_data/`.
---
## Step 1 -- Configure your YAML file
Two templates are provided in `config_templates/`. Choose based on your ML backend.
### Option A: Random Forest (recommended -- no GPU required)
Copy and edit `config_templates/config_rf.yaml`:
```yaml
data:
group1: path/to/condition0_data.csv
group2: path/to/condition1_data.csv
independent: path/to/features.csv
dependent: path/to/target.csv
normalize: true
test_size: 0.2
random_state: 42
ML:
type: RF
n_estimators: [100, 200]
max_depth: [3, 5, null]
max_features: [0.3, 0.5]
min_samples_leaf: [1, 5]
max_leaf_nodes: [null]
attribution:
type: tree_shap
attr_data_group: group2
attr_data_size: null
aggregation:
global_type: RMSD
output:
dir: results/
save_local: false
save_models: true
performance_metric: R2
```
### Option B: Neural Network (GPU recommended for large datasets)
Create `config_nn.yaml`:
```yaml
data:
group1: path/to/condition0_data.csv
group2: path/to/condition1_data.csv
independent: path/to/features.csv
dependent: path/to/target.csv
normalize: true
test_size: 0.2
random_state: 42
ML:
type: MLP
hidden_units: [64, 32]
dropout: 0.2
l2: 0.001
epochs: 100
batch_size: 128
learning_rate: 0.001
attribution:
type: deep_shap
attr_data_group: group2
attr_data_size: null
background_size: 1000
aggregation:
global_type: RMSD
output:
dir: results/
save_local: false
save_models: true
performance_metric: R2
```
---
## Step 2 -- Run the PerturbClaw differential attribution workflow on a single target
```bash
cimla --config config.yaml
```
To run the provided example end-to-end:
```bash
bash run_example.sh
```
Expected output files in `results/` (or `example_results/` for the example run):
```
global_feature_importance.csv # RMS attribution divergence statistics -- one per input feature
model_group1.joblib # trained model for condition 0
model_group2.joblib # trained model for condition 1
performance_group1.csv # R2/MSE on train and test, condition 0
performance_group2.csv # R2/MSE on train and test, condition 1
```
Validate model quality after running:
```python
import pandas as pd
for g in ["group1", "group2"]:
perf = pd.read_csv(f"results/performance_{g}.csv")
print(f"{g}:", perf)
```
A well-fit model should have R2 > 0.3 on the test set. If R2 is near zero for both
conditions, the target may not be predictable from these features -- interpret
results cautiously.
---
## Step 3 -- Run across multiple targets
The underlying CIMLA engine processes one target at a time. Use this driver script to loop over many:
```bash
#!/bin/bash
# Usage: bash run_all_targets.sh targets.txt config_template.yaml results_dir/
TARGETS=$1
CONFIG_TEMPLATE=$2
RESULTS_DIR=$3
mkdir -p "$RESULTS_DIR"
while IFS= read -r target; do
echo "Processing: $target"
sed "s/TARGET_PLACEHOLDER/$target/" "$CONFIG_TEMPLATE" > tmp_config_$target.yaml
sed -i "s|results/|$RESULTS_DIR/$target/|" tmp_config_$target.yaml
cimla --config tmp_config_$target.yaml
rm tmp_config_$target.yaml
done < "$TARGETS"
echo "Done. Results in $RESULTS_DIR"
```
In your config template set `dependent: TARGET_PLACEHOLDER` -- the script substitutes
the actual target name on each iteration.
---
## Step 4 -- Rank and interpret results
```python
import pandas as pd
import os
results_dir = "results/"
# Aggregate scores across multiple targets
all_scores = []
for target in os.listdir(results_dir):
score_file = os.path.join(results_dir, target,
"global_feature_importance.csv")
if os.path.exists(score_file):
scores = pd.read_csv(score_file)
scores["target"] = target
all_scores.append(scores)
combined = pd.concat(all_scores, ignore_index=True)
mean_scores = combined.drop(columns="target").mean().sort_values(ascending=False)
print("Top 10 features by mean RMS attribution divergence statistic:")
print(mean_scores.head(10))
mean_scores.to_csv("ranked_features.csv", header=["mean_rms_attribution_divergence_statistic"])
```
Interpreting scores:
- High RMS attribution divergence statistic = feature's attributional influence changed substantially between conditions
- This is a proxy for causal regulatory change (alpha_{t,g}), not direct proof
- High-scoring features are candidates for follow-up experimental validation
---
## Step 5 -- Ensemble RF and NN scores (MeanRank, optional)
For more robust results, run both backends and combine rankings:
```python
import pandas as pd
rf = pd.read_csv("results_rf/global_feature_importance.csv").T
nn = pd.read_csv("results_nn/global_feature_importance.csv").T
rf.columns = ["rf_score"]
nn.columns = ["nn_score"]
rf["rf_rank"] = rf["rf_score"].rank(ascending=False)
nn["nn_rank"] = nn["nn_score"].rank(ascending=False)
combined = rf.join(nn)
combined["mean_rank"] = (combined["rf_rank"] + combined["nn_rank"]) / 2
combined = combined.sort_values("mean_rank")
print("Top features by MeanRank ensemble:")
print(combined.head(10))
combined.to_csv("ensemble_ranked_features.csv")
```
---
## Troubleshooting
| Problem | Likely cause | Fix |
|---------|-------------|-----|
| R2 near zero for both models | Target not predictable from features | Check data quality; verify correct files used |
| SHAP computation very slow | Too many cells or features | Set `attr_data_size: 500` to subsample |
| DeepSHAP memory error | Dataset too large | Switch to RF + TreeSHAP, or enable `cache: true` for HDF5 batching |
| All RMS attribution divergence statistics near zero | Models identical between conditions | Verify conditions are genuinely different |
| ImportError on CIMLA | Package not installed | Run `pip install CIMLA` |
---
## Adapting to new domains
This workflow is domain-independent. Replace the input CSVs with your own
two-condition tabular data and run Steps 1-4 identically. Example applications:
- Drug response: condition 0 = untreated, condition 1 = treated; features = protein
levels; target = cell viability
- Climate science: condition 0 = pre-2000, condition 1 = post-2000; features =
atmospheric variables; target = regional temperature
- Economics: condition 0 = pre-policy, condition 1 = post-policy; features =
economic indicators; target = unemployment rate
---
## Shareable synthetic mode (added)
Synthetic mode enables deterministic execution suitable for automated workflow validation and agent-based benchmarking.
This integrated package now includes a fully synthetic workflow for conference/demo use:
- Synthetic TF list and gene list (`synthetic_data/`)
- Synthetic two-condition expression matrices (`synthetic_data/`)
- Batch config generation scripts (`scripts/`)
- End-to-end synthetic runner (`run_synthetic_pipeline.sh`)
Use this mode when sharing the package externally and you need a reproducible run without real identifiers or real measurements.Discussion (0)
to join the discussion.
No comments yet. Be the first to discuss this paper.