Skip to content
Merged
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
12 changes: 8 additions & 4 deletions c/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- Rename TSK_TAKE_TABLES to TSK_TAKE_OWNERSHIP.
(:user:`benjeffery`, :issue:`2221`, :pr:`2222`)

- Rename all flags to ``simplify`` for example ``TSK_KEEP_INPUT_ROOTS`` becomes ``TSK_SIMPLIFY_KEEP_INPUT_ROOTS``
(:user:`benjeffery`, :issue:`1720`, :pr:`2226`))


**Features**

- Make dumping of tables and tree sequences to disk a zero-copy operation.
Expand Down Expand Up @@ -199,7 +203,7 @@ Minor bugfix on internal APIs

**Features**

- Add ``TSK_KEEP_UNARY_IN_INDIVIDUALS`` flag to simplify, which allows the user to
- Add ``TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS`` flag to simplify, which allows the user to
keep unary nodes only if they belong to a tabled individual. This is useful for
simplification in forwards simulations (:user:`hyanwong`, :issue:`1113`, :pr:`1119`).

Expand Down Expand Up @@ -249,7 +253,7 @@ Minor bugfix on internal APIs
**Bugfixes**

- :issue:`823` - Fix mutation time error when using
``tsk_table_collection_simplify`` with ``TSK_KEEP_INPUT_ROOTS``
``tsk_table_collection_simplify`` with ``TSK_SIMPLIFY_KEEP_INPUT_ROOTS``
(:user:`petrelharp`, :pr:`823`).

---------------------
Expand All @@ -263,7 +267,7 @@ Minor bugfix on internal APIs

**New features**

- Add a ``TSK_KEEP_INPUT_ROOTS`` option to simplify which, if enabled, adds edges
- Add a ``TSK_SIMPLIFY_KEEP_INPUT_ROOTS`` option to simplify which, if enabled, adds edges
from the MRCAs of samples in the simplified tree sequence back to the roots
in the input tree sequence (:user:`jeromekelleher`, :issue:`775`, :pr:`782`).

Expand Down Expand Up @@ -357,7 +361,7 @@ Minor bugfix on internal APIs
tree sequence. These store arbitrary bytes and are optional in the file format.
(:user: `benjeffery`, :pr:`641`)

- Add the ``TSK_KEEP_UNARY`` option to simplify (:user:`gtsambos`). See :issue:`1`
- Add the ``TSK_SIMPLIFY_KEEP_UNARY`` option to simplify (:user:`gtsambos`). See :issue:`1`
and :pr:`143`.

- Add a ``set_root_threshold`` option to tsk_tree_t which allows us to set the
Expand Down
44 changes: 27 additions & 17 deletions c/tests/test_trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ verify_simplify(tsk_treeseq_t *ts)
const tsk_id_t *sample;
tsk_id_t *node_map = tsk_malloc(tsk_treeseq_get_num_nodes(ts) * sizeof(tsk_id_t));
tsk_treeseq_t subset;
tsk_flags_t options = TSK_FILTER_SITES;
tsk_flags_t options = TSK_SIMPLIFY_FILTER_SITES;

