Skip to content

Commit 7862ffa

Browse files
work on sensitivity analysis
1 parent 1c3ec99 commit 7862ffa

File tree

4 files changed

+45
-46
lines changed

4 files changed

+45
-46
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ dependencies = [
4848
"matplotlib",
4949
"pydantic",
5050
# dependencies
51-
"diskcache>=5.6.3",
52-
# "dill>=0.4.0",
51+
"dill>=0.4.0",
5352
"SAlib>=1.5.2",
5453
"petab>=0.7.0",
5554
# "tables>=3.10.2",

src/sbmlsim/sensitivity/analysis.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,3 @@ def run_sensitivity_analysis(
825825
fig_path=sa.results_path / f"sampling_sensitivity_N{sa.N}.png",
826826
)
827827

828-
829-
830-
)

src/sbmlsim/sensitivity/plots.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -117,45 +117,4 @@ def calculate_subset(df, cutoff=0.01) -> pd.DataFrame:
117117
plt.show()
118118

119119

120-
def sobol_barplot(
121-
S1, ST, S1_conf, ST_conf,
122-
parameter_labels: dict[str, str],
123-
fig_path: Optional[Path] = None,
124-
title: Optional[str] = None,
125-
ymax: float = 1.1,
126-
ymin: float = -0.1,
127-
):
128-
# width
129-
figsize = (15, 3)
130-
label_fontsize = 15
131-
132-
categories: list[str] = list(parameter_labels.values())
133-
f, ax = plt.subplots(figsize=figsize)
134-
135-
ax.bar(categories, ST, label='ST',
136-
color="tab:orange",
137-
alpha=1.0,
138-
edgecolor="black",
139-
yerr=ST_conf, capsize=5
140-
)
141-
142-
ax.bar(categories, S1, label='S1', color="tab:blue",
143-
edgecolor="black", yerr=S1_conf, capsize=5)
144-
145-
146-
# ax.set_xlabel('Parameter', fontsize=label_fontsize, fontweight="bold")
147-
ax.set_ylabel('Sobol Index', fontsize=label_fontsize, fontweight="bold")
148-
ax.set_ylim(bottom=ymin, top=ymax)
149-
ax.grid(True, axis="y")
150-
ax.tick_params(axis='x', labelrotation=90)
151-
# ax.tick_params(axis='x', labelweight='bold')
152-
ax.legend()
153-
154-
if title:
155-
plt.suptitle(title, fontsize=20, fontweight="bold")
156-
157-
if fig_path:
158-
plt.savefig(fig_path, dpi=300, bbox_inches="tight")
159-
plt.show()
160-
161120

src/sbmlsim/sensitivity/sobol.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import numpy as np
88
import xarray as xr
99

10+
1011
import SALib
1112
from SALib import ProblemSpec
1213
from SALib.sample import saltelli
@@ -160,3 +161,46 @@ def plot_sobol_indices(
160161
parameter_labels=parameter_labels,
161162
ymax=np.max([1.05, ymax]),
162163
ymin=np.min([-0.05, ymin]),
164+
)
165+
166+
def sobol_barplot(
167+
S1, ST, S1_conf, ST_conf,
168+
parameter_labels: dict[str, str],
169+
fig_path: Optional[Path] = None,
170+
title: Optional[str] = None,
171+
ymax: float = 1.1,
172+
ymin: float = -0.1,
173+
):
174+
# width
175+
figsize = (15, 3)
176+
label_fontsize = 15
177+
178+
categories: list[str] = list(parameter_labels.values())
179+
f, ax = plt.subplots(figsize=figsize)
180+
181+
ax.bar(categories, ST, label='ST',
182+
color="tab:orange",
183+
alpha=1.0,
184+
edgecolor="black",
185+
yerr=ST_conf, capsize=5
186+
)
187+
188+
ax.bar(categories, S1, label='S1', color="tab:blue",
189+
edgecolor="black", yerr=S1_conf, capsize=5)
190+
191+
192+
# ax.set_xlabel('Parameter', fontsize=label_fontsize, fontweight="bold")
193+
ax.set_ylabel('Sobol Index', fontsize=label_fontsize, fontweight="bold")
194+
ax.set_ylim(bottom=ymin, top=ymax)
195+
ax.grid(True, axis="y")
196+
ax.tick_params(axis='x', labelrotation=90)
197+
# ax.tick_params(axis='x', labelweight='bold')
198+
ax.legend()
199+
200+
if title:
201+
plt.suptitle(title, fontsize=20, fontweight="bold")
202+
203+
if fig_path:
204+
plt.savefig(fig_path, dpi=300, bbox_inches="tight")
205+
plt.show()
206+

0 commit comments

Comments
 (0)