<jupyter_start><jupyter_text>Phenotype Graph Tutorial In this tutorial, I go through how to use `PhenotypeGraphfun.py` and `ReducePhenotypeGraph.py` to construct a Phenotype Graph from a specified Phenotype Pattern, as well as the condensation of the Phenotype Graph. `PhenotypeGraphviz.py` can be used to visulize these graphs, however, this is only useful when the graphs are fairly small.<jupyter_code>import DSGRN
from DSGRN import *
import sys
sys.setrecursionlimit(10**8)
sys.path.insert(0,'/home/elizabeth/Desktop/GIT/dsgrn_acdc/src')

from PGDraw import *
from PhenotypeGraphviz import *
from PhenotypeGraphFun import *
from ReducePhenotypeGraph import *
database = Database("/home/elizabeth/Desktop/ACDC/TFP_test.db") 
network = Network("/home/elizabeth/Desktop/ACDC/TFP_test") 
parameter_graph = ParameterGraph(network)
print(parameter_graph.size())
DrawGraph(network)
PGGraph(database, network) # creates a png of the parameter graph.
database.DrawMorseGraph(2)<jupyter_output><empty_output><jupyter_text>First we need to decide what the path is we are looking for, each step in the path needs to have a fixed point in it that we are looking for. Below, bds00, bds20,... are how we code fixed points in DSGRN. So if you want to find a path that has a parameter graph node with fixed point {0,0} and fixed point {2,0}, you would mark this as a list [bds00, bds20]. Then the entire path is a list of lists that you wish your path to follow. An example of this are in lists `D` and `E` below. This is called the **Phenotype Pattern**.<jupyter_code>bds00 = {"X":0, "Y":0} #FP {0,0}
bds21 = {"X":2, "Y":1} #FP {2,1}
bds11 = {"X":1, "Y":1} #FP {1,1}
bds10 = {"X":1, "Y":0} #FP {1,0}

E = [[bds00, bds21, bds10],[bds00, bds21], [bds00, bds21, bds11]]
paramslist = get_paramslist(database, E, '=')<jupyter_output><empty_output><jupyter_text>The `get_paramslist()` function then finds all of the parameter nodes assosiated to the phenotype pattern. You can either search for Morse Graphs that have ONLY the fixed points in the phenotype pattern ('='), or have AT LEAST the fixed points in the phenotype pattern ('<').<jupyter_code>paramslist<jupyter_output><empty_output><jupyter_text>Next, we create the **Phenotype Graph**, this is a directed subgraph of the parameter graph created by DSGRN.<jupyter_code>edges = get_phenotype_graph(database, paramslist)
edges<jupyter_output><empty_output><jupyter_text>The **condensation** of the Phenotype Graph finds all of the strongly connected components and reduces it according to those groups. Currently, this function returns three objects. The first it the condensation of the Phenotype Graph, the next is the reduction of the parameter list and the last is the strongly connected components.<jupyter_code>[a,b,c] = reduce(edges, paramslist)
a<jupyter_output><empty_output><jupyter_text>We can visulize both the Phenotype Graph and its condensation. The different colors correspond to different layers (i.e, the steps of the Phenotype Pattern). These save as png files.<jupyter_code>PhenotypeGraphviz(database, network, edges, 'coolbeans1')
PhenotypeGraphviz(database, network, a, 'coolbeans2')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09577819785759294, 'fraction_numerical': 0.018588531821046, 'mean_word_length': 6.087053571428571, 'pattern_counts': {'":': 8, '<': 26, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '609084', 'license': 'MIT', 'n_tokens_mistral': 1042, 'n_tokens_neox': 987, 'n_words': 379, 'path': 'notebooks/Phenotype_Graph_Tutorial.ipynb', 'repo_name': 'Eandreas1857/dsgrn_acdc', 'size': '3174'}