catch for the broken confidence intervals
@@ -873,6 +873,14 @@ class ClockTree(TreeAnc):
from scipy.optimize import minimize_scalar as minimize
pidx = np.argmin(node.marginal_pos_LH.y)
pval = np.min(node.marginal_pos_LH.y)
+
+ # check if the distribution as at least 3 points and that the peak is not either of the two
+ # end points. Otherwise, interpolation objects can be initialized.
+ if node.marginal_pos_LH.y.shape[0]<3 or pidx==0 or pidx==node.marginal_pos_LH.y.shape[0]-1:
+ value_str = "values: " + ','.join([str(x) for x in node.marginal_pos_LH.y])
+ self.logger("get_max_posterior_region: peak on boundary or array too short." + value_str, 1, warn=True)
+ mutation_contribution=None
+ else:
left = interp1d(node.marginal_pos_LH.y[:(pidx+1)]-pval, node.marginal_pos_LH.x[:(pidx+1)],
kind='linear', fill_value=min_max[0], bounds_error=False)
right = interp1d(node.marginal_pos_LH.y[pidx:]-pval, node.marginal_pos_LH.x[pidx:],
