Skip to content

Commit 22566e1

Browse files
committed
added contam matrices
1 parent 32eeaac commit 22566e1

5 files changed

Lines changed: 68 additions & 8 deletions

File tree

CHANGES.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
v.0.4.0
2+
---
3+
* PYTMT now supports TMT contaminant correction.
4+
5+
v.0.3.5
6+
---
7+
* PYTMT now reads the percolator output log file from crux to assign mzML files to Percolator file_idx
8+
19
v.0.2.8
210
---
311
* input changed from specifying percolator directory to percolator file path

contams/WF309595.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
,tru_126,tru_127N,tru_127C,tru_128N,tru_128C,tru_129N,tru_129C,tru_130N,tru_130C,tru_131N
2+
obs_126,1.000,0.000,0.008,0.000,0.000,0.000,0.000,0.000,0.000,0.000
3+
obs_127N,0.000,1.000,0.000,0.012,0.000,0.000,0.000,0.000,0.000,0.000
4+
obs_127C,0.074,0.000,1.000,0.000,0.013,0.000,0.003,0.000,0.000,0.000
5+
obs_128N,0.000,0.072,0.000,1.000,0.000,0.016,0.000,0.000,0.000,0.000
6+
obs_128C,0.000,0.000,0.066,0.000,1.000,0.000,0.027,0.000,0.000,0.000
7+
obs_129N,0.000,0.000,0.000,0.063,0.000,1.000,0.000,0.022,0.000,0.000
8+
obs_129C,0.000,0.000,0.000,0.000,0.057,0.000,1.000,0.000,0.031,0.000
9+
obs_130N,0.000,0.000,0.000,0.000,0.000,0.054,0.000,1.000,0.000,0.087
10+
obs_130C,0.000,0.000,0.000,0.000,0.001,0.000,0.048,0.000,1.000,0.000
11+
obs_131N,0.000,0.000,0.000,0.000,0.000,0.013,0.000,0.046,0.000,1.000

contams/XB318561.csv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
,tru_126,tru_127N,tru_127C,tru_128N,tru_128C,tru_129N,tru_129C,tru_130N,tru_130C,tru_131N
2+
obs_126,1.000,0.000,0.074,0.000,0.000,0.000,0.000,0.000,0.000,0.000
3+
obs_127N,0.000,1.000,0.000,0.078,0.000,0.001,0.000,0.000,0.000,0.000
4+
obs_127C,0.008,0.000,1.000,0.000,0.069,0.000,0.001,0.000,0.000,0.000
5+
obs_128N,0.000,0.012,0.000,1.000,0.000,0.063,0.000,0.000,0.000,0.000
6+
obs_128C,0.000,0.000,0.015,0.000,1.000,0.000,0.062,0.000,0.002,0.000
7+
obs_129N,0.000,0.000,0.000,0.015,0.000,1.000,0.000,0.057,0.000,0.001
8+
obs_129C,0.000,0.000,0.000,0.000,0.026,0.000,1.000,0.000,0.048,0.000
9+
obs_130N,0.000,0.000,0.000,0.000,0.000,0.022,0.000,1.000,0.000,0.046
10+
obs_130C,0.000,0.000,0.000,0.000,0.000,0.000,0.031,0.000,1.000,0.000
11+
obs_131N,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.087,0.000,1.000

pytmt/main.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from pytmt.get_spec import Mzml
1515
from pytmt import tmt_reporters
1616
from pytmt import quantify_spec
17+
from pytmt import correct_matrix
1718

1819
def quant(args):
1920
"""
@@ -162,7 +163,7 @@ def quant(args):
162163
idx, pathname = pattern[0]
163164
dirname, filename = os.path.split(pathname)
164165
mzml_files[int(idx)] = re.sub('\.pep\.xml', '', filename)
165-
#TODO: will probably have to account for .pin or other input to Percolator
166+
# TODO: will probably have to account for .pin or other input to Percolator
166167

167168
# If the log file does not exist, assign index naively based on sort
168169
else:
@@ -279,10 +280,18 @@ def quant(args):
279280
for reporter in reporters:
280281
output_df_columns.append('m' + str(reporter))
281282

282-
output_df_columns.append('spectrum_int')
283283

284+
285+
output_df_columns.append('spectrum_int')
284286
output_df = pd.DataFrame(output_list, columns=output_df_columns)
285287

288+
# Correct for contamination
289+
if args.contam is not None:
290+
output_df = correct_matrix.correct_matrix(output_df=output_df,
291+
contam=args.contam,
292+
nnls=args.nnls,
293+
)
294+
286295
# Final output, merging the input and output tables
287296
final_df = pd.merge(id_df, output_df, how='left')
288297

@@ -306,13 +315,22 @@ def main():
306315
import argparse
307316

308317
parser = argparse.ArgumentParser(description='pytmt returns ms2 tmt quantification values'
309-
'from Percolator (Crux or Standalone) output')
318+
'from Percolator output and perform contamination'
319+
'correction')
310320

311-
parser.add_argument('mzml', help='path to folder containing mzml files')
321+
parser.add_argument('mzml',
322+
help='path to folder containing mzml files',
323+
)
312324

313-
parser.add_argument('id', help='path to percolator target psms output file')
325+
parser.add_argument('id',
326+
help='path to percolator target psms output file',
327+
)
314328

315-
parser.add_argument('-u', '--unique', action='store_true', help='quantify unique peptides only')
329+
parser.add_argument('-u',
330+
'--unique',
331+
action='store_true',
332+
help='quantify unique peptides only',
333+
)
316334

317335
parser.add_argument('-q', '--qvalue',
318336
help='quantify peptides with q value below this threshold [default: 1.0]',
@@ -332,10 +350,21 @@ def main():
332350
parser.add_argument('-o', '--out', help='name of the output directory [default: tmt_out]',
333351
default='tmt_out')
334352

335-
336353
parser.add_argument('-v', '--version', action='version',
337354
version='%(prog)s {version}'.format(version=__version__))
338355

356+
parser.add_argument('-c', '--contam',
357+
help='Path to contaminant matrix csv file.'
358+
' Leave blank to get tmt output without correction',
359+
metavar='CONTAM',
360+
type=argparse.FileType('r'),
361+
)
362+
363+
parser.add_argument('-n', '--nnls',
364+
action='store_true',
365+
help='uses non-negative least square for contamination correction',
366+
)
367+
339368
parser.set_defaults(func=quant)
340369

341370

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pandas>=1.0.4
22
pymzml==2.4.6
3-
tqdm>=4.46.0
3+
tqdm>=4.46.0
4+
scipy>=1.0.0

0 commit comments

Comments
 (0)