Skip to content

Commit

Permalink
Enable automatic detection of output format
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewThe committed Dec 5, 2023
1 parent 814c89c commit 132a604
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
42 changes: 38 additions & 4 deletions data/fragpipe_example/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ To run this example, follow these steps:

**Running PickedGroupFDR**

2. Run the following command (for alternative options see `run_picked_group_fdr.sh`):
2. Run the following command (for alternatives see `run_picked_group_fdr.sh`):
```
python3 -u -m picked_group_fdr \
--fasta ./iprg2016_with_labels.fasta \
--fragpipe_psm ./fragpipe/*/psm.tsv \
--combined_ion ./fragpipe/combined_ion.tsv \
--protein_groups_out ./results_from_combined_ion/combined_protein.tsv \
--output_format fragpipe \
--do_quant \
--lfq_min_peptide_ratios 1 \
--methods fragpipe
Expand All @@ -47,13 +46,48 @@ A quantified protein group result in FragPipe format will be available at `resul
```
This sets the FDR to 100% on all levels, which allows PickedGroupFDR to achieve increased sensitivity over the regular FragPipe results.


### Option 2a: reuse IonQuant results

**Running PickedGroupFDR**

5. Run the `run_picked_group_fdr.sh` script. This runs the `picked_group_fdr` and `picked_group_fdr.pipeline.update_fragpipe_results` modules.
5. Run the following command (for alternatives see `run_picked_group_fdr.sh`):
```
python3 -u -m picked_group_fdr \
--fasta ./iprg2016_with_labels.fasta \
--fragpipe_psm ./fragpipe/*/psm.tsv \
--combined_ion ./fragpipe/combined_ion.tsv \
--protein_groups_out ./results_from_combined_ion/combined_protein.tsv \
--do_quant \
--lfq_min_peptide_ratios 1 \
--methods fragpipe
```

A quantified protein group result in FragPipe format will be available at `results_from_combined_ion/combined_protein.tsv`.


### Option 2b: requantify with IonQuant

**Running PickedGroupFDR**

5. Run the following commands:
```
python3 -u -m picked_group_fdr \
--fasta ./iprg2016_with_labels.fasta \
--fragpipe_psm ./fragpipe/*/psm.tsv \
--protein_groups_out ./results/proteinGroups.txt \
--methods fragpipe
python3 -u -m picked_group_fdr.pipeline.update_fragpipe_results \
--fasta ./iprg2016_with_labels.fasta \
--fragpipe_psm ./fragpipe/*/psm.tsv \
--protein_groups ./results/proteinGroups.txt \
--output_folder ./results
```

This will produce a protein grouping result similar to MaxQuant's proteinGroups.txt format at `results/proteinGroups.txt`, as well as updated `psm.tsv` and `protein.tsv` file for each experiment in the `results` folder.

**Running IonQuant (optional)**
**Running IonQuant**

6. Run the `run_ionquant.sh` script with the path to the FragPipe software directory as the first argument:
```
Expand Down
1 change: 0 additions & 1 deletion data/fragpipe_example/run_picked_group_fdr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ python3 -u -m picked_group_fdr \
--fragpipe_psm ${fragpipe_psm_files} \
--combined_ion ./combined_ion.tsv \
--protein_groups_out ${RESULT_DIR}/combined_protein.tsv \
--output_format fragpipe \
--do_quant \
--lfq_min_peptide_ratios 1 \
--methods fragpipe
Expand Down
15 changes: 13 additions & 2 deletions picked_group_fdr/picked_group_fdr.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import sys
import os
import logging
Expand Down Expand Up @@ -110,9 +111,11 @@ def parse_args(argv):

apars.add_argument(
"--output_format",
default="maxquant",
default="auto",
metavar="PG",
help="""Protein groups output format. Options are "maxquant" (proteinGroups.txt
help="""Protein groups output format. Options are "auto", "maxquant" and
"fragpipe". "auto": decide based on input file format, will default to
"maxquant" if no suitable format is known; "maxquant" (proteinGroups.txt
format) and "fragpipe" (combined_protein.tsv format).""",
)

Expand Down Expand Up @@ -226,6 +229,9 @@ def write_protein_groups(
else:
label = label.lower().replace(" ", "_")
protein_groups_out = f"{base}_{label}{ext}"

Path(protein_groups_out).parent.mkdir(parents=True, exist_ok=True)

protein_groups_writer.write(protein_group_results, protein_groups_out)
logger.info(f"Protein group results have been written to: {protein_groups_out}")

Expand Down Expand Up @@ -544,8 +550,13 @@ def do_quantification(

logger.info("Preparing for quantification")

score_origin = score_type.score_origin.long_description().lower()
if args.output_format == "auto" and score_origin in ["maxquant", "fragpipe"]:
args.output_format = score_origin

protein_groups_writer = writers.get_protein_groups_output_writer(
protein_group_results,
args.output_format,
args,
protein_annotations,
parse_id,
Expand Down
1 change: 1 addition & 0 deletions picked_group_fdr/pipeline/sage_quantification.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def main(argv):

protein_groups_writer = writers.get_protein_groups_output_writer(
protein_group_results,
args.output_format,
args,
protein_annotations,
parse_id,
Expand Down
1 change: 1 addition & 0 deletions picked_group_fdr/writers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

def get_protein_groups_output_writer(
protein_group_results: results.ProteinGroupResults,
output_format: str,
args: argparse.Namespace,
protein_annotations: Dict[str, protein_annotation.ProteinAnnotation],
parse_id: Callable,
Expand Down

0 comments on commit 132a604

Please sign in to comment.