CASCI-lab / CANA

CANAlization: Control & Redundancy in Boolean Networks
https://casci-lab.github.io/CANA/
MIT License
22 stars 15 forks source link

Add c-sensitivity function, Derrida value based on c-sensitivy #3

Closed xuan-w closed 7 years ago

xuan-w commented 7 years ago

I have moved some of my code from Alex' repo to here and adjust them to adapt to CANA's data structure. Hope this is useful 1, add c-sensitivity calculation for BooleanNode 2, add an option to BooleanNetwork.derrida_curve, which will use c-sensitivity to estimate the Derrida value (of course in this function they are normalized by Nnode) 3, some functions in utils.py

citation: Kadelka, Claus, Jack Kuipers, and Reinhard Laubenbacher. "The influence of canalization on the robustness of Boolean networks." Physica D: Nonlinear Phenomena (2017).

I have tested them. The two way of Derrida value estimation fit well.

from cana.datasets import bio mq=bio.DROSOPHILA() print(mq.derrida_curve(nsamples=100)[1]) print(mq.derrida_curve(method='sensitivity')[1])

[ 0.06058824 0.11823529 0.17176471 0.22235294 0.26470588 0.31294118 0.38117647 0.43823529 0.44705882 0.49705882 0.52764706 0.57470588 0.61176471 0.66117647 0.67117647 0.70470588 0.73941176] [ 0.05968858 0.11656574 0.17082612 0.222652 0.2722133 0.31966757 0.36516003 0.40882353 0.45077855 0.49113322 0.52998332 0.56741226 0.6034911 0.63827855 0.67182093 0.70415225 0.73529412]

feel free to change function name

rionbr commented 7 years ago

Hey @xuan-w , great work! I'm really happy this package is getting pulls and is growing. Before I merge these, can I ask you to add some '/tests' and a '/tutorial' to the c-sensitivity/derrida curve? Take a look at the tests already there (it uses nosetest) and the tutorials I've included. Cheers! :)

rionbr commented 7 years ago

Also, feel free to update the /docs/ if you want (it's a nice learning process). The citation goes inside /docs/source/refs.bib Then you can cite it in the docstring as, for example, :cite:`Kadelka:2017`

xuan-w commented 7 years ago

docstring updated. Tests added for c-sensitivity I have added another function isclose() to utils.py, since it is dangerous to compare two float numbers. some bugs are fixed in other files. I am not quite sure about where to put those tutorial. Since I can't find a tutorial file using Derrida curve.

xuan-w commented 7 years ago

It turns out that push a new commit will update the pull request automatically!

rionbr commented 7 years ago

Awesome work Xuan! I am merging these changes. There is not a tutorial on Derrida curve, but you are welcome to create one if you want ;)