jcrozum / pystablemotifs

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

Initial state of nodes in a network #82

Closed priyambial123 closed 2 years ago

priyambial123 commented 2 years ago

Is the number of source nodes determines the number of attractors?. For example, I have three source nodes in the network (13 nodes) and I have 2 ^ 3 = 8 attractors. In the state transition graph (STG), I could only see the state of the source nodes and state of other nodes are not shown. Is this because of the large number of nodes and hard to create a STG with initial state of all nodes?

Thanks Priya Figure_1_cluster1_prenatal

jcrozum commented 2 years ago

In general, with K source nodes, there will be at least 2^K attractors, though there could be more.

I'm not quite sure what you're asking here though; the figure you've posted is the depiction of the succession diagram, not the STG. In this case, the succession diagram is saying that the dynamics are completely determined by the values of your three source nodes.

It should be possible to generate the entire STG for 13 nodes, though with 8192 states, it will be large and difficult to interpret / work with. Our software does not typically generate full STGs. Instead, it will generate the parts of the STGs that correspond to the attractors, in case you want to more closely study the nature of oscillating attractors.

priyambial123 commented 2 years ago

Thank you. I ran the below code to create state transition graph and the dictionary of attractors was returned. But, no STG was created. Have I missed on something here?

import pystablemotifs as sm
import pyboolnet
import pystablemotifs.export as ex
import networkx as nx
rules='''DCAF5*= not (miR335 or miR124 or miR4507 or miR653 or miR3154 or miR5191 or X1) and (BCL6 or MYC or KDM5A or KDM2B or TCF4)
BCL6*= not (miR124 or miR335)
MYC*= not (miR335)
KDM5A*= not (miR335)
KDM2B*= KDM2B
TCF4*= TCF4
miR335*= BCL6 or MYC or KDM5A
miR4507*= BCL6 or TCF4
miR653*= MYC or KDM5A
miR3154*= MYC
miR5191*= MYC or KDM5A or TCF4
X1*= KDM2B
miR124*= miR124'''

primes = sm.format.create_primes(rules)

max_simulate_size=20
ar=sm.AttractorRepertoire.from_primes(primes, max_simulate_size=max_simulate_size)
ar.summary()

df=ex.attractor_dataframe(ar)
df

for a in ar.attractors:
    if a.n_unfixed == 0: continue # skip steady states
    print(a.attractor_dict)
    nx.draw(a.stg,with_labels=True)  

Output:

C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
C:\Python310\lib\site-packages\pystablemotifs\export.py:357: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
  df=df.append(a.attractor_dict,ignore_index=True).astype(int, errors='ignore').astype(str)
There are 8 attractors.
{'BCL6': 'X', 'DCAF5': 'X', 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 0, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 'X', 'miR5191': 'X', 'miR653': 'X'}

{'BCL6': 'X', 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 1, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 'X', 'miR5191': 'X', 'miR653': 'X'}

{'BCL6': 'X', 'DCAF5': 0, 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 0, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}

{'BCL6': 'X', 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 1, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}

{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 0, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 0, 'miR5191': 'X', 'miR653': 'X'}

{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 1, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 0, 'miR5191': 'X', 'miR653': 'X'}

{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 0, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}

{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 1, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}

{'BCL6': 'X', 'DCAF5': 'X', 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 0, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 'X', 'miR5191': 'X', 'miR653': 'X'}
{'BCL6': 'X', 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 1, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 'X', 'miR5191': 'X', 'miR653': 'X'}
{'BCL6': 'X', 'DCAF5': 0, 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 0, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}
{'BCL6': 'X', 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 1, 'miR124': 0, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}
{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 0, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 0, 'miR5191': 'X', 'miR653': 'X'}
{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 0, 'X1': 1, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 0, 'miR5191': 'X', 'miR653': 'X'}
{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 0, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 0, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}
{'BCL6': 0, 'DCAF5': 0, 'KDM2B': 1, 'KDM5A': 'X', 'MYC': 'X', 'TCF4': 1, 'X1': 1, 'miR124': 1, 'miR3154': 'X', 'miR335': 'X', 'miR4507': 1, 'miR5191': 1, 'miR653': 'X'}
jcrozum commented 2 years ago

It seems to be working, but your code does not display the plots or save the STGs. The code below worked for me:

import pystablemotifs as sm
import pyboolnet
import pystablemotifs.export as ex
import networkx as nx
import matplotlib.pyplot as plt
rules='''DCAF5*= not (miR335 or miR124 or miR4507 or miR653 or miR3154 or miR5191 or X1) and (BCL6 or MYC or KDM5A or KDM2B or TCF4)
BCL6*= not (miR124 or miR335)
MYC*= not (miR335)
KDM5A*= not (miR335)
KDM2B*= KDM2B
TCF4*= TCF4
miR335*= BCL6 or MYC or KDM5A
miR4507*= BCL6 or TCF4
miR653*= MYC or KDM5A
miR3154*= MYC
miR5191*= MYC or KDM5A or TCF4
X1*= KDM2B
miR124*= miR124'''

primes = sm.format.create_primes(rules)

max_simulate_size=20
ar=sm.AttractorRepertoire.from_primes(primes, max_simulate_size=max_simulate_size)
ar.summary()

df=ex.attractor_dataframe(ar)
df

for a in ar.attractors:
    if a.n_unfixed == 0: continue # skip steady states
    print(a.attractor_dict)
    nx.draw(a.stg,with_labels=True)
    plt.show()

This is the same as the code you posted, but I've added import matplotlib.pyplot as plt to the top and plt.show() to the for loop. You might also want to consider saving the graphs to files using the exporting tools in networkx.

It should be noted that the STGs being plotted are subgraphs of the full STG. Specifically, these are the terminal strongly connected components (i.e., attractors) of the full STG.

priyambial123 commented 2 years ago

Thank you, it worked