Combined scans #20
Replies: 1 comment 1 reply
-
Hello, This is relatively straight-forward to do, depending upon how much metadata you want to carry forwards or how much other processing you want to do along the way. You can merge scans together using import ms_deisotope
reader = ms_deisotope.MSFileLoader("path/to/file")
bin_size = 10
half_size = bin_size // 2
mz_resolution = 0.001
ms1_buffer = []
msn_buffer = []
for precursor, products in enumerate(reader):
if len(ms1_buffer) == bin_size :
ref_scan = ms1_buffer[0]
merged_scan = ref_scan.average_with(ms1_buffer[1:], mz_resolution)
# if you want to use the sum instead of the mean
merged_scan.arrays *= bin_size
do_something(merged_scan, msn_buffer)
ms1_buffer = ms1_buffer[half_size:]
msn_buffer = []
ms1_buffer.append(precursor)
msn_buffer.extend(products)
if ms1_buffer:
ref_scan = ms1_buffer[0]
merged_scan = ref_scan.average_with(ms1_buffer[1:], mz_resolution)
# if you want to use the sum instead of the mean
merged_scan.arrays *= bin_size
do_something(merged_scan, msn_buffer)
ms1_buffer = ms1_buffer[half_size:]
msn_buffer = [] If your MS1 spectra were acquired pre-centroided, this will reprofile them automatically, so you may want to re-pick peaks afterwards. The averaged MS1 spectra will have a lot of data points so they will consume more memory than normal. All the metadata in the MSn scans will still point to their real parent scans, which can be fixed by doing something like this: def redirect_precursor_ids(products, precursor):
level_to_redirect = precursor.ms_level + 1
# Don't re-direct MS3+ scans
for product in products:
if product.ms_level == level_to_redirect:
product.precursor_information.precursor_scan_id = precursor.id
return products Does this do what you are looking for? |
Beta Was this translation helpful? Give feedback.
-
Hi Joshua,
I'm trying to use ms_deisotope to analyze my LCMS data. My gradient is too long so I want to bin every 10 (or whatever number that makes sense) MS1 scans to save the data size. Is there a function in your scripts that can combine certain scans? I directly use the Thermo raw files.
Thank you very much.
Mengxuan
Beta Was this translation helpful? Give feedback.
All reactions