shuzhao-li-lab / asari

asari, metabolomics data preprocessing
Other
38 stars 9 forks source link

interpolated ref RT producing infinity #54

Closed shuzhao-li closed 1 year ago

shuzhao-li commented 1 year ago
$ time python3 -m asari.main process --input /Users/lish/data/VAX005/C18pos --output /Users/lish/data/VAX005/asaripos 

~~~~~~~ Hello from Asari (1.11.6) ~~~~~~~~~

Working on ~~ /Users/lish/data/VAX005/C18pos ~~ 

batch11_VT_131011_119 64
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/lish/tools/asari/asari/main.py", line 181, in <module>
    main(PARAMETERS)
  File "/Users/lish/tools/asari/asari/main.py", line 139, in main
    __run_process__(parameters, args)
  File "/Users/lish/tools/asari/asari/main.py", line 52, in __run_process__
    process_project( list_input_files,  parameters )
  File "/Users/lish/tools/asari/asari/workflow.py", line 85, in process_project
    EE.process_all()
  File "/Users/lish/tools/asari/asari/experiment.py", line 144, in process_all
    self.CMAP.build_composite_tracks()
  File "/Users/lish/tools/asari/asari/constructors.py", line 445, in build_composite_tracks
    self.calibrate_sample_RT(SM, list_mass_tracks, 
  File "/Users/lish/tools/asari/asari/constructors.py", line 557, in calibrate_sample_RT
    sample.rt_cal_dict, sample.reverse_rt_cal_dict = calibration_fuction( 
  File "/Users/lish/tools/asari/asari/chromatograms.py", line 377, in rt_lowess_calibration
    ref_interpolated = [int(round(ii)) for ii in ref_interpolated]
  File "/Users/lish/tools/asari/asari/chromatograms.py", line 377, in <listcomp>
    ref_interpolated = [int(round(ii)) for ii in ref_interpolated]
OverflowError: cannot convert float infinity to integer
shuzhao-li commented 1 year ago

Funny no error in v1.11.4

:asari-metabolomics-1.11.4 lish$ time python3 -m asari.main process --input /Users/lish/data/VAX005/C18pos --output /Users/lish/data/VAX005/asaripos 

~~~~~~~ Hello from Asari (1.11.4) ~~~~~~~~~

Working on ~~ /Users/lish/data/VAX005/C18pos ~~ 

 ~~~~~~ Got 11744 khipus, with 30262 features ~~~~~~~ 

Annotation of 69314 Empirical compounds was written to /Users/lish/data/VAX005/asaripos_asari_project_7793041/Feature_annotation.tsv.

Feature table (84042 x 1204) was written to /Users/lish/data/VAX005/asaripos_asari_project_7793041/export/full_Feature_table.tsv.
Filtered Feature table (16812 x 1204) was written to /Users/lish/data/VAX005/asaripos_asari_project_7793041/preferred_Feature_table.tsv.

Unique compound table (13417 x 1204) was written to /Users/lish/data/VAX005/asaripos_asari_project_7793041/export/unique_compound__Feature_table.tsv.

Removing temporary pickle files...

real    53m53.150s
user    114m57.110s
sys 2m37.132s
jmmitc06 commented 1 year ago

Okay, I think there are at least two issues here.

First, I made the assumption that the default value of iter was 1 for lowess. Upon reviewing the source code for statsmodels.nonparametric.smoothers_lowess, that value should be 3. I will fix that now in default parameters.

Second, since we are passing the fraction parameter to lowess, the subset of peaks selected for a regression may not be the same between runs. So the error could be intermittent too.

jmmitc06 commented 1 year ago

Since reverting the code fixed the issue and the default argument has been updated and this issue has not recurred I'm going to close the issue.