Skip to content

Commit 8a5a744

Browse files
committed
Make skipping fixations optional when generating a data_matrix from tree sequences.
1 parent d661f16 commit 8a5a744

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

examples/tree_sequence_examples_common.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ matrix_runtime_test(const fwdpp::ts::table_collection &tables,
181181
const std::vector<fwdpp::uint_t> &mcounts)
182182
{
183183
auto dm = fwdpp::ts::generate_data_matrix(tables, samples, mutations, true,
184-
true);
184+
true, false);
185185
auto rs = fwdpp::row_sums(dm);
186186
for (std::size_t i = 0; i < rs.first.size(); ++i)
187187
{
@@ -398,7 +398,7 @@ write_sfs(const options &o, const fwdpp::GSLrng_mt &rng,
398398
s.data(), s.size(), sizeof(fwdpp::ts::TS_NODE_INT));
399399
std::iota(small_sample.begin(), small_sample.end(), 0);
400400
auto dm = fwdpp::ts::generate_data_matrix(tables, small_sample,
401-
mutations, true, false);
401+
mutations, true, false, true);
402402
auto rs = fwdpp::row_sums(dm);
403403
std::vector<int> sfs(small_sample.size() - 1);
404404
for (auto i : rs.first)

fwdpp/ts/generate_data_matrix.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ namespace fwdpp
2020
const std::vector<TS_NODE_INT>& samples,
2121
const mcont_t& mutations,
2222
const bool record_neutral,
23-
const bool record_selected, const double start,
24-
const double stop)
23+
const bool record_selected, const bool skip_fixed,
24+
const double start, const double stop)
2525
/// \todo Document
2626
/// \version 0.7.0 Added to library
2727
/// \version 0.7.1 Change behavior to skip sites fixed in the sample
28-
/// \version 0.7.4 Add [start, stop) arguments
28+
/// \version 0.7.4 Add [start, stop) arguments. Add option to skip fixed variants.
2929
{
3030
if (!(stop > start))
3131
{
@@ -61,7 +61,9 @@ namespace fwdpp
6161
auto tc = tree.leaf_counts[mut->node]
6262
+ tree.preserved_leaf_counts
6363
[mut->node];
64-
if (tc < tree.sample_size)
64+
if (!skip_fixed
65+
|| (skip_fixed
66+
&& tc < tree.sample_size))
6567
{
6668
// Mutation leads to a polymorphism
6769
bool is_neutral
@@ -109,11 +111,11 @@ namespace fwdpp
109111
const std::vector<TS_NODE_INT>& samples,
110112
const mcont_t& mutations,
111113
const bool record_neutral,
112-
const bool record_selected)
114+
const bool record_selected, const bool skip_fixed)
113115
{
114-
return generate_data_matrix(tables, samples, mutations,
115-
record_neutral, record_selected, 0.,
116-
tables.genome_length());
116+
return generate_data_matrix(
117+
tables, samples, mutations, record_neutral, record_selected,
118+
skip_fixed, 0., tables.genome_length());
117119
}
118120

119121
} // namespace ts

0 commit comments

Comments
 (0)