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

PEAKS support and various fixes/improvements #35

Merged
merged 28 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
44a0eb1
Added Peaks_pipeline
ArthurDeclercq Aug 20, 2021
fd7fb3e
Peaks pipeline update, plotting bug fix
ArthurDeclercq Aug 27, 2021
c3d8778
bug fix percolator modification mapping
ArthurDeclercq Sep 1, 2021
b27dad3
updating Peaks pipeline, fixes plotting module
ArthurDeclercq Sep 1, 2021
e5d288e
bux fixes percolator pipeline, peaks pipeline and plotting module
ArthurDeclercq Sep 3, 2021
bc1b0ce
bug fix parse mgf
ArthurDeclercq Sep 15, 2021
195164e
retention time calibration for each raw file
ArthurDeclercq Sep 28, 2021
bfc65ae
bug fix config parser
ArthurDeclercq Sep 28, 2021
4260ddc
removing print sstatements
ArthurDeclercq Sep 28, 2021
a6156a9
num calibration fix
ArthurDeclercq Sep 30, 2021
2ce3667
tiny fixes in plottting module and Peaks pipeline
ArthurDeclercq Oct 11, 2021
e69001d
DeepLC import fix
ArthurDeclercq Oct 11, 2021
ada66dc
Pattern change in to allow for +, - or nothing
ArthurDeclercq Oct 11, 2021
6bc2b14
requested changes
ArthurDeclercq Nov 5, 2021
8b00ebc
requested changes, added CL parameters
ArthurDeclercq Nov 10, 2021
1c7bede
removed mgf argument from maxquant_to_rescore dict in config file
ArthurDeclercq Nov 17, 2021
9e696fb
requested changes
ArthurDeclercq Nov 17, 2021
d24bfea
optimized model selection deeplc
ArthurDeclercq Nov 18, 2021
6c35e19
add plotting warning if percolator is disabled
ArthurDeclercq Nov 23, 2021
23711a0
Merge branch 'master' into feature/Peaks_id_file_parser
ArthurDeclercq Nov 23, 2021
04c1c46
MS2ReScoreError fix
ArthurDeclercq Nov 23, 2021
ba94f3e
MS2ReScoreError fix (2)
ArthurDeclercq Nov 23, 2021
eb4e15d
another MS2rescoreError fix
ArthurDeclercq Nov 23, 2021
20bd6a1
added decoy error, searchengine feature
ArthurDeclercq Dec 2, 2021
5e91a68
parse_mgf: Fix removal of lines with zero peak intensity
RalfG Dec 14, 2021
d13af34
Add example to readme for maxquant config section
RalfG Dec 14, 2021
efce2a7
Update README.md: Add PEAKS to supported input
RalfG Dec 14, 2021
c39ef8a
Remove obsolute maxquant mgf dir option
RalfG Dec 14, 2021
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
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ MS²Rescore uses identifications from a
or from the output of one of these search engines:

