deconvolute_peaks throws error when retention_strategy is specified
DarylWM opened this issue · comments
Hi @mobiusklein ,
I've been using deconvolute_peaks which has been fine until I tried to specified a retention strategy, as in the following call:
ms2_deconvoluted_peaks, _ = deconvolute_peaks(ms2_peaks_l, averagine=averagine.peptide, charge_range=(1,5), scorer=scoring.MSDeconVFitter(minimum_score=8, mass_error_tolerance=0.1), error_tolerance=4e-5, truncate_after=0.6, retention_strategy=peak_retention_strategy.TopNRetentionStrategy(n_peaks=50, base_peak_coefficient=0.05, max_mass=850.0))
and it throws this error:
ms2_deconvoluted_peaks, _ = deconvolute_peaks(ms2_peaks_l, averagine=averagine.peptide, charge_range=(1,5), scorer=scoring.MSDeconVFitter(minimum_score=8, mass_error_tolerance=0.1), error_tolerance=4e-5, truncate_after=0.6, retention_strategy=peak_retention_strategy.TopNRetentionStrategy(n_peaks=50, base_peak_coefficient=0.05, max_mass=850.0))
File "/home/ubuntu/anaconda3/envs/py36/lib/python3.6/site-packages/ms_deisotope-0.0.9-py3.6-linux-x86_64.egg/ms_deisotope/deconvolution/api.py", line 155, in deconvolute_peaks
decon.peaklist, peaklist, charge_range, deconvoluted_peaks)
File "/home/ubuntu/anaconda3/envs/py36/lib/python3.6/site-packages/ms_deisotope-0.0.9-py3.6-linux-x86_64.egg/ms_deisotope/deconvolution/peak_retention_strategy.py", line 112, in __call__
return self.retain_peaks(peaklist, original_peaklist, charge_range)
File "/home/ubuntu/anaconda3/envs/py36/lib/python3.6/site-packages/ms_deisotope-0.0.9-py3.6-linux-x86_64.egg/ms_deisotope/deconvolution/peak_retention_strategy.py", line 174, in retain_peaks
base_peak = max([peak.intensity for peak in base_peak_sequence])
File "/home/ubuntu/anaconda3/envs/py36/lib/python3.6/site-packages/ms_deisotope-0.0.9-py3.6-linux-x86_64.egg/ms_deisotope/deconvolution/peak_retention_strategy.py", line 174, in <listcomp>
base_peak = max([peak.intensity for peak in base_peak_sequence])
AttributeError: 'tuple' object has no attribute 'intensity'
I'm wondering whether this is because I'm using a list of (mz,intensity) tuples and the prepare_peaklist coercion didn't work properly, and when the retention strategy tries to access peak.intensity it's not there?
It's happy if ms2_peaks_l is a list of simple_peak.
The peaklist
parameter was only being transformed into the expected type once inside the Deconvoluter
instance, but was written assuming the type of peaklist
was already forced to be an Iterable
of FittedPeak
s.
I've changed the coercion point to be much earlier in the process in 7ca3980 so this won't be an issue.
The truncation parameter you're using will lose out on the multiply charged peaks smaller than 950 Da. What type of instrument are you using? I've found that truncate_after=0.8
is suitable for most MS2 data. Additionally, because this global truncation parameter is only good for data where the range of isotopic pattern widths is consistently the same, I've implemented a new incremental truncation algorithm which considers all theoretical isotopomers with peaks between truncate_after
to truncate_to
% of the total theoretical signal:
In [12]: ms_deisotope.peptide.isotopic_cluster(400, charge=2)
Out[12]: TheoreticalIsotopicPattern(400.0000, charge=2, (0.650, 0.277, 0.072))
In [13]: tid = ms_deisotope.peptide.isotopic_cluster(400, charge=2)
In [14]: tid.incremental_truncation(0.8)
Out[14]:
[TheoreticalIsotopicPattern(400.0000, charge=2, (0.650, 0.277, 0.072)),
TheoreticalIsotopicPattern(400.0000, charge=2, (0.701, 0.299)),
TheoreticalIsotopicPattern(400.0000, charge=2, (1.000))]
You can enable this behavior by passing the truncate_to
parameter to deconvolute_peaks
. I also suggest you try use_quick_charge=True
, which will speed up the process markedly. At some point in the future, use_quick_charge
will be True
by default.
Thanks @mobiusklein for your reply and the recent repo pushes. I'm using deconvolute_peaks on data from a Bruker timsTOF Pro for some custom feature detection. I'll give your suggestions a try.
Hi @mobiusklein - I'm not seeing how to use the incremental truncation feature. truncate_to doesn't seem to be a parameter on deconvolute_peaks?
Is this issue resolved?
Yes, thank you.