LongQC icon indicating copy to clipboard operation
LongQC copied to clipboard

ValueError when mode_logn_main is nan

Open husensofteng opened this issue 6 months ago • 3 comments

Hi,

In a sample with very few reads, I got the following error in the calc_xome_size function caused by https://github.com/yfukasawa/LongQC/blob/d55acc1b9911fe795c4efe9f15eee8c51581cc73/lq_coverage.py#L375

ValueError: cannot convert float NaN to integer

As a quick fix, I added a try/exception statement to use self.mean_main instead. I wonder if this is a reasobable approach here?

Proposed change:

try:
    m_size = int((throughput * (1.0 - self.unmapped_frac_med)) / self.mode_logn_main)
except ValueError:
    m_size = int((throughput * (1.0 - self.unmapped_frac_med)) / self.mean_main)

husensofteng avatar Dec 19 '23 15:12 husensofteng

Hi @husensofteng,

Thank you for reporting and your suggestion. Yes, I think it is reasonable and has no issue at all. I didn't expect NaN, but indeed it is possible... Thanks for catching this!

Y.

yfukasawa avatar Dec 20 '23 08:12 yfukasawa

Hi! is it possible to implement this approach for next version? Thank you in advance!

eprdz avatar Feb 15 '24 09:02 eprdz

Hi @eprdz, Thanks for your reminder! yes, absolutely. Y.

yfukasawa avatar Feb 16 '24 06:02 yfukasawa