Skip to content

Commit e11cf83

Browse files
committed
ancient samples
1 parent 042562d commit e11cf83

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

tsdate/core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def get_mut_lik_fixed_node(self, edge):
258258

259259
mutations_on_edge = self.mut_edges[edge.id]
260260
child_time = self.ts.node(edge.child).time
261-
assert child_time == 0
261+
#assert child_time == 0
262262
# Temporary hack - we should really take a more precise likelihood
263263
return self._lik(
264264
mutations_on_edge,
@@ -732,10 +732,10 @@ def outside_pass(
732732
if ignore_oldest_root:
733733
if edge.parent == self.ts.num_nodes - 1:
734734
continue
735-
if edge.parent in self.fixednodes:
736-
raise RuntimeError(
737-
"Fixed nodes cannot currently be parents in the TS"
738-
)
735+
#if edge.parent in self.fixednodes:
736+
# raise RuntimeError(
737+
# "Fixed nodes cannot currently be parents in the TS"
738+
# )
739739
# Geometric scaling works exactly for all nodes fixed in graph
740740
# but is an approximation when times are unknown.
741741
spanfrac = edge.span / self.spans[child]
@@ -1066,9 +1066,9 @@ def get_dates(
10661066
:return: tuple(mn_post, posterior, timepoints, eps, nodes_to_date)
10671067
"""
10681068
# Stuff yet to be implemented. These can be deleted once fixed
1069-
for sample in tree_sequence.samples():
1070-
if tree_sequence.node(sample).time != 0:
1071-
raise NotImplementedError("Samples must all be at time 0")
1069+
#for sample in tree_sequence.samples():
1070+
# if tree_sequence.node(sample).time != 0:
1071+
# raise NotImplementedError("Samples must all be at time 0")
10721072
fixed_nodes = set(tree_sequence.samples())
10731073

10741074
# Default to not creating approximate priors unless ts has > 1000 samples

tsdate/prior.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ def __init__(self, tree_sequence, progress=False):
419419

420420
self.ts = tree_sequence
421421
self.sample_node_set = set(self.ts.samples())
422-
if np.any(self.ts.tables.nodes.time[self.ts.samples()] != 0):
423-
raise ValueError(
424-
"The SpansBySamples class needs a tree seq with all samples at time 0"
425-
)
422+
#if np.any(self.ts.tables.nodes.time[self.ts.samples()] != 0):
423+
# raise ValueError(
424+
# "The SpansBySamples class needs a tree seq with all samples at time 0"
425+
# )
426426
self.progress = progress
427427

428428
# We will store the spans in here, and normalize them at the end
@@ -1042,19 +1042,19 @@ def build_grid(
10421042
"Can't set approx_prior_size if approximate_prior is False"
10431043
)
10441044

1045-
contmpr_ts, node_map = util.reduce_to_contemporaneous(tree_sequence)
1046-
if contmpr_ts.num_nodes != tree_sequence.num_nodes:
1047-
raise ValueError(
1048-
"Passed tree sequence is not simplified and/or contains "
1049-
"noncontemporaneous samples"
1050-
)
1051-
span_data = SpansBySamples(contmpr_ts, progress=progress)
1045+
#contmpr_ts, node_map = util.reduce_to_contemporaneous(tree_sequence)
1046+
#if contmpr_ts.num_nodes != tree_sequence.num_nodes:
1047+
# raise ValueError(
1048+
# "Passed tree sequence is not simplified and/or contains "
1049+
# "noncontemporaneous samples"
1050+
# )
1051+
span_data = SpansBySamples(tree_sequence, progress=progress)
10521052

10531053
base_priors = ConditionalCoalescentTimes(
10541054
approx_prior_size, Ne, prior_distribution, progress=progress
10551055
)
10561056

1057-
base_priors.add(contmpr_ts.num_samples, approximate_priors)
1057+
base_priors.add(tree_sequence.num_samples, approximate_priors)
10581058
for total_fixed in span_data.total_fixed_at_0_counts:
10591059
# For missing data: trees vary in total fixed node count => have different priors
10601060
if total_fixed > 0:
@@ -1078,9 +1078,9 @@ def build_grid(
10781078
else:
10791079
raise ValueError("time_slices must be an integer or a numpy array of floats")
10801080

1081-
prior_params_contmpr = base_priors.get_mixture_prior_params(span_data)
1081+
prior_params = base_priors.get_mixture_prior_params(span_data)
10821082
# Map the nodes in the prior params back to the node ids in the original ts
1083-
prior_params = prior_params_contmpr[node_map, :]
1083+
#prior_params = prior_params_contmpr[node_map, :]
10841084
# Set all fixed nodes (i.e. samples) to have 0 variance
10851085
priors = fill_priors(
10861086
prior_params,

0 commit comments

Comments
 (0)