6
6
*/
7
7
8
8
#include " celltree.h"
9
+ #include " beta_distribution.hpp"
9
10
10
11
CellTree::CellTree (double K,
11
12
double migrationRate,
@@ -173,7 +174,15 @@ void CellTree::simulateReadCounts()
173
174
174
175
int coverage = poisson (g_rng);
175
176
// divide 2, heterozygous diploid
176
- std::binomial_distribution<> binom (coverage, _freq[s][p][i] / 2 );
177
+ double f = _freq[s][p][i] / 2 ;
178
+ int alpha = std::min (1 , int (f * 100 ));
179
+ int beta = 100 - alpha;
180
+
181
+ sftrabbit::beta_distribution<> beta_dist (alpha, beta);
182
+ double ff = beta_dist (g_rng);
183
+
184
+ // std::binomial_distribution<> binom(coverage, f);
185
+ std::binomial_distribution<> binom (coverage, ff);
177
186
_var[s][p][i] = binom (g_rng);
178
187
_ref[s][p][i] = coverage - _var[s][p][i];
179
188
}
@@ -187,16 +196,20 @@ void CellTree::writeReadCounts(std::ostream& out) const
187
196
{
188
197
int nrMutations = getNrMutations ();
189
198
190
- out << _nrAnatomicalSites << " #anatomical sites" << std::endl;
199
+ out << _nrActiveAnatomicalSites << " #anatomical sites" << std::endl;
191
200
out << _nrSamplesPerAnatomicalSite * _nrAnatomicalSites << " #samples" << std::endl;
192
201
out << nrMutations << " #mutations" << std::endl;
193
202
194
203
out << " #sample_index\t sample_label\t anatomical_site_index\t anatomical_site_label" \
195
204
" \t character_index\t character_label\t ref\t var" << std::endl;
196
205
197
206
char buf[1024 ];
207
+ int activeSiteIndex = 0 ;
198
208
for (int s = 0 ; s < _nrAnatomicalSites; ++s)
199
209
{
210
+ if (!_isActiveAnatomicalSite[s])
211
+ continue ;
212
+
200
213
std::string label_s;
201
214
if (s == 0 )
202
215
{
@@ -210,18 +223,20 @@ void CellTree::writeReadCounts(std::ostream& out) const
210
223
211
224
for (int p = 0 ; p < _nrSamplesPerAnatomicalSite; ++p)
212
225
{
213
- int pp = s * _nrSamplesPerAnatomicalSite + p;
226
+ int pp = activeSiteIndex * _nrSamplesPerAnatomicalSite + p;
214
227
215
228
snprintf (buf, 1024 , " %s_%d" , label_s.c_str (), p);
216
229
std::string label_p = buf;
217
230
for (int i = 0 ; i < nrMutations; ++i)
218
231
{
219
232
out << pp << " \t " << label_p << " \t "
220
- << s << " \t " << label_s << " \t "
233
+ << activeSiteIndex << " \t " << label_s << " \t "
221
234
<< i << " \t " << i << " \t "
222
235
<< _ref[s][p][i] << " \t " << _var[s][p][i] << std::endl;
223
236
}
224
237
}
238
+
239
+ ++activeSiteIndex;
225
240
}
226
241
}
227
242
0 commit comments