CU_ASSERT_FATAL(node_map != NULL);
sample = tsk_treeseq_get_samples(ts);
Expand Down Expand Up @@ -1118,17 +1118,19 @@ test_simplest_records(void)
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2,
TSK_KEEP_UNARY | TSK_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
TSK_SIMPLIFY_KEEP_UNARY | TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS, &simplified,
NULL);
CU_ASSERT_EQUAL_FATAL(ret, TSK_ERR_KEEP_UNARY_MUTUALLY_EXCLUSIVE);
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2, TSK_KEEP_UNARY, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);
Expand Down Expand Up @@ -1161,13 +1163,14 @@ test_simplest_nonbinary_records(void)
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 4, TSK_KEEP_UNARY, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, sample_ids, 4, TSK_SIMPLIFY_KEEP_UNARY, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(
&ts, sample_ids, 4, TSK_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
&ts, sample_ids, 4, TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);
Expand Down Expand Up @@ -1208,13 +1211,14 @@ test_simplest_unary_records(void)
CU_ASSERT_EQUAL(tsk_treeseq_get_num_trees(&simplified), 1);
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2, TSK_KEEP_UNARY, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_FALSE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
ret = tsk_treeseq_simplify(&ts, sample_ids, 2, 0, &simplified_other, NULL);
Expand Down Expand Up @@ -1285,7 +1289,8 @@ test_simplest_unary_with_individuals(void)
CU_ASSERT_EQUAL(tsk_treeseq_get_num_populations(&ts), 1);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2,
TSK_KEEP_UNARY_IN_INDIVIDUALS | TSK_FILTER_INDIVIDUALS, &simplified, NULL);
TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS | TSK_SIMPLIFY_FILTER_INDIVIDUALS,
&simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(simplified.tables, expected.tables, 0));
tsk_treeseq_free(&simplified);
Expand Down Expand Up @@ -1410,7 +1415,8 @@ test_simplest_degenerate_multiple_root_records(void)
CU_ASSERT_EQUAL(tsk_treeseq_get_num_nodes(&simplified), 2);
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2, TSK_KEEP_UNARY, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);
Expand Down Expand Up @@ -1745,7 +1751,8 @@ test_simplest_holey_tree_sequence(void)
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2, TSK_KEEP_UNARY, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);
Expand Down Expand Up @@ -1837,7 +1844,8 @@ test_simplest_initial_gap_tree_sequence(void)
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);

ret = tsk_treeseq_simplify(&ts, sample_ids, 2, TSK_KEEP_UNARY, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, sample_ids, 2, TSK_SIMPLIFY_KEEP_UNARY, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_TRUE(tsk_table_collection_equals(ts.tables, simplified.tables, 0));
tsk_treeseq_free(&simplified);
Expand Down Expand Up @@ -2899,7 +2907,7 @@ test_simplest_reduce_site_topology(void)
CU_ASSERT_EQUAL_FATAL(tables.sites.num_rows, 1);

ret = tsk_table_collection_simplify(
&tables, samples, 2, TSK_REDUCE_TO_SITE_TOPOLOGY, NULL);
&tables, samples, 2, TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);

CU_ASSERT_EQUAL(tables.nodes.num_rows, 3);
Expand Down Expand Up @@ -3006,7 +3014,7 @@ test_simplest_population_filter(void)
CU_ASSERT_EQUAL(tables.populations.metadata[2], '2');

ret = tsk_table_collection_simplify(
&tables, samples, 2, TSK_FILTER_POPULATIONS, NULL);
&tables, samples, 2, TSK_SIMPLIFY_FILTER_POPULATIONS, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_EQUAL(tables.nodes.num_rows, 2);
CU_ASSERT_EQUAL(tables.nodes.population[0], 0);
Expand Down Expand Up @@ -3044,7 +3052,7 @@ test_simplest_individual_filter(void)
CU_ASSERT_EQUAL(tables.individuals.metadata[2], '2');

ret = tsk_table_collection_simplify(
&tables, samples, 2, TSK_FILTER_INDIVIDUALS, NULL);
&tables, samples, 2, TSK_SIMPLIFY_FILTER_INDIVIDUALS, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_EQUAL(tables.nodes.num_rows, 2);
CU_ASSERT_EQUAL(tables.nodes.individual[0], 0);
Expand Down Expand Up @@ -4165,7 +4173,8 @@ test_single_tree_simplify_keep_input_roots(void)
ret = tsk_treeseq_copy_tables(&ts, &tables, 0);
CU_ASSERT_EQUAL_FATAL(ret, 0);

