<h1>Table of Contents<span class="tocSkip"></span></h1>
<div class="toc"><ul class="toc-item"></ul></div>

$$
\begin{align}
\max_{v,p,t,e,a} \quad & f^T v \\
\text{subject to} \quad & Sv = 0, \\
   & l \leq v \leq u, \\
   & \sum p \leq P, && \text{P: total protein mass} \\
   & C e = p,  && \text{C: protein complex stoichiometry}  \\
   & v_j \leq \sum_{i\in r(j)} k^\text{eff}_{ij} e_i, && \text{r(j): enzymes catalyzing reaction j} \\
   & t_i = p_i / w_i && \text{Scaling RNA (transcript, $t$)-to-protein by a factor $w$. Simplest case: uniform scaling.} \\
   & \log_2(t_i) = \log_2(t^0_i) + R_i a,  && \text{R: log-linear regulatory constraints, $R_i$: row $i$} \\
   & t \geq \delta
\end{align}
$$
where $p^0$ is a constant reference vector (log_2 transformed), and $\delta$ is a small number (e.g., 0.01 / P), and $w_i$ are RNA-to-protein scaling weights, $p$ is protein, $e$ is enzyme complex, $t$ is transcript, $a$ is regulatory component activity.

This problem has the general form:

$$
\begin{align}
\max_{x} \quad & f^T x \\
\text{subject to} \quad & l \leq Ax \leq u, \\     
   & \log(Cx) + Dx = b
\end{align}
$$

$$
\begin{align}
\max_{x,y} \quad & f^T x \\
\text{subject to} \quad & l \leq Ax \leq u, \\     
   & y + Dx = b \\
   & y_i = \log(x_j)
\end{align}
$$

Moving $y_i=\log(x_j)$ into objective with augmented Lagrangian should make the constraint be solved exactly.  Interior point also appropriate?

The log constraint comes from:

ICA-equivalent form:
$$
\begin{align}
\log_2(p) - \log_2(p^0) &= Ma
\end{align}
$$

$$
\begin{align}
\log_2(X) - \log_2(X^0) &= SA
\end{align}
$$

Note: $\log(x)$ is quasiconvex on $x > 0$.

Can use the augmented Lagrangian of MINOS.


```python

```


```python
import pandas as pd
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
```


```python
%matplotlib inline
```

ICA values


```python
df_X0 = pd.read_csv('../data/data_files/log_tpm.csv', index_col=0)
df_X = pd.read_csv('../data/data_files/log_tpm_norm.csv', index_col=0)
df_M = pd.read_csv('../data/data_files/M.csv', index_col=0)
df_A = pd.read_csv('../data/data_files/A.csv', index_col=0)
```


```python
X0 = df_X0.to_numpy()
X = df_X.to_numpy()
A = df_A.to_numpy()
M = df_M.to_numpy()
MA = np.dot(M,A)
```


```python
print('X not norm:', df_X0.min().min(), df_X0.max().max())
print('X norm:', df_X.min().min(), df_X.max().max())
```

    X not norm: 0.0 16.4019957054125
    X norm: -11.336737814951801 12.831169252022299


df_A.head()


```python
### X as fold change:
m = X0.shape[0]
xref = np.log2(df_X0.iloc[:,:2].mean(1)+1.).to_numpy()
xref = xref.reshape((m,1))
ncond = X0.shape[1]
Xref = np.outer(xref, np.ones((1,ncond)))
Xf = np.log2(X0+1) - Xref
```


```python
plt.hist((Xf - MA).flatten(), 50)
```

4573cef7ca3f59e86595fa04bcbc1b7dcf59240d
ipynb
Jupyter Notebook
framework.ipynb
NYXFLOWER/MeMo
e8007ea2de6b45acc24f4459f64dfa8b1374ad29
MIT
framework.ipynb
NYXFLOWER/MeMo
e8007ea2de6b45acc24f4459f64dfa8b1374ad29
MIT
framework.ipynb
NYXFLOWER/MeMo
e8007ea2de6b45acc24f4459f64dfa8b1374ad29
MIT
Qwen/Qwen-72B
1. YES
2. YES