Skip to content

Commit

Permalink
Merge pull request #90 from daichengxin/main
Browse files Browse the repository at this point in the history
support .d and disable beeswarm
  • Loading branch information
ypriverol authored Oct 27, 2023
2 parents fda6118 + d2e6402 commit ac8f922
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 195 deletions.
4 changes: 2 additions & 2 deletions pmultiqc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def pmultiqc_plugin_execution_start():
if 'quantms/mzML' not in config.sp:
config.update_dict(config.sp, {'quantms/mzML': {'fn': '*.mzML', 'num_lines': 0}})

if 'quantms/mzml_info' not in config.sp:
config.update_dict(config.sp, {'quantms/mzml_info': {'fn': '*_mzml_info.tsv', 'num_lines': 0}})
if 'quantms/ms_info' not in config.sp:
config.update_dict(config.sp, {'quantms/ms_info': {'fn': '*_ms_info.tsv', 'num_lines': 0}})

if 'quantms/idXML' not in config.sp:
config.update_dict(config.sp, {'quantms/idXML': {'fn': '*.idXML', 'num_lines': 0}})
Expand Down
47 changes: 47 additions & 0 deletions pmultiqc/modules/quantms/ms_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
======================
@author:Chengxin Dai
@time:2023/10/23:17:25
======================
"""
import pandas as pd

# The time resulution in seconds.
# Larger values will result in smaller data files as outputs
# and will slightly smooth the data. 5 seconds seems to be
# a good value for qc purposes.
SECOND_RESOLUTION = 5


def get_ms_qc_info(ms_info: pd.DataFrame):
"""
Note that here I am using min and not mean for purely qc reasons.
Since the diagnostic aspect here is mainly to see major fluctuations
in the intensity, and usually these are scans with very low intensity
due to bubbles or ionization issues, thus the mean would hide that.
@param ms_info:
@return:
"""
ms1_info = ms_info[ms_info["MSLevel"] == 1]
ms2_info = ms_info[ms_info["MSLevel"] == 2]
ms1_info["rt_normalize"] = (ms1_info.sort_values(by="Retention_Time")["Retention_Time"] / SECOND_RESOLUTION).astype(
int)
tic_data = ms1_info.groupby("rt_normalize")[["Retention_Time", "Summed_Peak_Intensities"]].min()
tic_data = dict(zip(tic_data["Retention_Time"], tic_data["Summed_Peak_Intensities"]))

bpc_data = dict(zip(ms1_info.groupby("rt_normalize")["Retention_Time"].min(),
ms1_info.groupby("rt_normalize")["Summed_Peak_Intensities"].max()))

ms1_peaks = dict(zip(ms1_info.groupby("rt_normalize")["Retention_Time"].min(),
ms1_info.groupby("rt_normalize")["MS_peaks"].mean()))

general_stats = {
"AcquisitionDateTime": ms1_info["AcquisitionDateTime"][0],
"TotalCurrent": ms1_info["Summed_Peak_Intensities"].sum(),
"ScanCurrent": ms2_info["Summed_Peak_Intensities"].sum()
}

return tic_data, bpc_data, ms1_peaks, general_stats
Loading

0 comments on commit ac8f922

Please sign in to comment.