ret = tsk_table_collection_simplify(&tables, samples, 2, TSK_KEEP_INPUT_ROOTS, NULL);
ret = tsk_table_collection_simplify(
&tables, samples, 2, TSK_SIMPLIFY_KEEP_INPUT_ROOTS, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
CU_ASSERT_EQUAL(tables.nodes.num_rows, 4);
CU_ASSERT_EQUAL(tables.edges.num_rows, 3);
Expand Down Expand Up @@ -4948,7 +4957,8 @@ test_simplify_keep_input_roots_multi_tree(void)
tsk_treeseq_from_text(&ts, 10, paper_ex_nodes, paper_ex_edges, NULL, paper_ex_sites,
paper_ex_mutations, paper_ex_individuals, NULL, 0);
tsk_treeseq_dump(&ts, "tmp.trees", 0);
ret = tsk_treeseq_simplify(&ts, samples, 2, TSK_KEEP_INPUT_ROOTS, &simplified, NULL);
ret = tsk_treeseq_simplify(
&ts, samples, 2, TSK_SIMPLIFY_KEEP_INPUT_ROOTS, &simplified, NULL);
CU_ASSERT_EQUAL_FATAL(ret, 0);
verify_trees(&simplified, num_trees, parents);

Expand Down
38 changes: 20 additions & 18 deletions c/tskit/tables.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* Copyright (c) 2019-2021 Tskit Developers
* Copyright (c) 2019-2022 Tskit Developers
* Copyright (c) 2017-2018 University of Oxford
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -8660,14 +8660,15 @@ simplifier_print_state(simplifier_t *self, FILE *out)
fprintf(out, "--simplifier state--\n");
fprintf(out, "options:\n");
fprintf(out, "\tfilter_unreferenced_sites : %d\n",
!!(self->options & TSK_FILTER_SITES));
!!(self->options & TSK_SIMPLIFY_FILTER_SITES));
fprintf(out, "\treduce_to_site_topology : %d\n",
!!(self->options & TSK_REDUCE_TO_SITE_TOPOLOGY));
fprintf(out, "\tkeep_unary : %d\n", !!(self->options & TSK_KEEP_UNARY));
!!(self->options & TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY));
fprintf(out, "\tkeep_unary : %d\n",
!!(self->options & TSK_SIMPLIFY_KEEP_UNARY));
fprintf(out, "\tkeep_input_roots : %d\n",
!!(self->options & TSK_KEEP_INPUT_ROOTS));
!!(self->options & TSK_SIMPLIFY_KEEP_INPUT_ROOTS));
fprintf(out, "\tkeep_unary_in_individuals : %d\n",
!!(self->options & TSK_KEEP_UNARY_IN_INDIVIDUALS));
!!(self->options & TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS));

