-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from daichengxin/main
support .d and disable beeswarm
- Loading branch information
Showing
4 changed files
with
370 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.