Boolean Finite State Machine
Bases: object
Builds and plots Network Finite State Machines (NFSMs) from a regulatory
network modelled using Boolean logic functions (see
BooleanNet
).
BoolStateMachine first performs a comprehensive search for stable
equilibrium states of the regulatory network. It then uses pseudo-time simulation,
starting the system off at every equilibrium state and every input signal,
applying a new input signal, and returning the system to the original input signal.
It then detects new equilibrium states occupied by the system after the application
of each input signal perturbation. The input-driven transitions between states are
recorded as the NFSMs of the system.
Attributes:
Name | Type | Description |
---|---|---|
G_states |
MultiDiGraph
|
General NFSM (G-NFSM), where each equilibrium-state of the
regulatory network is a node of the G-NFSM, and labeled directed edges indicate the
input state (as an edge label) inducing a transition between one equilibrium state
and another. This is a networkx MultiDiGraph,
which means parallel edges are allowed to exist and therefore it is possible for different signals to
transition the system between the same two state. |
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
|
__init__(bnet)
Initialize the BoolStateMachine
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bnet
|
BooleanNet
|
An instance of |
required |
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
create_transition_network(states_dict, sig_test_set, solsM_allo, charM_allo, verbose=True, remove_inaccessible_states=False, save_graph_file=None, n_max_steps=10, output_nodes_only=False)
This method builds the Network Finite State Machine by starting the system in different equilibrium states, applying different input signals, and seeing which equilibrium state the system ends up in after a time simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
states_dict
|
dict
|
A dictionary with keys as tuples representing each input state, and values being the equilibrium
state index as the column index of |
required |
sig_test_set
|
list | ndarray
|
An array containing each of the input states (i.e. all binary-node-level combinations of
|
required |
solsM_allo
|
ndarray
|
The matrix of unique equilibrium state solutions, with each solution appearing in columns, and each row representing the node expression level. This is returned by `steady_state_solutions_search'. |
required |
charM_allo
|
ndarray
|
The dynamic characterization of each equilibrium state in solsM, as a linear array of
|
required |
verbose
|
bool
|
Print output while solving ( |
True
|
remove_inaccessible_states
|
bool
|
If there are states in the NFSM that aren't reachable by any other state, remove them? (Don't think this variable currently works). |
False
|
save_graph_file
|
str | None
|
Full directory and filename to save a gml format graph of the resulting G-NFSM. |
None
|
n_max_steps
|
int
|
The maximum number of steps that the Boolean regulatory network solver should use in
determining each eq'm. It is recommended that |
10
|
output_nodes_only
|
bool
|
Define the uniqueness of equilibrium states using only the |
False
|
Returns:
Name | Type | Description |
---|---|---|
transition_edges_set |
set
|
Set containing tuples defining all edges representing transitions of the general-NFSM (G-NFSM).
Each tuple marks the transition from eq'm state i to j under the action of input state k, so (i, j, k).
Eq'm state indices are to the columns of |
perturbation_edges_set |
set
|
Set containing tuples defining all edges representing transitions of the event-driven NFSM (E-NFSM).
Each tuple marks the transition from eq'm state i to j under the action of transiently held input state k,
where the system is returned to the base input state l, so (i, j, k, l).
Eq'm state indices are to the columns of |
GG |
MultiDiGraph
|
The networkx MultiDiGraph object representing the G-NFSM. |
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
|
get_state_distance_matrix(solsM_all)
Returns a matrix representing the L2 norm 'distance' between each state in the array of all possible states.
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
|
plot_input_words_array(sig_test_set, gene_list, figsave=None, cmap=None, save_format='png', figsize=(10, 10))
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
|
plot_sequence_trajectory(c_time, tvectr, phase_inds, matched_states, char_states, gene_plot_inds=None, figsize=(10, 4), state_label_offset=0.02, glyph_zoom=0.15, glyph_alignment=(-0.0, -0.15), fontsize='medium', save_file=None, legend=True)
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
|
plot_state_perturbation_network(pert_edges_set, charM_all, nodes_listo, save_file=None, graph_layout='dot', mono_edge=False, rank='same', constraint=False, concentrate=True, fontsize=18.0, node_colors=None, cmap_str='rainbow_r', transp_str='80')
This method creates a plot of an event-driven network finite state machine (E-NFSM), which has nodes representing equilibrium states of a regulatory network, edges as the transition between two equilibrium states occuring under the application of a transiently applied input signal, and a more 'permanent' input signal to which the system returns after the transient perturbation.
An input state can be associated with several possible equilibrium states if the network has multistability. If this is the case, then the equilibrium state that the system transitions to depends not only on the applied input state, but also the equilibrium state that the system is in to begin with.
To capture this path dependency, here we create a graph with subgraphs, where each subgraph represents the possible states for a held input state (the 'held context' case is represented by the subgraph). In the case of multistability, temporary perturbations to the held input state can result in transitions between the multistable states. The sub-graph indicates which temporarily-applied input signal leads to which state transition via the edge label. Input signal states are represented as integers, where the integer codes for a binary bit string of signal state values; equilibrium states are indexed according to their column index in solsM_all.
The result is saved to an image file on disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes_listo
|
list
|
List of nodes forming the E-NFSM. |
required |
pert_edges_set
|
set
|
List of edges forming the E-NFSM. |
required |
charM_all
|
list | ndarray
|
The dynamic characteristic of all unique equilbrium states. |
required |
save_file
|
str | None
|
The complete directory and filename to save an image of the E-NFSM graph (as 'png' or 'svg'). |
None
|
graph_layout
|
str, default:'dot'
|
Graphviz layout for the graph. |
'dot'
|
mono_edge
|
bool
|
Merge close edges into a single path ( |
False
|
rank
|
str, default:'same'
|
Graphviz rank key. |
'same'
|
constraint
|
bool
|
Graphviz constraint key. |
False
|
concentrate
|
bool
|
Graphviz concentrate key. |
True
|
fontsize
|
float
|
Font size to use on node labels. |
18.0
|
node_colors
|
list | None
|
Values that should be mapped to nodes (e.g. these may be distance from a 'cancer' state). |
None
|
cmap_str
|
str
|
Colormap to use to color the nodes. |
'rainbow_r'
|
transp_str
|
str
|
Transparancy (as a hex value) to lighten the node coloring. |
'80'
|
Returns:
Type | Description |
---|---|
AGraph
|
The pygraphviz object representing the E-NFSM. |
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 |
|
plot_state_transition_network(nodes_listo, edges_list, charM_all, save_file=None, graph_layout='dot', mono_edge=False, rank='same', constraint=False, concentrate=True, fontsize=18.0, node_colors=None, cmap_str='rainbow_r', transp_str='80')
This method creates a plot of a general network finite state machine (G-NFSM), which has nodes representing equilibrium states of a regulatory network, edges as the transition between two equilibrium states, and the label on each edge representing the input state index applied and held to transition the network between the two equilibrium states. The result is saved to an image file on disk.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes_listo
|
list
|
List of nodes forming the G-NFSM. |
required |
edges_list
|
list
|
List of edges forming the G-NFSM. |
required |
charM_all
|
list | ndarray
|
The dynamic characteristic of all unique equilbrium states. |
required |
save_file
|
str | None
|
The complete directory and filename to save an image of the G-NFSM graph (as 'png' or 'svg'). |
None
|
graph_layout
|
str, default:'dot'
|
Graphviz layout for the graph. |
'dot'
|
mono_edge
|
bool
|
Merge close edges into a single path ( |
False
|
rank
|
str, default:'same'
|
Graphviz rank key. |
'same'
|
constraint
|
bool
|
Graphviz constraint key. |
False
|
concentrate
|
bool
|
Graphviz concentrate key. |
True
|
fontsize
|
float
|
Font size to use on node labels. |
18.0
|
node_colors
|
list | None
|
Values that should be mapped to nodes (e.g. these may be distance from a 'cancer' state). |
None
|
cmap_str
|
str
|
Colormap to use to color the nodes. |
'rainbow_r'
|
transp_str
|
str
|
Transparancy (as a hex value) to lighten the node coloring. |
'80'
|
Returns:
Type | Description |
---|---|
AGraph
|
The pygraphviz object representing the G-NFSM. |
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
|
sim_sequence_trajectory(starting_state, solsM_all, inputs_list, sig_test_set, n_seq_steps=20, verbose=True, match_tol=0.1)
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 |
|
steady_state_solutions_search(verbose=True, search_main_nodes_only=False, n_max_steps=20, order_by_distance=False, node_num_max=None, output_nodes_only=False)
Search through all possible (binary valued) combinations of input nodes
(BooleanNet.input_node_inds
) to find and dynamically characterize equilibrium
state of the regulatory network system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose
|
bool
|
Print output while solving ( |
True
|
search_main_nodes_only
|
bool
|
Search only the |
False
|
n_max_steps
|
int
|
The maximum number of steps that the Boolean regulatory network solver should use in
determining each eq'm. It is recommended that |
20
|
order_by_distance
|
bool
|
Order states by increasing distance from the zero state ( |
False
|
node_num_max
|
int | None
|
If |
None
|
output_nodes_only
|
bool
|
Define the uniqueness of equilibrium states using only the |
False
|
Returns:
Name | Type | Description |
---|---|---|
solsM |
ndarray
|
The matrix of unique equilibrium state solutions, with each solution appearing in columns, and each row representing the node expression level. |
charM_all |
ndarray
|
The dynamic characterization of each equilibrium state in solsM, as a linear array of
|
sols_list |
list
|
The list of all (non-unique) equilibrium state solutions in the order that they were found. |
states_dict |
OrderedDict
|
A dictionary with keys as tuples representing each input state, and values being the equilibrium
state index as the column index of |
sig_test_set |
ndarray
|
An array containing each of the input states (i.e. all binary-node-level combinations of
|
Source code in cellnition/science/networks_toolbox/boolean_state_machine.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|