In [1]:
from cno.io import xcnograph
%pylab inline
matplotlib.rcParams['figure.figsize'] = (12,8)
In [2]:
c = xcnograph.XCNOGraph()
Let us create a random graph that 'looks like' typical graph used in CellNOpt: some ligands, some readouts (transcripts without output:
Note that there are few inhibitors (10% of the edges) and no self loops, which is optional
In [3]:
c.random_cnograph()
In [4]:
c.png
Out[4]:
two edges are selected randomly:
u v u v
| | becomes | |
x y y x
Their edges are swapped.
In [5]:
res = c.swap_edges(100)
In [6]:
c.png
Out[6]:
You can figure out the similarity between the orignal and new graph using for isntance the number of common edges as a measure of similarity.
In [7]:
from cno.io import randomisation
reload(randomisation)
Out[7]:
In [8]:
r = randomisation.RandomGraph()
r.parameters
Out[8]:
In [9]:
# We will (1) create a random graph with default number of nodes
# (2) swap edges 150 times and (3) repeat this 10 times
r.run(100, 100, verbose=False)
In [10]:
r.parameters['nSignals'] = 25
r.parameters['nTrans'] = 8
r.parameters['nStimuli'] = 10
r.parameters['extraNode'] = 80
In [11]:
r.create_graph()
In [12]:
print r.c
In [13]:
r.run(3, 600 , verbose=True)
In [ ]: