Skip to content

Instantly share code, notes, and snippets.

@asalt
Created September 12, 2018 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asalt/82548c387e68dc228bb8b2124268a913 to your computer and use it in GitHub Desktop.
Save asalt/82548c387e68dc228bb8b2124268a913 to your computer and use it in GitHub Desktop.
Simple script to separate MaxQuant experiments
"""
Simple script to separate MaxQuant experiments
"""
import os
import sys
import numpy as np
import pandas as pd
def main(f):
df = pd.read_table(f)
cols = df.filter(like='LFQ intensity').columns
for col in cols:
subdf = df.copy()
name = col.split('LFQ intensity ')[1]
subdf['PrecursorArea'] = df[col]
subdf.loc[ subdf['Identification type ' + name] == 'By matching', 'IonScore' ] = np.nan
subdf.loc[ subdf['Identification type ' + name] == 'By matching', 'PEP' ] = np.nan
x = os.path.splitext(f)
outname = '{}_{}{}'.format(x[0], name, x[1])
print('Writing', outname)
subdf.to_csv(outname, sep='\t', index=False)
if __name__ == '__main__':
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment