jcrozum / pystablemotifs

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

Killed: 9 #73

Closed yzongy closed 2 years ago

yzongy commented 2 years ago

Hi Jordan,

I am working on large networks with pystablemotifs. As far as I know, the typical workflow to search for controlling strategies is:

  1. Load a Boolean network
  2. Calculate its attractors
  3. Pick an attractor as the target state
  4. Find corresponding controlling strategies with the reprogram_to_trap_spaces function

However, it stopped running possibly due to running out of memory(returning "Killed: 9") when it's searching for attractors with AttractorRepertoire.from_primes

Could you please give some tips to avoid this?

The task I am working on is actually a bit different from the typical workflow above since I already have a target state that I want to reach. So if there is a way to skip calculating all possible attractors like:

  1. Load a Boolean network
  2. Set the target state
  3. Find corresponding controlling strategies with the reprogram_to_trap_spaces function

It will be a great help.

Best,

Bill

jcrozum commented 2 years ago

Hi Bill! In principle, it is possible to avoid calculating the attractors if you know that your target state is in an attractor, but this is not (yet) implemented in an automated way. You can do it "manually", however. Here's a rough sketch of how that code might work:

import pyboolnet as pbn
import pystablemotifs as psm

# primes <--- import as usual
# target <--- a dictionary of states you want to reach, e.g., {'xA':0,'xB':1}; this can be as many or as few variables as you want
stable_motifs = pbn.trap_spaces.compute_trap_spaces(primes, "max")
for motif in stable_motifs:
  if psm.drivers.fixed_implies_implicant(target, motif):
    motif_drivers = psm.drivers.internal_drivers(motif,primes) # other driver search methods are available too
    reduced_primes = psm.reduction.reduce_primes(motif,primes)
    # repeat the above process using reduced_primes instead of primes, and keep track of motif_drivers

We will add implementing a function like this to our to-do list, but unfortunately I can't give you an ETA.

jcrozum commented 2 years ago

One more thing I forgot to mention: you can also try running psm.drivers.internal_drivers(target,primes) directly, but this is a brute force approach. If you are lucky, you might only need a few node overrides to get to the target state, in which case it will go relatively fast. Otherwise it could take a very long time.

yzongy commented 2 years ago

Thanks Jordan!

I was quite lucky to get the results I wanted with psm.drivers.internal_drivers(target,primes)

jcrozum commented 2 years ago

Great!