Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions scripts/s03_make_figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def agg_result(

# %% ar-dhm
fig_path = FIG_PATH_PN / "ar-dhm.svg"
fig_w, fig_h = 6.8, 2
fig_w, fig_h = 6.2, 1.8
with sns.axes_style("white"):
fig, axs = plt.subplots(1, 2, figsize=(fig_w, fig_h))
end = 60
Expand Down Expand Up @@ -506,7 +506,9 @@ def agg_result(
axs[iplt].set_xlabel("Timesteps")
fig.tight_layout()
fig.legend(
loc="center left", bbox_to_anchor=(1.01, 0.5), bbox_transform=axs[-1].transAxes
loc="lower center",
bbox_to_anchor=(0.5, 0.95),
ncol=3,
)
fig.savefig(fig_path, bbox_inches="tight")

Expand Down Expand Up @@ -539,7 +541,7 @@ def AR_scatter(
fig_path = FIG_PATH_PN / "ar-full.svg"
resdf = load_agg_result(IN_MET_PATH / "test_demo_solve_fit_h_num")
ressub = (
resdf.query("taus == '(6, 1)' & upsamp < 5 & rand_seed == 2")
resdf.query("taus == '(6, 1)' & upsamp == 1 & rand_seed == 2")
.astype({"upsamp": int})
.copy()
)
Expand All @@ -555,9 +557,7 @@ def AR_scatter(
"solve_fit": "InDeCa",
"solve_fit-all": "InDeCa /w \nshared kernel",
}
g = sns.FacetGrid(
ressub, row="upsamp", col="ns_lev", height=1.5, aspect=1.15, margin_titles=True
)
g = sns.FacetGrid(ressub, col="ns_lev", height=1.7, aspect=1, margin_titles=True)
g.map_dataframe(
AR_scatter,
x="dhm0",
Expand All @@ -577,12 +577,12 @@ def AR_scatter(
frameon=RC_PARAM["legend.frameon"],
fancybox=RC_PARAM["legend.fancybox"],
framealpha=RC_PARAM["legend.framealpha"],
bbox_to_anchor=(1.02, 0.5),
bbox_to_anchor=(0.5, 1.06),
ncol=4,
)
g.set_xlabels(r"$\text{DHM}_r$ (timesteps)")
g.set_ylabels(r"$\text{DHM}_d$" + "\n(timesteps)")
g.set_titles(
row_template="Upsampling $k$: {row_name}",
col_template="Noise level (A.U.): {col_name}",
)
for lab in g._legend.texts:
Expand Down
14 changes: 8 additions & 6 deletions src/indeca/core/deconv/deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ def __init__(
backend: str = "osqp",
nthres: int = 1000,
err_weighting: str = None,
wt_trunc_thres: float = 1e-2,
wt_trunc_thres: float = None,
masking_radius: int = None,
pks_polish: bool = True,
th_min: float = 0,
th_max: float = 1,
density_thres: float = None,
ncons_thres: int = None,
min_rel_scl: float = "auto",
min_rel_scl: float = None,
max_iter_l0: int = 30,
max_iter_penal: int = 500,
max_iter_scal: int = 50,
Expand Down Expand Up @@ -484,15 +484,17 @@ def update(
A_before = self.A.copy()
self._update_A()
assert self.A.shape == A_before.shape
assert (self.A.nonzero()[0] == A_before.nonzero()[0]).all()
assert (self.A.nonzero()[1] == A_before.nonzero()[1]).all()
if not setup_prob:
assert (self.A.nonzero()[0] == A_before.nonzero()[0]).all()
assert (self.A.nonzero()[1] == A_before.nonzero()[1]).all()
updt_A = True
if any((scale is not None, scale_mul is not None, updt_HG, updt_P)):
P_before = self.P.copy()
self._update_P()
assert self.P.shape == P_before.shape
assert (self.P.nonzero()[0] == P_before.nonzero()[0]).all()
assert (self.P.nonzero()[1] == P_before.nonzero()[1]).all()
if not setup_prob:
assert (self.P.nonzero()[0] == P_before.nonzero()[0]).all()
assert (self.P.nonzero()[1] == P_before.nonzero()[1]).all()
updt_P = True
if any(
(
Expand Down
1 change: 0 additions & 1 deletion src/indeca/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ def pipeline_bin(
opt_idx = metric_df.loc[
metric_df[metric_df["cell"] == icell]["obj"].idxmin(), "iter"
]
opt_idx = -1
opt_C[icell, :] = C_ls[opt_idx][icell, :]
opt_S[icell, :] = S_ls[opt_idx][icell, :]
C_ls.append(opt_C)
Expand Down
6 changes: 5 additions & 1 deletion tests/regression/test_deconv_thres.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ def test_solve_thres(
)
s_direct = intm[0]
s_bin = s_bin.astype(float)
ttol = max(upsamp_y / upsamp, upsamp, upsamp_y)
mdist, f1, precs, recall = assignment_distance(
s_ref=s_org, s_slv=s_bin, tdist_thres=5, include_range=(0, len(s_org) - 5)
s_ref=s_org,
s_slv=s_bin,
tdist_thres=ttol,
include_range=(0, len(s_org) - max(int(ttol), 5)),
)
# plotting
fig = go.Figure()
Expand Down
13 changes: 10 additions & 3 deletions tests/validation/test_deconv_realds.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ def test_demo_solve_scale_realds(
err_weighting=err_weighting,
use_base=True,
)
opt_s, opt_c, cur_scl, cur_obj, cur_penal, iterdf = deconv.solve_scale(
return_met=True, obj_crit=obj_crit
)
(
opt_s,
opt_c,
cur_scl,
cur_obj,
err_rel,
nnz,
cur_penal,
iterdf,
) = deconv.solve_scale(return_met=True, obj_crit=obj_crit)
deconv.update(update_weighting=True)
err_wt = deconv.err_wt.squeeze()
deconv.update(update_weighting=True, clear_weighting=True, scale=1)
Expand Down
Loading