Skip to content

Load and validate data

Download the notebook (executed for this page) · source

Validation checks numeric finite time series without silently normalizing them. Protein/PSite input uses GeneID/Psite, mRNA uses GeneID, and regulation uses Source/Target. input1 columns are matched to the RNA times by actual time (ms_time_points and time_points of the configuration; TFOpt has no built-in time grid).

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.cleanup import validate_timeseries
from tfopt.local.utils.iodata import load_expression_data,load_tf_protein_data
frame=pd.read_csv(ROOT/'notebooks/data/input1.csv')
print(validate_timeseries(frame,['GeneID','Psite']))
genes,expression,columns=load_expression_data()
tfs,protein,sites,labels,times=load_tf_protein_data()
assert [len(sites[tf]) for tf in ['TF0','TF1','TF2']]==[0,1,2]
print('Genes:',genes,'TFs:',tfs,'time columns:',columns)
['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8', 'x9']
Genes: ['G0', 'G1', 'G2', 'G3', 'G4'] TFs: ['TF0', 'TF1', 'TF2', 'G0', 'G1', 'G2', 'G3', 'G4'] time columns: ['x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x8', 'x9']

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/.