jcrozum / pystablemotifs

Python library for attractor identification and control in Boolean networks
MIT License
28 stars 7 forks source link

Running time greatly depending on constant nodes #92

Open kyuhyongpark opened 1 year ago

kyuhyongpark commented 1 year ago

I noticed that the running time for building the succession diagram greatly depends on the initial percolation/deletion of constant nodes. @jcrozum Are you aware of this? I'm pretty sure we won't have this issue in the nfvs-motifs though.

I used the 2017 ABA model, and fixed ABA=1 and percolated it. I also used MPBN update.

  1. Removed constants in the percolation - took 1.5 s
  2. Did not remove constants in the percolation - took 72 s

One could say that you can always percolate first and remove constants, so this is not a problem. Then at least we should document it so that people do this.

The 2017 ABA model

ABA* = ABA
ABH1* = 1
ARP_Complex* = 1
CPK6* = 1
CPK23* = 1
DAGK* = 1
ERA1* = 1
GAPC1_2* = 1
GCR1* = 1
GTP* = 1
MRP5* = 1
NAD* = 1
NADPH* = 1
Nitrite* = 1
NtSyp121* = 1
PC* = 1
PtdInsP3* = 1
PtdInsP4* = 1
RCN1* = 1
SCAB1* = 1
Sph* = 1
GEF1_4_10* = 0
SPP1* = 0
RCARs* = ABA
PEPC* = not ABA
PI3P5K* = ABA
ROP11* = GEF1_4_10
ABI1* = not PA and (not RCARs or ROP11) and not ROS and pHc
ABI2* = (not RCARs or ROP11) and not ROS
HAB1* = not RCARs and not ROS
PP2CA* = not RCARs and not ROS
OST1* = (not ABI1 and not HAB1) or (not PP2CA and not ABI2) or (not ABI1 and not ABI2) or (not HAB1 and not PP2CA) or (not HAB1 and not ABI2) or (not ABI1 and not PP2CA)
RBOH* = pHc and not ABI1 and PtdInsP3 and OST1 and GPA1 and PA and RCN1
ROS* = NADPH and RBOH
GHR1* = not ABI2 and ROS
NO* = Nitrite and NIA1_2 and NADPH
NIA1_2* = ROS
NOGC1* = NO
cGMP* = NOGC1 and GTP
8-nitro-cGMP* = cGMP and ROS and NO
ADPRc* = 8-nitro-cGMP
cADPR* = NAD and ADPRc
CIS* = InsP3 or InsP6 or cADPR
CaIM* = Actin_Reorganization or (NtSyp121 and GHR1 and MRP5) or not ABH1 or not ERA1
Ca2c* = (CIS or CaIM) and not Ca2_ATPase
Ca2_ATPase* = Ca2c
CPK3_21* = Ca2c or CPK3_21
MPK9_12* = Ca2c or MPK9_12
PtdIns4_5P2* = PtdInsP4
PLC* = Ca2c
DAG* = PtdIns4_5P2 and PLC
InsP3* = PLC and PtdIns4_5P2
InsP6* = InsP3
PLDalpha* = GPA1 and Ca2c
PLDdelta* = NO or ROS and GAPC1_2
PA* = PC and (PLDdelta or PLDalpha) or DAG and DAGK
SPHK1_2* = PA or ABA
S1P_PhytoS1P* = SPHK1_2 and Sph and not SPP1
GPA1* = S1P_PhytoS1P or not GCR1
PtdIns3_5P2* = PI3P5K
V-PPase* = PtdIns3_5P2
V-ATPase* = Ca2c
Vacuolar_Acidification* = V-PPase or V-ATPase or Vacuolar_Acidification
TCTP* = Ca2c
Microtubule_Depolymerization* = TCTP or Microtubule_Depolymerization
pHc* = (OST1 and not ABI2 and not ABI1 or Ca2c) and Vacuolar_Acidification
H_ATPase* = not pHc and not Ca2c and not ROS
AtRAC1* = not ABA or ABI1
Actin_Reorganization* = (PtdInsP4 or PtdInsP3) and not AtRAC1 and ARP_Complex and SCAB1
SLAC1* = (CPK6 or CPK23 or CPK3_21) and MPK9_12 and OST1 and GHR1 and pHc and not ABI1 and not PP2CA and not ABI2
QUAC1* = OST1 and Ca2c
SLAH3* = (CPK6 or CPK23) and CPK3_21 and not ABI1
AnionEM* = SLAC1 or QUAC1 and SLAH3
Malate* = PEPC and not ABA and not AnionEM
KEV* = Vacuolar_Acidification or Ca2c
Depolarization* = (AnionEM or Ca2c or KEV) and (not H_ATPase or not K_efflux)
KOUT* = (not NO or not ROS or pHc) and Depolarization
K_efflux* = KEV and KOUT
AquaporinPIP2_1* = OST1
H2O_Efflux* = (AnionEM and AquaporinPIP2_1 and K_efflux) and not Malate
Closure* = Microtubule_Depolymerization and H2O_Efflux

The code I used.

import pystablemotifs as sm
import pyboolnet.prime_implicants
import time

MODEL = 'PyStableMotifs/models/ABA_full.txt'

primes = sm.format.import_primes(MODEL)
print("Network loaded.\n")

fix = {'ABA':1}
print('fix:', fix)

print("Finding attractors with the constant nodes removed")
start = time.time()
primes1 = pyboolnet.prime_implicants.percolate(primes, add_constants = fix, remove_constants = True, copy=True)
print('percolated')
ar = sm.AttractorRepertoire.from_primes(primes1,MPBN_update=True)
ar.summary()
print("time taken: ", time.time()-start)

print("Finding attractors without the constant nodes removed")
start = time.time()
primes2 = pyboolnet.prime_implicants.percolate(primes, add_constants = fix, remove_constants = False, copy=True)
print('percolated')
ar = sm.AttractorRepertoire.from_primes(primes2,MPBN_update=True)
ar.summary()
print("time taken: ", time.time()-start)
jcrozum commented 1 year ago

@troonmel I was not aware of this. By default, the constant nodes are percolated and removed when the functions are first imported, so the issue never came up. It should be easy enough to add a call to percolate as the first step of the from_primes function if we want to address this.

kyuhyongpark commented 1 year ago

I think the default setting in the import_primes is to not percolate and not remove constants. When set remove_constants=True, it does percolate and remove constants.

I'm wondering why carrying around the constant nodes that are already percolated to the other functions makes such a huge difference in the running time.

jcrozum commented 1 year ago

Oh, I guess you're right; I had it backwards. I have some guesses about why it might be slow, but I'll have to do some digging. Let me know if you figure it out.