aeeckhou / shallowHRD

This method uses shallow Whole Genome Sequencing (sWGS) and the segmentation of a genomic profile to assess the Homologous Recombination Deficiency of a tumor based on the number of Large-scale Genomic Alterations (LGAs).
33 stars 13 forks source link

Logic error in merging segments #13

Closed lbeltrame closed 1 year ago

lbeltrame commented 1 year ago

While studying the code I came across this part:

https://github.com/aeeckhou/shallowHRD/blob/341f0fe0e645757b6596b34de5df5cd194703f9c/shallowHRD_hg19_1.13_QDNAseq_no_chrX.R#L1297

To me it looks like the logic there is swapped, because the final rbind in case the next index is not present in the long segments dataframe the code adds tmp_3mb[c:L_3mb,] instead of stopping like in all other cases with tmp_0.1_3mb[i,8]. This instead present in the subsequent else block, that is when the loop is not yet at the end of the long segments.

If I read this correctly, this code may produce incorrect results here.

aeeckhou commented 1 year ago

Hello,

For me when re-reading my code it seems fine. The condition here is playing with c-1 and c segments, the small segment here if I am not mistaken is after the c-1 segment, before the end of the large segment. Then the end should be the end of the large segment. Again really sorry it's been a long time and the code is quite dense to say the least.

If I would want to test it out, one way would be to print the segments and the final table when it happens in a case, and look at the output and if it makes sense compared to the c-1, c segments and the smal segments concerned.

I hope I understood correctly what you were saying.

Best regards, Alexandre