@@ -128,9 +128,6 @@ void Spectral::reset()
128
128
for (auto item : frs) {
129
129
item->set_window_info (start_variant_idx, end_variant_idx_overlap, end_variant_idx_intended);
130
130
}
131
- for (auto item : frs) {
132
- item->set_window_info (start_variant_idx, end_variant_idx_overlap, end_variant_idx_intended);
133
- }
134
131
// fr->set_window_info(start_variant_idx, end_variant_idx_overlap, end_variant_idx_intended);
135
132
this ->variant_graph .reset (variant_count);
136
133
this ->raw_graph = new double [n * n];
@@ -142,19 +139,27 @@ void Spectral::reset()
142
139
this ->raw_count [i] = 0 ;
143
140
}
144
141
this ->frag_buffer .clear ();
142
+ // read graph
143
+ ViewMap weighted_graph (raw_graph, n, n);
144
+ CViewMap count_graph (raw_count, n, n);
145
145
for (int i = 0 ; i < OPERATIONS.size (); i++) {
146
146
auto item = OPERATIONS[i];
147
147
if (item == MODE_10X)
148
- read_fragment_10x (i);
148
+ read_fragment_10x (i,weighted_graph,count_graph );
149
149
else if (item == MODE_HIC)
150
- read_fragment_hic (i);
150
+ read_fragment_hic (i,weighted_graph,count_graph );
151
151
else if (item == MODE_PE)
152
- read_fragment (i);
152
+ read_fragment (i,weighted_graph,count_graph );
153
153
else if (item == MODE_NANOPORE)
154
- read_fragment_nanopore (i);
154
+ read_fragment_nanopore (i,weighted_graph,count_graph );
155
155
else if (item == MODE_PACBIO)
156
- read_fragment_pacbio (i);
156
+ read_fragment_pacbio (i,weighted_graph,count_graph);
157
+ }
158
+ // cal prob graph
159
+ if (HAS_TENX){
160
+ add_snp_edge_barcode (weighted_graph, count_graph);
157
161
}
162
+ cal_prob_matrix (weighted_graph, count_graph, nullptr , nullptr , nullptr );
158
163
}
159
164
160
165
GMatrix Spectral::slice_submat (std::set<uint > &variants_mat, GMatrix &adj_mat)
@@ -212,23 +217,23 @@ CMatrix Spectral::slice_submat(std::set<uint> &variants_mat, bool t)
212
217
}
213
218
214
219
// read fragment matrix
215
- void Spectral::read_fragment (int frIdx)
220
+ void Spectral::read_fragment (int frIdx, ViewMap &weighted_graph, CViewMap &count_graph )
216
221
{
217
222
auto fr = frs[frIdx];
218
223
// this->frag_buffer.clear();
219
224
Fragment fragment;
220
- ViewMap weighed_graph (raw_graph, n, n);
221
- CViewMap count_graph (raw_count, n, n);
225
+ // ViewMap weighed_graph(raw_graph, n, n);
226
+ // CViewMap count_graph(raw_count, n, n);
222
227
while (fr->get_next_pe (fragment))
223
228
{
224
- add_snp_edge (fragment, weighed_graph , count_graph);
229
+ add_snp_edge (fragment, weighted_graph , count_graph);
225
230
this ->frag_buffer .push_back (fragment);
226
231
fragment.reset ();
227
232
}
228
- cal_prob_matrix (weighed_graph , count_graph, nullptr , nullptr , nullptr );
233
+ // cal_prob_matrix(weighted_graph , count_graph, nullptr, nullptr, nullptr);
229
234
}
230
235
231
- void Spectral::read_fragment_10x (int frIdx)
236
+ void Spectral::read_fragment_10x (int frIdx, ViewMap &weighted_graph, CViewMap &count_graph )
232
237
{
233
238
auto fr = frs[frIdx];
234
239
this ->region_frag_stats ->clear ();
@@ -238,8 +243,8 @@ void Spectral::read_fragment_10x(int frIdx)
238
243
frbed->read_region_frag (this ->chromo_phaser ->chr_name .c_str (), start_pos, end_pos, this ->region_frag_stats );
239
244
// this->barcode_linker->regionFragStats = region_frag_stats;
240
245
Fragment fragment;
241
- ViewMap weighed_graph (raw_graph, n, n);
242
- CViewMap count_graph (raw_count, n, n);
246
+ // ViewMap weighed_graph(raw_graph, n, n);
247
+ // CViewMap count_graph(raw_count, n, n);
243
248
244
249
while (fr->get_next_tenx (fragment))
245
250
{
@@ -250,61 +255,61 @@ void Spectral::read_fragment_10x(int frIdx)
250
255
// add_barcode_info(fragment, barcode_linker);
251
256
fragment.reset ();
252
257
}
253
- add_snp_edge_barcode (weighed_graph , count_graph);
254
- cal_prob_matrix (weighed_graph , count_graph, nullptr , nullptr , nullptr );
258
+ // add_snp_edge_barcode(weighted_graph , count_graph);
259
+ // cal_prob_matrix(weighted_graph , count_graph, nullptr, nullptr, nullptr);
255
260
}
256
261
257
262
// TODO: only unused HiC linker should be stored
258
- void Spectral::read_fragment_hic (int frIdx)
263
+ void Spectral::read_fragment_hic (int frIdx, ViewMap &weighted_graph, CViewMap &count_graph )
259
264
{
260
265
auto fr = frs[frIdx];
261
266
Fragment fragment;
262
267
// this->frag_buffer.clear();
263
- CViewMap count_graph (raw_count, n, n);
264
- ViewMap weighed_graph (raw_graph, n, n);
268
+ // CViewMap count_graph(raw_count, n, n);
269
+ // ViewMap weighed_graph(raw_graph, n, n);
265
270
while (fr->get_next_hic (fragment))
266
271
{
267
- add_snp_edge (fragment, weighed_graph , count_graph);
272
+ add_snp_edge (fragment, weighted_graph , count_graph);
268
273
this ->frag_buffer .push_back (fragment);
269
274
if ( fragment.snps [0 ].first >= phasing_window->prev_window_start )
270
275
if (fragment.insertion_size >= 5000 && fragment.insertion_size <= 40000000 )
271
276
this ->hic_linker_container .add_HiC_info (fragment);
272
277
fragment.reset ();
273
278
}
274
- cal_prob_matrix (weighed_graph , count_graph, nullptr , nullptr , nullptr );
279
+ // cal_prob_matrix(weighted_graph , count_graph, nullptr, nullptr, nullptr);
275
280
}
276
281
277
- void Spectral::read_fragment_nanopore (int frIdx)
282
+ void Spectral::read_fragment_nanopore (int frIdx, ViewMap &weighted_graph, CViewMap &count_graph )
278
283
{
279
284
auto fr = frs[frIdx];
280
285
// this->frag_buffer.clear();
281
286
Fragment fragment;
282
- ViewMap weighed_graph (raw_graph, n, n);
283
- CViewMap count_graph (raw_count, n, n);
287
+ // ViewMap weighed_graph(raw_graph, n, n);
288
+ // CViewMap count_graph(raw_count, n, n);
284
289
while (fr->get_next_nanopore (fragment))
285
290
{
286
- add_snp_edge (fragment, weighed_graph , count_graph);
291
+ add_snp_edge (fragment, weighted_graph , count_graph);
287
292
this ->frag_buffer .push_back (fragment);
288
293
fragment.reset ();
289
294
}
290
295
// this->q_aver = q_sum / this->frag_buffer.size() / 6;
291
- cal_prob_matrix (weighed_graph , count_graph, nullptr , nullptr , nullptr );
296
+ // cal_prob_matrix(weighted_graph , count_graph, nullptr, nullptr, nullptr);
292
297
}
293
298
294
- void Spectral::read_fragment_pacbio (int frIdx)
299
+ void Spectral::read_fragment_pacbio (int frIdx, ViewMap &weighted_graph, CViewMap &count_graph )
295
300
{
296
301
auto fr = frs[frIdx];
297
302
// this->frag_buffer.clear();
298
303
Fragment fragment;
299
- ViewMap weighed_graph (raw_graph, n, n);
300
- CViewMap count_graph (raw_count, n, n);
304
+ // ViewMap weighed_graph(raw_graph, n, n);
305
+ // CViewMap count_graph(raw_count, n, n);
301
306
while (fr->get_next_pacbio (fragment))
302
307
{
303
- add_snp_edge (fragment, weighed_graph , count_graph);
308
+ add_snp_edge (fragment, weighted_graph , count_graph);
304
309
this ->frag_buffer .push_back (fragment);
305
310
fragment.reset ();
306
311
}
307
- cal_prob_matrix (weighed_graph , count_graph, nullptr , nullptr , nullptr );
312
+ // cal_prob_matrix(weighted_graph , count_graph, nullptr, nullptr, nullptr);
308
313
}
309
314
310
315
// aid function
@@ -625,6 +630,8 @@ void Spectral::solver()
625
630
// for each block (variant) in phasing window
626
631
for (auto i : phasing_window->current_window_idxes )
627
632
{
633
+ if (i == 15 )
634
+ int tmp = 9 ;
628
635
mat_idx = phasing_window->var_idx2mat_idx (i);
629
636
if (met_idx.find (mat_idx) == met_idx.end ())
630
637
met_idx.insert (mat_idx);
@@ -667,11 +674,11 @@ void Spectral::solver()
667
674
}
668
675
}
669
676
// TODO, if we need this
670
- if (false )
671
- {
672
- for (auto start_idx: this ->phased_block_starts )
673
- barcode_aware_filter (start_idx.first );
674
- }
677
+ // if (HAS_TENX )
678
+ // {
679
+ // for (auto start_idx: this->phased_block_starts)
680
+ // barcode_aware_filter(start_idx.first);
681
+ // }
675
682
}
676
683
677
684
void Spectral::add_snp_edge_barcode_subroutine (ViewMap &sub_weighted_graph, CViewMap &sub_count_graph, VariantGraph &sub_variant_graph, std::map<uint , int > &subroutine_map, std::map<uint , uint > & subroutine_blk_start)
@@ -880,7 +887,11 @@ void Spectral::find_connected_component_dfs(const Eigen::MatrixBase<Derived> &ad
880
887
std::set<uint > &nxt_vars = sub_variant_graph.graph [var_idx];
881
888
882
889
uint idx = phasing_window->mat_idx2var_idx (subroutine_blk_start[var_idx]);
890
+ // Fixme, block_to_merge equals to starting block, this is a bug
891
+ // if(idx == starting_block->block_id) return;
883
892
ptr_PhasedBlock block_to_merge = phasing_window->blocks [idx];
893
+ if (block_to_merge->block_id == starting_block->block_id )
894
+ return ;
884
895
if (adj_mat (2 * prev_var_idx, 2 * var_idx) > 0 )
885
896
{
886
897
if (block_to_merge->size () == 1 )
@@ -953,7 +964,11 @@ void Spectral::find_connected_component_dfs(const Eigen::MatrixBase<Derived> &ad
953
964
std::set<uint > &nxt_vars = this ->variant_graph .graph [var_idx];
954
965
955
966
uint idx = phasing_window->mat_idx2var_idx (var_idx);
967
+ // Fixme, block_to_merge equals to starting block, this is a bug
968
+ // if(idx == starting_block->block_id) return;
956
969
ptr_PhasedBlock block_to_merge = phasing_window->blocks [idx];
970
+ if (block_to_merge->block_id == starting_block->block_id )
971
+ return ;
957
972
if (adj_mat (2 * prev_var_idx, 2 * var_idx) > 0 )
958
973
{
959
974
if (block_to_merge->size () == 1 )
0 commit comments