Skip to content

Commit

Permalink
Minor clarifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromekelleher committed Sep 2, 2019
1 parent 52e9740 commit 899ebf5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Running inference

.. autofunction:: tsinfer.match_samples

.. todo::
1. Add documentation for path compression here.
.. autofunction:: tsinfer.augment_ancestors

++++++++++
Exceptions
Expand Down
4 changes: 2 additions & 2 deletions docs/inference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ The final phase of a ``tsinfer`` inference consists of a number steps:
for our sample haplotypes through the ancestors. Each copying path
corresponds to a set of tree sequence edges in precisely the same
way as for ancestors, and the path compression algorithm can be equally
applied here.
applied here.


2. As we only use a subset of the available sites for inference
Expand All @@ -213,7 +213,7 @@ The final phase of a ``tsinfer`` inference consists of a number steps:
may be clades of ancestral state samples which would allow us
to encode the data with fewer back mutations.**

3. Remove ancestral paths that do not lead to any of the samples by
3. Remove ancestral paths that do not lead to any of the samples by
`simplifying
<https://tskit.readthedocs.io/en/latest/python-api.html#tskit.TreeSequence.simplify>`_
the final tree sequence. When simplifying, we keep non-branching ("unary")
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Installation
############

Python 3.3 or newer is required for ``tsinfer``. Any Unix-like platform should
Python 3.5 or newer is required for ``tsinfer``. Any Unix-like platform should
work (``tsinfer`` is tested on Linux, OS X, and Windows).

Please use ``pip`` to install,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def finalize_options(self):
"tqdm",
"humanize",
"daiquiri",
"tskit>=0.2.0a3",
"tskit>=0.2.1",
"numcodecs>=0.6",
"zarr>=2.2",
"lmdb",
Expand Down
13 changes: 10 additions & 3 deletions tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class TestZeroInferenceSites(unittest.TestCase):
Tests for the degenerate case in which we have no inference sites.
"""
def verify(self, genotypes):
genotypes = np.array(genotypes, dtype=np.uint8)
genotypes = np.array(genotypes, dtype=np.int8)
m = genotypes.shape[0]
with tsinfer.SampleData(sequence_length=m + 1) as sample_data:
for j in range(m):
Expand Down Expand Up @@ -628,8 +628,7 @@ def verify_inserted_ancestors(self, ts):
tsinfer.check_ancestors_ts(ancestors_ts)
self.assertEqual(ancestor_data.num_sites, ancestors_ts.num_sites)
self.assertEqual(ancestor_data.num_ancestors, ancestors_ts.num_samples)
self.assertTrue(np.array_equal(
ancestors_ts.genotype_matrix(impute_missing_data=True), A))
self.assertTrue(np.array_equal(ancestors_ts.genotype_matrix(), A))
inferred_ts = tsinfer.match_samples(
sample_data, ancestors_ts, engine=engine)
self.assertTrue(np.array_equal(
Expand Down Expand Up @@ -1230,6 +1229,14 @@ def verify(self, ts):
list(ts2.samples()),
list(range(ts2.num_nodes - n, ts2.num_nodes)))

# Check that we're calling simplify with the correct arguments.
ts2 = tsinfer.infer(sd, simplify=False).simplify(keep_unary=True)
t1 = ts1.dump_tables()
t2 = ts2.dump_tables()
t1.provenances.clear()
t2.provenances.clear()
self.assertEqual(t1, t2)

def test_single_tree(self):
ts = msprime.simulate(5, random_seed=1, mutation_rate=2)
self.verify(ts)
Expand Down
6 changes: 3 additions & 3 deletions tsinfer/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def augment_ancestors(
sample_data, ancestors_ts, indexes, num_threads=0, path_compression=True,
extended_checks=False, engine=constants.C_ENGINE, progress_monitor=None):
"""
augment_ancestors(sample_data, ancestors_ts, indexes, num_threads=0,
path_compression=True)
augment_ancestors(sample_data, ancestors_ts, indexes, num_threads=0,\
path_compression=True)
Runs the sample matching :ref:`algorithm <sec_inference_match_samples>`
on the specified :class:`SampleData` instance and ancestors tree sequence,
Expand Down Expand Up @@ -290,7 +290,7 @@ def match_samples(
extended_checks=False, stabilise_node_ordering=False, engine=constants.C_ENGINE,
progress_monitor=None):
"""
match_samples(sample_data, ancestors_ts, num_threads=0, path_compression=True,
match_samples(sample_data, ancestors_ts, num_threads=0, path_compression=True,\
simplify=True)
Runs the sample matching :ref:`algorithm <sec_inference_match_samples>`
Expand Down

0 comments on commit 899ebf5

Please sign in to comment.