fprintf(out, "===\nInput tables\n==\n");
tsk_table_collection_print_state(&self->input_tables, out);
Expand Down Expand Up @@ -8723,7 +8724,7 @@ simplifier_print_state(simplifier_t *self, FILE *out)
fprintf(out, "]\n");
}
}
if (!!(self->options & TSK_REDUCE_TO_SITE_TOPOLOGY)) {
if (!!(self->options & TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY)) {
fprintf(out, "===\nposition_lookup\n==\n");
for (j = 0; j < self->input_tables.sites.num_rows + 2; j++) {
fprintf(out, "%lld\t-> %f\n", (long long) j, self->position_lookup[j]);
Expand Down Expand Up @@ -8883,7 +8884,7 @@ simplifier_record_edge(simplifier_t *self, double left, double right, tsk_id_t c
interval_list_t *tail, *x;
bool skip;

if (!!(self->options & TSK_REDUCE_TO_SITE_TOPOLOGY)) {
if (!!(self->options & TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY)) {
skip = simplifier_map_reduced_coordinates(self, &left, &right);
/* NOTE: we exit early here when reduce_coordindates has told us to
* skip this edge, as it is not visible in the reduced tree sequence */
Expand Down Expand Up @@ -9073,7 +9074,7 @@ simplifier_init(simplifier_t *self, const tsk_id_t *samples, tsk_size_t num_samp
/* TODO Current unit tests require TSK_CHECK_SITE_DUPLICATES but it's
* debateable whether we need it. If we remove, we definitely need explicit
* tests to ensure we're doing sensible things with duplicate sites.
* (Particularly, re TSK_REDUCE_TO_SITE_TOPOLOGY.) */
* (Particularly, re TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY.) */
ret_id = tsk_table_collection_check_integrity(tables,
TSK_CHECK_EDGE_ORDERING | TSK_CHECK_SITE_ORDERING | TSK_CHECK_SITE_DUPLICATES);
if (ret_id != 0) {
Expand Down Expand Up @@ -9141,7 +9142,7 @@ simplifier_init(simplifier_t *self, const tsk_id_t *samples, tsk_size_t num_samp
if (ret != 0) {
goto out;
}
if (!!(self->options & TSK_REDUCE_TO_SITE_TOPOLOGY)) {
if (!!(self->options & TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY)) {
ret = simplifier_init_position_lookup(self);
if (ret != 0) {
goto out;
Expand Down Expand Up @@ -9218,10 +9219,10 @@ simplifier_merge_ancestors(simplifier_t *self, tsk_id_t input_id)

bool is_sample = output_id != TSK_NULL;
bool keep_unary = false;
if (self->options & TSK_KEEP_UNARY) {
if (self->options & TSK_SIMPLIFY_KEEP_UNARY) {
keep_unary = true;
}
if ((self->options & TSK_KEEP_UNARY_IN_INDIVIDUALS)
if ((self->options & TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS)
&& (self->input_tables.nodes.individual[input_id] != TSK_NULL)) {
keep_unary = true;
}
Expand Down Expand Up @@ -9428,7 +9429,7 @@ simplifier_output_sites(simplifier_t *self)
tsk_id_t num_output_mutations, num_output_site_mutations;
tsk_id_t mapped_node;
bool keep_site;
bool filter_sites = !!(self->options & TSK_FILTER_SITES);
bool filter_sites = !!(self->options & TSK_SIMPLIFY_FILTER_SITES);
tsk_site_t site;
tsk_mutation_t mutation;

Expand Down Expand Up @@ -9516,7 +9517,7 @@ simplifier_finalise_references(simplifier_t *self)
= tsk_calloc(num_populations, sizeof(*population_referenced));
tsk_id_t *population_id_map
= tsk_malloc(num_populations * sizeof(*population_id_map));
bool filter_populations = !!(self->options & TSK_FILTER_POPULATIONS);
bool filter_populations = !!(self->options & TSK_SIMPLIFY_FILTER_POPULATIONS);

tsk_individual_t ind;
tsk_id_t ind_id;
Expand All @@ -9526,7 +9527,7 @@ simplifier_finalise_references(simplifier_t *self)
= tsk_calloc(num_individuals, sizeof(*individual_referenced));
tsk_id_t *individual_id_map
= tsk_malloc(num_individuals * sizeof(*individual_id_map));
bool filter_individuals = !!(self->options & TSK_FILTER_INDIVIDUALS);
bool filter_individuals = !!(self->options & TSK_SIMPLIFY_FILTER_INDIVIDUALS);

if (population_referenced == NULL || population_id_map == NULL
|| individual_referenced == NULL || individual_id_map == NULL) {
Expand Down Expand Up @@ -9729,7 +9730,7 @@ simplifier_run(simplifier_t *self, tsk_id_t *node_map)
goto out;
}
}
if (self->options & TSK_KEEP_INPUT_ROOTS) {
if (self->options & TSK_SIMPLIFY_KEEP_INPUT_ROOTS) {
ret = simplifier_insert_input_roots(self);
if (ret != 0) {
goto out;
Expand All @@ -9749,7 +9750,7 @@ simplifier_run(simplifier_t *self, tsk_id_t *node_map)
self->input_tables.nodes.num_rows * sizeof(tsk_id_t));
}
if (self->edge_sort_offset != TSK_NULL) {
tsk_bug_assert(self->options & TSK_KEEP_INPUT_ROOTS);
tsk_bug_assert(self->options & TSK_SIMPLIFY_KEEP_INPUT_ROOTS);
ret = simplifier_sort_edges(self);
if (ret != 0) {
goto out;
Expand Down Expand Up @@ -11446,7 +11447,8 @@ tsk_table_collection_simplify(tsk_table_collection_t *self, const tsk_id_t *samp
/* Avoid calling to simplifier_free with uninit'd memory on error branches */
tsk_memset(&simplifier, 0, sizeof(simplifier_t));

if ((options & TSK_KEEP_UNARY) && (options & TSK_KEEP_UNARY_IN_INDIVIDUALS)) {
if ((options & TSK_SIMPLIFY_KEEP_UNARY)
&& (options & TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS)) {
ret = TSK_ERR_KEEP_UNARY_MUTUALLY_EXCLUSIVE;
goto out;
}
Expand Down
30 changes: 15 additions & 15 deletions c/tskit/tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,13 @@ typedef struct {
/**@} */

/* Flags for simplify() */
#define TSK_FILTER_SITES (1 << 0)
#define TSK_FILTER_POPULATIONS (1 << 1)
#define TSK_FILTER_INDIVIDUALS (1 << 2)
#define TSK_REDUCE_TO_SITE_TOPOLOGY (1 << 3)
#define TSK_KEEP_UNARY (1 << 4)
#define TSK_KEEP_INPUT_ROOTS (1 << 5)
#define TSK_KEEP_UNARY_IN_INDIVIDUALS (1 << 6)
#define TSK_SIMPLIFY_FILTER_SITES (1 << 0)
#define TSK_SIMPLIFY_FILTER_POPULATIONS (1 << 1)
#define TSK_SIMPLIFY_FILTER_INDIVIDUALS (1 << 2)
#define TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY (1 << 3)
#define TSK_SIMPLIFY_KEEP_UNARY (1 << 4)
#define TSK_SIMPLIFY_KEEP_INPUT_ROOTS (1 << 5)
#define TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVIDUALS (1 << 6)

/* Flags for subset() */
#define TSK_NO_CHANGE_POPULATIONS (1 << 0)
Expand Down Expand Up @@ -3859,31 +3859,31 @@ at least ``self->nodes.num_rows`` :c:type:`tsk_id_t` values.
Options can be specified by providing one or more of the following bitwise
flags:

TSK_FILTER_SITES
TSK_SIMPLIFY_FILTER_SITES
Remove sites from the output if there are no mutations that reference them.
TSK_FILTER_POPULATIONS
TSK_SIMPLIFY_FILTER_POPULATIONS
Remove populations from the output if there are no nodes or migrations that
reference them.
TSK_FILTER_INDIVIDUALS
TSK_SIMPLIFY_FILTER_INDIVIDUALS
Remove individuals from the output if there are no nodes that reference them.
TSK_REDUCE_TO_SITE_TOPOLOGY
TSK_SIMPLIFY_REDUCE_TO_SITE_TOPOLOGY
Reduce the topological information in the tables to the minimum necessary to
represent the trees that contain sites. If there are zero sites this will
result in an zero output edges. When the number of sites is greater than zero,
every tree in the output tree sequence will contain at least one site.
For a given site, the topology of the tree containing that site will be
identical (up to node ID remapping) to the topology of the corresponding tree
in the input.
TSK_KEEP_UNARY
TSK_SIMPLIFY_KEEP_UNARY
By default simplify removes unary nodes (i.e., nodes with exactly one child)
along the path from samples to root. If this option is specified such unary
nodes will be preserved in the output.
TSK_KEEP_INPUT_ROOTS
TSK_SIMPLIFY_KEEP_INPUT_ROOTS
By default simplify removes all topology ancestral the MRCAs of the samples.
This option inserts edges from these MRCAs back to the roots of the input
trees.
TSK_KEEP_UNARY_IN_INDIVDUALS
This acts like TSK_KEEP_UNARY (and is mutually exclusive with that flag). It
TSK_SIMPLIFY_KEEP_UNARY_IN_INDIVDUALS
This acts like TSK_SIMPLIFY_KEEP_UNARY (and is mutually exclusive with that flag). It
keeps unary nodes, but only if the unary node is referenced from an individual.

.. note:: Migrations are currently not supported by simplify, and an error will
Expand Down
Loading