michaelmarty / UniDec

Universal Deconvolution of Mass and Ion Mobility Spectra
Other
60 stars 19 forks source link

Error/bug appears using export_params() and autorun() on docker container #88

Closed Dondonn closed 1 year ago

Dondonn commented 1 year ago

Hi, I'm using the latest version of the docker container and trying to get the DScore of the peak using functions export_params() and autorun(). I tested it with the example data "BSA.txt".

The export_params() would return an error "IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed"; when using autorun(), it returns the BSA_peakparam.dat file but the DScore is always with 0.

It works using unidec GUI with Analysis/Export peaks parameters and Data, so it could be an error in the docker file.

Thanks

Using export_params():

import unidec eng=unidec.UniDec() eng.open_file("BSA.txt", "./unidec_test") eng.process_data() eng.run_unidec(silent=True) eng.pick_peaks() eng.get_charge_peaks() eng.export_params() Traceback (most recent call last): File "", line 1, in File "/opt/UniDec/unidec/engine.py", line 759, in export_params ud.dataexport(mztab[:, :, 1], self.config.outfname + "_chargedata.dat") IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed

Using autorun():

Code: import unidec eng=unidec.UniDec() eng.open_file("BSA.txt", "./unidec_test") eng.autorun(auto_peak_width=False, silent = True)

BSA_peakparam.dat: Mass MassStdGuess AvgCharge StdDevCharge Height Area MassCentroid MassFWHM MassErrorBetweenZ DScore 66430.000000 12.679518 14.917080 0.634718 100.000000 100.000000 66425.461394 30.000000 0.000000 0.000000

Using GUI:

BSA_peakparam.dat: Mass MassStdGuess AvgCharge StdDevCharge Height Area MassCentroid MassFWHM MassErrorBetweenZ DScore 66211.000000 14.909570 14.909570 0.610480 1.331321 1.271188 66211.556002 25.000000 0.414636 0.914815 (...)

michaelmarty commented 1 year ago

Hey! The problem is this line: eng.get_charge_peaks(). When you remove that, I think it will work. What were you hoping to get out of the get_charge_peaks function?

It's meant to convert the charge distribution into a pks object for the sake of making a plot in the GUI. Unfortunately, it writes over the actual mass peaks object, which is what is causing the error. This is partially my lazy coding, but it also makes it easier for users to interact with the charge states like they would mass peaks, which is helpful for some GUI operations.

Dondonn commented 1 year ago

Thanks a lot! I was trying to test if I can extract the change from the peak. Another problem I'm facing is the DScore, which always returns 0 in my case when using export_params(). Would you know what could cause this?

michaelmarty commented 1 year ago

It should report the average charge state automatically with export_params() (see AvgCharge). It will also write out the _chargedata.dat for the intensities of each charge state for each peak. More info here: https://github.com/michaelmarty/UniDec/wiki/What-Are-All-Those-File-Outputs-and-How-Can-I-Export-My-Data#peak-detection

Let me see if can track down what's happening with the export params and Dscore

michaelmarty commented 1 year ago

Can you describe the DScore issue more? I'm not seeing it when I test simply repeating the export_params in the GUI

Dondonn commented 1 year ago

It might be an error in the dockerfile. This happens only when using the docker.

Using export_params() with docker terminal:

import unidec eng=unidec.UniDec() eng.open_file("BSA.txt", "./unidec_test") eng.process_data() eng.run_unidec(silent=True) eng.pick_peaks() eng.export_params()

BSA_peakparam.dat: Mass MassStdGuess AvgCharge StdDevCharge Height Area MassCentroid MassFWHM MassErrorBetweenZ DScore 66420.000000 12.737862 14.985720 0.576081 100.000000 100.000000 66420.070452 24.000000 1.223040 0.000000

Using GUI:

BSA_peakparam.dat: Mass MassStdGuess AvgCharge StdDevCharge Height Area MassCentroid MassFWHM MassErrorBetweenZ DScore 66211.000000 14.909570 14.909570 0.610480 1.331321 1.271188 66211.556002 25.000000 0.414636 0.914815 (...)

michaelmarty commented 1 year ago

Great! I think I found the problem. The command line doesn't automatically calculate the DScore, unlike the GUI, which runs it as part of the peak picking. Try adding eng.dscore() after the pick_peak() command. I also just added it automatically to the pick_peak function now, and the Docker should be updated to reflect this. Thanks for finding this!