Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FBMN] Normalize table option that propogates to all values #651

Merged
merged 2 commits into from
Dec 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion feature-based-molecular-networking/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ include ../Makefile.deploytemplate

WORKFLOW_NAME=feature-based-molecular-networking
TOOL_FOLDER_NAME=feature-based-molecular-networking
WORKFLOW_VERSION=release_26
WORKFLOW_VERSION=release_27
WORKFLOW_DESCRIPTION='Feature-Based Molecular Networking (FBMN) is a computational method that bridges popular mass spectrometry data processing tools for LC-MS/MS and molecular networking analysis on GNPS. The supported tools are: MZmine, OpenMS, MS-DIAL, MetaboScape, XCMS, Progenesis QI, and the mzTab-M format. FBMN facilitates the detection of isomers that are separated by chromatographic or ion mobility separation, and provides accurate ion abundances for statistical analysis. Note that FBMN requires processing the mass spectrometry data with a feature detection and alignment tool. For rapid/qualitative analysis, we recommend using classical molecular networking that accepts unprocessed mass spectrometry files. See the FBMN documentation at https://ccms-ucsd.github.io/GNPSDocumentation/featurebasedmolecularnetworking and refer to the "Method and Citation for Manuscripts" on the results page for citations.'
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<arg valueRef="inputSpectra"/>
<arg valueRef="spectra_reformatted"/>
<arg valueRef="workflowParameters"/>
<arg option="-QUANT_FILE_NORM" valueRef="@QUANT_FILE_NORM"/>
</execution>
</tool>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def main():
parser.add_argument('input_spectra_folder', help='input_spectra_folder')
parser.add_argument('output_mgf', help='output_mgf')
parser.add_argument('workflowParameters', help='workflowParameters')
parser.add_argument('--QUANT_FILE_NORM', default="None", help='QUANT_FILE_NORM')

args = parser.parse_args()

input_filenames = glob.glob(os.path.join(args.input_spectra_folder, "*"))
Expand Down Expand Up @@ -113,5 +115,20 @@ def main():
compound_filename_mapping = mztabm_formatter.convert_to_feature_csv(args.quantification_table, args.quantification_table_reformatted)
mztabm_formatter.create_mgf(input_filenames, args.output_mgf, compound_filename_mapping, name_mangle_mapping=name_mangle_mapping)

# Finally, we can renormlize the output
try:
if args.QUANT_FILE_NORM == "RowSum":
import pandas as pd
quant_df = pd.read_csv(args.quantification_table_reformatted, sep=",")
quant_df = quant_df.loc[:, ~quant_df.columns.str.contains('^Unnamed')]

for column in quant_df:
if "Peak area" in column:
quant_df[column] = quant_df[column] / sum(quant_df[column]) * 1000000

quant_df.to_csv(args.quantification_table_reformatted, sep=",", index=False)
except:
pass

if __name__ == "__main__":
main()