Description
Describe the problem you encountered
I simulated a LC-MS data from a compound and analyze it using pyopenms through Untargeted Metabolomics Pre-Processing pipline. But I can not get the expected mass traces even by exhaustive tuning the parameters. I also view our data using TOPPView. and the expected mass trace all can be found. I also check iod_df generated by MzMLFile().load() and I also can find our expected mass.
To Reproduce
Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
What should be happening
I should find the expected mass trace at m/z 148.5713 (the most intense), 149.0726, 149.5749, and 150.0755. But now, I just can find mass traces at m/z 149.5741 and 150.0755 by MassTraceDetection().
System information:
- OS: Windows-10-10.0.19045-SP0/Linux-5.4.0-159-generic-x86_64-with-glibc2.31
- OS Version: 10.0.19045-SP0
- Python version: 3.10.13/3.11.4
- pyopenms version: 3.1.0
- How did you install pyopenms? Please cross a box with an X.
- conda::bioconda: Specify your conda/mamba command and/or your environment with
conda list
. - conda::openms: Specify your conda/mamba command and/or your environment with
conda list
. - [X ] pip
- nightly wheel
- built from source
- conda::bioconda: Specify your conda/mamba command and/or your environment with
Additional context
The .mzML and .py file is not supported to uploaded. and Here I just pasted our code:
class FeatureDetection:
"""
Extract features from mzML files using pyopenms
"""
def init(self, file):
self.file = file
self.exp = oms.MSExperiment()
self.mass_traces = []
self.mass_traces_deconvol = []
self.feature_map = oms.FeatureMap()
self.chrom_out = []
def load_file(self):
"""Load the mzML file"""
oms.MzMLFile().load(self.file, self.exp)
def get_dataframes(self):
"""Get the ion dataframes and filter them"""
self.ion_df = self.exp.get_ion_df()
self.ion_df = self.ion_df[self.ion_df['inty'] > 0.0]
# self.ion_df.to_csv(r'C:\Users\xyy\Desktop\test\tem\ion_df.csv', index=False)
def mass_trace_detection(self):
"""Detect the mass traces"""
mtd = oms.MassTraceDetection()
mtd_par = mtd.getDefaults()
# print(mtd_par)
mtd_par.setValue("mass_error_ppm", 20.0)
mtd_par.setValue('min_trace_length', 1.0)
mtd_par.setValue("noise_threshold_int", 0.0)
mtd_par.setValue("chrom_peak_snr", 0.0)
mtd_par.setValue('trace_termination_criterion', 'sample_rate')
mtd_par.setValue('min_sample_rate', 0.5)
mtd.setParameters(mtd_par)
mtd.run(self.exp, self.mass_traces, 0)
print(len(self.mass_traces))
for i in range(len(self.mass_traces)):
trace = self.mass_traces[i]
print(f"Trace {i}:")
print(f"Centroid MZ: {trace.getCentroidMZ()}")
print(f"Centroid RT: {trace.getCentroidRT()}")
print(f"Size: {trace.getSize()}")
print("--------------------")
def elution_peak_detection(self):
"""Detect the elution peaks"""
epd = oms.ElutionPeakDetection()
epd_par = epd.getDefaults()
epd_par.setValue("width_filtering", "fixed")
# print(epd_par)
epd.setParameters(epd_par)
epd.detectPeaks(self.mass_traces, self.mass_traces_deconvol)
print(len(self.mass_traces_deconvol))
def feature_detection(self):
"""Detect the features"""
ffm = oms.FeatureFindingMetabo()
ffm_par = ffm.getDefaults()
ffm_par.setValue("local_rt_range", 10.0)
ffm_par.setValue("local_mz_range", 6.5)
ffm_par.setValue("chrom_fwhm", 5.0)
ffm_par.setValue('enable_RT_filtering', 'true')
ffm_par.setValue('mz_scoring_by_elements', 'true')
ffm_par.setValue("elements", "CHNOPSClBrFeBSeIF")
ffm_par.setValue('isotope_filtering_model','none')
ffm_par.setValue("remove_single_traces", "true")
ffm_par.setValue("report_convex_hulls", 'true')
ffm.setParameters(ffm_par)
ffm.run(self.mass_traces_deconvol, self.feature_map, self.chrom_out)
self.feature_map.setUniqueIds()
self.feature_map.setPrimaryMSRunPath([self.file.encode()])
print(self.feature_map.get_df())
print(len(self.feature_map.get_df()))
def run(self):
"""Run the feature detection process"""
self.load_file()
self.get_dataframes()
self.mass_trace_detection()
self.elution_peak_detection()
self.feature_detection()
return self.feature_map