Skip to content

Preprocessing and mapping

Download the notebook (executed for this page) · source

Regulator order determines alpha layout. Missing regulators use -1 padding; they never contribute to predictions or absorb alpha mass. The edge mapper preserves order and removes duplicate edges. Genes lacking measured valid regulators are excluded by the filtering stage.

from pathlib import Path
import os, sys
ROOT = next(p for p in [Path.cwd(), *Path.cwd().parents] if (p / 'pixi.toml').exists())
os.environ['TFOPT_CONFIG'] = str(ROOT / 'notebooks/data/toy.toml')
os.environ.setdefault('MPLBACKEND', 'Agg')
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))
import tfopt
import numpy as np
import pandas as pd
from notebooks.tutorial import build_problem, optimize, OUTPUT
p = build_problem()
from processing.map import regulation_map
edges=pd.read_csv(ROOT/'notebooks/data/input4.csv')
mapping=regulation_map(edges)
display(mapping)
print('Padded regulator matrix:')
print(p['args'][1])
assert np.any(p['args'][1] == -1)
{'G0': ['TF0'],
 'G1': ['TF1'],
 'G2': ['TF2'],
 'G3': ['TF0', 'TF1'],
 'G4': ['TF0', 'TF1', 'TF2']}
Padded regulator matrix:
[[ 0 -1 -1]
 [ 1 -1 -1]
 [ 2 -1 -1]
 [ 0  1 -1]
 [ 0  1  2]]

Interpretation

Check both fit and feasibility. For biological data, identifiability, scaling and regulatory coverage need domain review. Results and figures belong only in notebooks/outputs/.