Skip to content

Commit c31a5aa

Browse files
committed
[core] misc bug fixes
1 parent 9a5080e commit c31a5aa

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

smcpp/_smcpp.pyx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ cdef class _PyInferenceManager:
170170
self._im.setRho(rho)
171171

172172
def E_step(self, forward_backward_only=False):
173+
if None in (self.theta, self.rho):
174+
raise RuntimeError("theta and rho must be set")
173175
cdef bool fbOnly = forward_backward_only
174176
with nogil:
175177
self._im.Estep(fbOnly)

smcpp/commands/posterior.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def main(self, args):
9696
im = _smcpp.PyTwoPopInferenceManager(
9797
*n, *a, all_obs, hidden_states, contig.key, args.polarization_error)
9898
im.theta = j['theta']
99+
im.rho = j['rho']
99100
im.save_gamma = True
100101
im.model = m
101102
im.E_step()
@@ -111,6 +112,7 @@ def main(self, args):
111112
kwargs.update({path + "_sites": obs[:, 0] for path, obs in zip(args.data, all_obs)})
112113
np.savez_compressed(args.output, hidden_states=hidden_states, **kwargs)
113114
if args.heatmap:
115+
obs = all_obs[0]
114116
if len(args.data) > 1:
115117
logger.error("--heatmap is only supported for one data set")
116118
sys.exit(1)

src/conditioned_sfs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ std::vector<Matrix<T> > incorporate_theta(const std::vector<Matrix<T> > &csfs, d
104104
std::vector<Matrix<T> > ret(csfs.size());
105105
for (unsigned int i = 0; i < csfs.size(); ++i)
106106
{
107+
assert(csfs[i](0, 0) == 0.);
108+
assert(csfs[i](2, n) == 0.);
107109
T tauh = csfs[i].sum();
108110
if (toDouble(tauh) > 1.0 / theta)
109111
throw improper_sfs_exception();
@@ -112,7 +114,8 @@ std::vector<Matrix<T> > incorporate_theta(const std::vector<Matrix<T> > &csfs, d
112114
CHECK_NAN(tauh);
113115
ret[i] = csfs[i] * -expm1(-theta * tauh) / tauh;
114116
CHECK_NAN(ret[i]);
115-
} catch (std::runtime_error)
117+
}
118+
catch (std::runtime_error)
116119
{
117120
std::cout << i << std::endl << csfs[i].template cast<double>() << std::endl;
118121
std::cout << tauh << std::endl;

src/inference_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void NPopInferenceManager<P>::recompute_emission_probs()
422422
}
423423
else
424424
{
425-
e2(m, 1) = 2. * theta * avg_ct.at(m);
425+
e2(m, 1) = -expm1(-2. * theta * avg_ct.at(m));
426426
e2(m, 0) = 1. - e2(m, 1);
427427
}
428428
// CHECK_NAN(e2(m, 1));

0 commit comments

Comments
 (0)