- [MaxQuant](https://www.maxquant.org/): Start from `msms.txt` identification
file and directory with `.mgf` files. (Be sure to export without FDR
filtering!)
file and directory with `.mgf` files.
- [MSGFPlus](https://omics.pnl.gov/software/ms-gf): Start with an `.mzid`
identification file and corresponding `.mgf`.
- [X!Tandem](https://www.thegpm.org/tandem/): Start with an X!Tandem `.xml`
identification file and corresponding `.mgf`.
- [PEAKS](https://www.bioinfor.com/peaksdb/): Start with an `.mzid` identification
file and directory with `.mgf` files.
- [PeptideShaker](http://compomics.github.io/projects/peptide-shaker): Start with a
PeptideShaker Extended PSM Report and corresponding `.mgf` file.

Expand Down Expand Up @@ -187,6 +188,17 @@ one of the modifications listed in the MS²PIP configuration (see
- `fixed_modifications`: Must list all modifications set as fixed during the
MaxQuant search (as this is not denoted in the msms.txt file). Keys refer to the
amino acid, values to the modification name used in the MS²PIP configuration.
- The maxquant specific configuration could for example be:
```json
"maxquant_to_rescore": {
"modification_mapping":{
"ox":"Oxidation",
"cm":"Carbamidomethyl"
},
"fixed_modifications":{
"C":"Carbamidomethyl"
}
```

As a general rule, MS²Rescore always needs access to all target and decoy PSMs, not
only the FDR-filtered targets.
Expand Down
1 change: 0 additions & 1 deletion configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
- **Items**: Refer to *#/definitions/modifications*.
- **`percolator`** *(object)*: Command line options directly passed to Percolator (see the Percolator wiki).
- **`maxquant_to_rescore`** *(object)*: Settings specific to the MaxQuant pipeline. Cannot contain additional properties.
- **`mgf_dir`** *(string)*: Path to directory with MGF files.
- **`modification_mapping`** *(object)*: Mapping of MaxQuant modification labels to modifications names for MS²PIP. Default: `{}`.
- **`fixed_modifications`** *(object)*: Mapping of amino acids with fixed modifications to the modification name. Default: `{}`.
## Definitions
Expand Down
69 changes: 41 additions & 28 deletions ms2rescore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from multiprocessing import cpu_count
from typing import Dict, Optional, Union

from pandas.errors import EmptyDataError

from ms2pip.ms2pipC import MS2PIP

from ms2rescore import id_file_parser, plotting, rescore_core, setup_logging
Expand Down Expand Up @@ -44,6 +46,7 @@ def __init__(
self.config = parse_config(
parse_cli_args=parse_cli_args, config_class=configuration
)

if set_logger:
setup_logging.setup_logging(self.config["general"]["log_level"])

Expand Down Expand Up @@ -119,6 +122,8 @@ def _select_pipeline(self):
pipeline = id_file_parser.TandemPipeline
elif self.config["general"]["pipeline"] == "peptideshaker":
pipeline = id_file_parser.PeptideShakerPipeline
elif self.config["general"]["pipeline"] == "peaks":
pipeline = id_file_parser.PeaksPipeline
else:
raise NotImplementedError(self.config["general"]["pipeline"])
return pipeline
Expand Down Expand Up @@ -216,6 +221,7 @@ def _run_percolator(self):
def run(self):
"""Run MS²ReScore."""
peprec = self.pipeline.get_peprec()
peprec.validate_decoy_presence()
peprec_filename = self.tmpfile_basepath + ".peprec"
peprec.to_csv(peprec_filename)

Expand Down Expand Up @@ -254,35 +260,42 @@ def run(self):
if self.config["general"]["run_percolator"]:
self._run_percolator()

logger.info("Generating Rescore plots")
if self.config["general"]["plotting"]:

plotting.PIN(
peprec_filename, self.config["general"]["output_filename"]
)
# Only use plotting module when run_percolator is true
if self.config["general"]["plotting"]:
logger.info("Generating Rescore plots")

for fset in self.config["general"]["feature_sets"]:
pout_file = (
self.config["general"]["output_filename"]
+ "_"
+ "_".join(fset)
+ "_features.pout"
plotting.PIN(
peprec_filename, self.config["general"]["output_filename"]
)
pout_decoy_file = (
self.config["general"]["output_filename"]
+ "_"
+ "_".join(fset)
+ "_features.pout_dec"
)
plotting.POUT(
pout_file,
pout_decoy_file,
self.config["general"]["output_filename"],
" ".join(fset)
)
plotting.RescoreRecord.save_plots_to_pdf(
self.config["general"]["output_filename"] + "_plots.pdf",
FDR_thresholds=[0.01, 0.001],
)

for fset in self.config["general"]["feature_sets"]:
pout_file = (
self.config["general"]["output_filename"]
+ "_"
+ "_".join(fset)
+ "_features.pout"
)
pout_decoy_file = (
self.config["general"]["output_filename"]
+ "_"
+ "_".join(fset)
+ "_features.pout_dec"
)
try:
plotting.POUT(
pout_file,
pout_decoy_file,
self.config["general"]["output_filename"],
" ".join(fset)
)
except EmptyDataError:
logger.warn(f"Feature set: {'_'.join(fset)} returned empty pout file")
continue

plotting.RescoreRecord.save_plots_to_pdf(
self.config["general"]["output_filename"] + "_plots.pdf",
FDR_thresholds=[0.01, 0.001],
)
if not self.config["general"]["run_percolator"] and self.config["general"]["plotting"]:
logger.warn("To plot rescore results run_percolator should be enabled")
logger.info("MS²ReScore finished!")
38 changes: 38 additions & 0 deletions ms2rescore/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,42 @@ def _parse_arguments() -> argparse.Namespace:
default="info",
help="logging level (default: `info`)",
)
parser.add_argument(
"-n",
metavar="VALUE",
action="store",
type=int,
dest="num_cpu",
default=None,
help="number of cpus available to MS²Rescore",
)
parser.add_argument(
"--pipeline",
metavar="PIPELINE",
action="store",
type=str,
dest="pipeline",
default=None,
help="determines which pipeline to use (default: 'infer')",
)
parser.add_argument(
"--percolator",
metavar="BOOL",
action="store",
type=bool,
dest="run_percolator",
default=None,
help="run percolator (default: 'True')",
)
parser.add_argument(
"--plotting",
metavar="BOOL",
action="store",
type=bool,
dest="plotting",
default=None,
help="write PDF with result plots",
)
return parser.parse_args()


Expand Down Expand Up @@ -156,4 +192,6 @@ def parse_config(parse_cli_args: bool = True, config_class: Optional[Dict] = Non
config = _validate_filenames(config)
config = _validate_num_cpu(config)

config["general"]["pipeline"] = config["general"]["pipeline"].lower()

return config
Loading