From 54850678b4e2e108f5e5197ca82cf8a33f73f5c7 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald Date: Mon, 12 Oct 2020 17:09:15 +0100 Subject: [PATCH 01/13] flipping sign of matrix to match expected --- arsenic/stats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arsenic/stats.py b/arsenic/stats.py index abc9a61..0f6402a 100644 --- a/arsenic/stats.py +++ b/arsenic/stats.py @@ -217,11 +217,11 @@ def form_edge_matrix(g, label, step=None, action=None, node_label=None): for a, b in g.edges: i = node_name_to_index[a] j = node_name_to_index[b] - matrix[i, j] = g.edges[a, b][label] + matrix[j, i] = g.edges[a, b][label] if action == 'symmetrize': - matrix[j, i] = matrix[i, j] + matrix[i, j] = matrix[j, i] elif action == 'antisymmetrize': - matrix[j, i] = -matrix[i, j] + matrix[i, j] = -matrix[j, i] elif action is None: pass else: From 5ea82fe000492a64562d5ed83a5e3dc51b695cab Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald Date: Mon, 12 Oct 2020 17:20:50 +0100 Subject: [PATCH 02/13] change tests to match protocol --- arsenic/tests/test_stats.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arsenic/tests/test_stats.py b/arsenic/tests/test_stats.py index 53ff9db..12fcf05 100644 --- a/arsenic/tests/test_stats.py +++ b/arsenic/tests/test_stats.py @@ -17,7 +17,7 @@ def test_mle_easy(input_absolutes=[-14., -13., -9.]): edges = [(0, 1), (0, 2), (2, 1)] for a, b in edges: noise = np.random.uniform(low=-1., high=1.) - diff = input_absolutes[a] - input_absolutes[b] + noise + diff = input_absolutes[b] - input_absolutes[a] + noise g.add_edge(a, b, f_ij=diff, f_dij=0.5+np.abs(noise)) output_absolutes, C = stats.mle(g, factor='f_ij', node_factor='f_i') @@ -49,7 +49,7 @@ def test_mle_hard(input_absolutes=[-14., -13., -9.]): edges = [(0, 1), (0, 2), (2, 1)] for a, b in edges: noise = np.random.uniform(low=-1., high=1.) - diff = input_absolutes[a] - input_absolutes[b] + noise + diff = input_absolutes[b] - input_absolutes[a] + noise g.add_edge(a, b, f_ij=diff, f_dij=0.5+np.abs(noise)) output_absolutes, C = stats.mle(g, factor='f_ij', node_factor='f_i') @@ -74,8 +74,8 @@ def test_mle_relative(input_absolutes=[-14., -13., -9.]): # Don't assign any absolute values edges = [(0, 1), (0, 2), (2, 1)] for a, b in edges: - noise = np.random.uniform(low=-1., high=1.) - diff = input_absolutes[a] - input_absolutes[b] + noise + noise = np.random.uniform(low=-0.5, high=0.5) + diff = input_absolutes[b] - input_absolutes[a] + noise g.add_edge(a, b, f_ij=diff, f_dij=0.5+np.abs(noise)) output_absolutes, C = stats.mle(g, factor='f_ij', node_factor='f_i') From e357a6faa039dcb5ab9b79ab140ec0f28265a8ec Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Tue, 13 Oct 2020 19:44:46 +0100 Subject: [PATCH 03/13] Update before_install.sh trying to fix miniconda travis thing --- devtools/travis-ci/before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/travis-ci/before_install.sh b/devtools/travis-ci/before_install.sh index cfaa073..bf4b761 100755 --- a/devtools/travis-ci/before_install.sh +++ b/devtools/travis-ci/before_install.sh @@ -15,7 +15,7 @@ else MINICONDA=Miniconda3-latest-Linux-x86_64.sh fi MINICONDA_HOME=$HOME/miniconda -MINICONDA_MD5=$(curl -s https://repo.continuum.io/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *\(.*\)<\/td> */\1/p') +MINICONDA_MD5=$(wget -qO- https://repo.anaconda.com/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *\(.*\)<\/td> */\1/p') wget -q https://repo.continuum.io/miniconda/$MINICONDA if [[ $MINICONDA_MD5 != $(md5sum $MINICONDA | cut -d ' ' -f 1) ]]; then echo "Miniconda MD5 mismatch" From 6a6f45892b83ece08ff97b71d937dc95dd2c13ae Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Tue, 13 Oct 2020 19:52:36 +0100 Subject: [PATCH 04/13] Update test_env.yaml --- devtools/conda-envs/test_env.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 2f26b24..7cb487f 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -9,6 +9,8 @@ dependencies: - pytest - pytest-cov - codecov + - networkx + - numpy # Pip-only installs #- pip: From 46c2a50eb7cd4c959004420c7bdcc61246af1e71 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald Date: Sun, 18 Oct 2020 21:56:36 +0100 Subject: [PATCH 05/13] adding test --- arsenic/tests/test_stats.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arsenic/tests/test_stats.py b/arsenic/tests/test_stats.py index 12fcf05..79e040b 100644 --- a/arsenic/tests/test_stats.py +++ b/arsenic/tests/test_stats.py @@ -89,3 +89,26 @@ def test_mle_relative(input_absolutes=[-14., -13., -9.]): assert np.abs(true_diff - mle_diff) < 1., f"Relative\ difference from MLE: {mle_diff} is too far from the\ input difference, {true_diff}" + + +def test_correlation_positive(): + """ Test that the absolute DG plots have the correct signs, and statistics within reasonable agreement to the example data in `arsenic/data/example.csv` + + """ + from arsenic import plotting, stats, wrangle + import os + print(os.system('pwd')) + fe = wrangle.FEMap('arsenic/data/example.csv') + + x_data = np.asarray([node[1]['exp_DG'] for node in fe.graph.nodes(data=True)]) + y_data = np.asarray([node[1]['calc_DG'] for node in fe.graph.nodes(data=True)]) + xerr = np.asarray([node[1]['exp_dDG'] for node in fe.graph.nodes(data=True)]) + yerr = np.asarray([node[1]['calc_dDG'] for node in fe.graph.nodes(data=True)]) + + s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic='rho') + assert 0 < s['mle'] < 1, 'Correlation must be positive for this data' + + for stat in ['RMSE','MUE','R2','rho']: + s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic=stat) + # all of the statistics for this example is between 0.61 and 0.84 + assert 0.5 < s['mle'] < 0.9, 'Correlation must be positive for this data' From d346a7bc504a9f5de91cf7f5d3f31c4b333ad452 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Sun, 18 Oct 2020 22:17:15 +0100 Subject: [PATCH 06/13] adding matplotlib --- devtools/conda-envs/test_env.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 7cb487f..e85e4c5 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -11,6 +11,7 @@ dependencies: - codecov - networkx - numpy + - matplotlib # Pip-only installs #- pip: From ba100957d60b5ae156f39f5c533dfcaa72122c6f Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Sun, 18 Oct 2020 22:28:41 +0100 Subject: [PATCH 07/13] Update test_env.yaml --- devtools/conda-envs/test_env.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index e85e4c5..b8ce9fb 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -12,6 +12,7 @@ dependencies: - networkx - numpy - matplotlib + - seaborn # Pip-only installs #- pip: From 9c774a7f66a7db7731aa9b7d1d41d23937a200c9 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Sun, 18 Oct 2020 22:36:14 +0100 Subject: [PATCH 08/13] adding dependencies one by one --- devtools/conda-envs/test_env.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index b8ce9fb..90b77af 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -13,6 +13,7 @@ dependencies: - numpy - matplotlib - seaborn + - plotly # Pip-only installs #- pip: From beff2e8308f0260a13f6d8c9e4c075ee7df194d4 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Thu, 29 Oct 2020 18:13:25 +0000 Subject: [PATCH 09/13] Update test_stats.py --- arsenic/tests/test_stats.py | 1 + 1 file changed, 1 insertion(+) diff --git a/arsenic/tests/test_stats.py b/arsenic/tests/test_stats.py index 79e040b..a8a896f 100644 --- a/arsenic/tests/test_stats.py +++ b/arsenic/tests/test_stats.py @@ -98,6 +98,7 @@ def test_correlation_positive(): from arsenic import plotting, stats, wrangle import os print(os.system('pwd')) + import numpy as np fe = wrangle.FEMap('arsenic/data/example.csv') x_data = np.asarray([node[1]['exp_DG'] for node in fe.graph.nodes(data=True)]) From 12f143fef560bc6a2af4f535b04055a7a74fbfc2 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Thu, 29 Oct 2020 19:35:02 +0000 Subject: [PATCH 10/13] Update test_env.yaml --- devtools/conda-envs/test_env.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 90b77af..de740d8 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -14,6 +14,7 @@ dependencies: - matplotlib - seaborn - plotly + - sklearn # Pip-only installs #- pip: From 10357437777429dd58501c0f5231ec2da3db8612 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Thu, 29 Oct 2020 19:46:45 +0000 Subject: [PATCH 11/13] Update test_stats.py --- arsenic/tests/test_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arsenic/tests/test_stats.py b/arsenic/tests/test_stats.py index a8a896f..5593a87 100644 --- a/arsenic/tests/test_stats.py +++ b/arsenic/tests/test_stats.py @@ -112,4 +112,4 @@ def test_correlation_positive(): for stat in ['RMSE','MUE','R2','rho']: s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic=stat) # all of the statistics for this example is between 0.61 and 0.84 - assert 0.5 < s['mle'] < 0.9, 'Correlation must be positive for this data' + assert 0.5 < s['mle'] < 0.9, f"Correlation must be positive for this data. {stat} is {s['mle']}" From 8f388061c1724b1bdec8fca4378914247117a8aa Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Thu, 29 Oct 2020 20:01:26 +0000 Subject: [PATCH 12/13] Update test_env.yaml --- devtools/conda-envs/test_env.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index de740d8..01f6e7c 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -14,9 +14,9 @@ dependencies: - matplotlib - seaborn - plotly - - sklearn + - scikit-learn # Pip-only installs - #- pip: - # - codecov +#- pip: +# - codecov From 3da3270ac6ab802b4d04e46c0a7401bcc29b525f Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald Date: Fri, 30 Oct 2020 14:29:10 +0000 Subject: [PATCH 13/13] fixing test --- arsenic/tests/test_stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arsenic/tests/test_stats.py b/arsenic/tests/test_stats.py index 5593a87..6af55a0 100644 --- a/arsenic/tests/test_stats.py +++ b/arsenic/tests/test_stats.py @@ -109,7 +109,7 @@ def test_correlation_positive(): s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic='rho') assert 0 < s['mle'] < 1, 'Correlation must be positive for this data' - for stat in ['RMSE','MUE','R2','rho']: + for stat in ['R2','rho']: s = stats.bootstrap_statistic(x_data, y_data, xerr, yerr, statistic=stat) # all of the statistics for this example is between 0.61 and 0.84 assert 0.5 < s['mle'] < 0.9, f"Correlation must be positive for this data. {stat} is {s['mle']}"