From b95f8c0d7831bb582be5f3a41c547a49aab188be Mon Sep 17 00:00:00 2001 From: Susanna Kiwala Date: Wed, 9 Aug 2023 13:13:29 +0200 Subject: [PATCH] Update reference proteome similarity step to work with nonhuman data --- ...calculate_reference_proteome_similarity.py | 4 +- ...calculate_reference_proteome_similarity.py | 23 ++ .../Test.all_epitopes.aggregated.mouse.tsv | 2 + ...epitopes.aggregated.mouse.tsv.metrics.json | 247 ++++++++++++++++++ ...t.all_epitopes.aggregated.tsv.metrics.json | 2 +- .../Test.mouse.fasta | 4 + .../input.aggregated.tsv | 24 -- .../output.aggregated.peptide_fasta.mouse.tsv | 2 + 8 files changed, 281 insertions(+), 27 deletions(-) create mode 100644 tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv create mode 100644 tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv.metrics.json create mode 100644 tests/test_data/calculate_reference_proteome_similarity/Test.mouse.fasta delete mode 100644 tests/test_data/calculate_reference_proteome_similarity/input.aggregated.tsv create mode 100644 tests/test_data/calculate_reference_proteome_similarity/output.aggregated.peptide_fasta.mouse.tsv diff --git a/pvactools/lib/calculate_reference_proteome_similarity.py b/pvactools/lib/calculate_reference_proteome_similarity.py index fa40f9692..3f9097693 100644 --- a/pvactools/lib/calculate_reference_proteome_similarity.py +++ b/pvactools/lib/calculate_reference_proteome_similarity.py @@ -269,7 +269,7 @@ def _input_tsv_type(self, line): def _get_full_peptide(self, line, mt_records_dict, wt_records_dict): for record_id in mt_records_dict.keys(): (rest_record_id, variant_type, aa_change) = record_id.rsplit(".", 2) - transcript_regex = '^.*(ENST[0-9|.]+)$' + transcript_regex = '^.*(ENS[0-9|A-Z|.]+)$' transcript_p = re.compile(transcript_regex) m = transcript_p.match(rest_record_id) if m: @@ -522,7 +522,7 @@ def _write_outputs(self, processed_peptides, mt_records_dict, wt_records_dict): for query_window, hit_reference_matches in groupby(metric_lines,key=lambda x:x['Match Window']): hit_reference_matches = list(hit_reference_matches) gene_regex = '^.*gene_symbol:([0-9|A-Z]+).*$' - transcript_regex = '^.*transcript:(ENST[0-9|.]+).*$' + transcript_regex = '^.*transcript:(ENS[0-9|A-Z|.]+).*$' gene_p = re.compile(gene_regex) transcript_p = re.compile(transcript_regex) genes = [] diff --git a/tests/test_calculate_reference_proteome_similarity.py b/tests/test_calculate_reference_proteome_similarity.py index 028a3c7a3..6fc3fcd7b 100644 --- a/tests/test_calculate_reference_proteome_similarity.py +++ b/tests/test_calculate_reference_proteome_similarity.py @@ -90,6 +90,29 @@ def test_calculate_self_similarity_with_aggregated_tsv_and_peptide_fasta(self): )) os.remove(metric_file) + def test_calculate_self_similarity_with_aggregated_tsv_and_peptide_fasta_mouse(self): + input_file = os.path.join(self.test_data_dir, 'Test.all_epitopes.aggregated.mouse.tsv') + input_aggregated_metrics_file = os.path.join(self.test_data_dir, 'Test.all_epitopes.aggregated.mouse.tsv.metrics.json') + tmp_aggregated_metrics_file = tempfile.NamedTemporaryFile() + import shutil + shutil.copy(input_aggregated_metrics_file, tmp_aggregated_metrics_file.name) + input_fasta = os.path.join(self.test_data_dir, 'Test.mouse.fasta') + output_file = tempfile.NamedTemporaryFile(suffix='.tsv') + metric_file = "{}.reference_matches".format(output_file.name) + output_aggregated_metrics_file = output_file.name.replace(".tsv", ".metrics.json") + self.assertFalse(CalculateReferenceProteomeSimilarity( + input_file, + input_fasta, + output_file.name, + peptide_fasta=self.peptide_fasta, + aggregate_metrics_file=tmp_aggregated_metrics_file.name, + ).execute()) + self.assertTrue(cmp( + output_file.name, + os.path.join(self.test_data_dir, "output.aggregated.peptide_fasta.mouse.tsv"), + )) + os.remove(metric_file) + def test_wt_peptide_fully_in_mt_peptide(self): input_file = os.path.join(self.test_data_dir, 'input_wt_in_mt.tsv') input_fasta = os.path.join(self.test_data_dir, 'input_wt_in_mt.fasta') diff --git a/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv b/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv new file mode 100644 index 000000000..067c7fd0e --- /dev/null +++ b/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv @@ -0,0 +1,2 @@ +ID E*01:01 G*01:09 Gene AA Change Num Passing Transcripts Best Peptide Best Transcript TSL Allele Pos Prob Pos Num Passing Peptides IC50 MT IC50 WT %ile MT %ile WT RNA Expr RNA VAF Allele Expr RNA Depth DNA VAF Tier Evaluation +22-41920894-41920895-G-C 2 1 ACO2 N1453S 1 KFNPQTDYL ENSMUST00000027032 Not Supported HLA-G*01:09 5 None 3 1262.760 1318.61 0.500 0.6 NA NA NA NA 0.250 Poor Pending diff --git a/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv.metrics.json b/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv.metrics.json new file mode 100644 index 000000000..429bdfcfe --- /dev/null +++ b/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.mouse.tsv.metrics.json @@ -0,0 +1,247 @@ +{ + "tumor_purity": null, + "vaf_clonal": 0.571, + "vaf_subclonal": 0.286, + "binding_threshold": 500, + "aggregate_inclusion_binding_threshold": 5000, + "trna_vaf": 0.25, + "trna_cov": 10, + "allele_expr_threshold": 2.5, + "maximum_transcript_support_level": 1, + "percentile_threshold": null, + "allele_specific_binding_thresholds": false, + "mt_top_score_metric": "Best", + "wt_top_score_metric": "Corresponding", + "binding_cutoffs": { + "HLA-E*01:01": 500, + "HLA-G*01:09": 500 + }, + "is_allele_specific_binding_cutoff": { + "HLA-E*01:01": false, + "HLA-G*01:09": false + }, + "allele_specific_anchors": false, + "anchor_contribution_threshold": 0.8, + "22-41920894-41920895-G-C": { + "good_binders": { + "Transcript Set 1": { + "peptides": { + "LLPLLPLLL": { + "ic50s_MT": [ + 2551.25, + 4778.52001953125 + ], + "percentiles_MT": [ + 0.1700439453125, + 6.80078125 + ], + "ic50s_WT": [ + 3099.81, + 4830.5 + ], + "percentiles_WT": [ + 0.33, + 6.9 + ], + "hla_types": [ + "HLA-E*01:01", + "HLA-G*01:09" + ], + "mutation_position": "6-7", + "problematic_positions": "None", + "individual_ic50_calls": { + "algorithms": [ + "NetMHC", + "PickPocket" + ], + "MT": { + "HLA-E*01:01": [ + 6891.60986328125, + 2551.25 + ], + "HLA-G*01:09": [ + "NA", + 4778.52001953125 + ] + }, + "WT": { + "HLA-E*01:01": [ + 9234.71, + 3099.81 + ], + "HLA-G*01:09": [ + "NA", + 4830.5 + ] + } + }, + "individual_percentile_calls": { + "algorithms": [ + "NetMHC", + "PickPocket" + ], + "MT": { + "HLA-E*01:01": [ + 0.1700439453125, + 1.400390625 + ], + "HLA-G*01:09": [ + "NA", + 6.80078125 + ] + }, + "WT": { + "HLA-E*01:01": [ + 0.33, + 2.2 + ], + "HLA-G*01:09": [ + "NA", + 6.9 + ] + } + }, + "individual_el_calls": { + "algorithms": [], + "MT": { + "HLA-E*01:01": [], + "HLA-G*01:09": [] + }, + "WT": { + "HLA-E*01:01": [], + "HLA-G*01:09": [] + } + }, + "individual_el_percentile_calls": { + "algorithms": [], + "MT": { + "HLA-E*01:01": [], + "HLA-G*01:09": [] + }, + "WT": { + "HLA-E*01:01": [], + "HLA-G*01:09": [] + } + }, + "wt_peptide": "LLPLLLLLL" + }, + "LLPLLLLLG": { + "ic50s_MT": [ + 4676.22998046875, + "X" + ], + "percentiles_MT": [ + 5.8984375, + "X" + ], + "ic50s_WT": [ + 38565.12, + "X" + ], + "percentiles_WT": [ + 81.0, + "X" + ], + "hla_types": [ + "HLA-E*01:01", + "HLA-G*01:09" + ], + "mutation_position": "3-4", + "problematic_positions": "None", + "individual_ic50_calls": { + "algorithms": [ + "NetMHC", + "PickPocket" + ], + "MT": { + "HLA-E*01:01": [ + 31981.0703125, + 4676.22998046875 + ] + }, + "WT": { + "HLA-E*01:01": [ + 42768.73, + 38565.12 + ] + } + }, + "individual_percentile_calls": { + "algorithms": [ + "NetMHC", + "PickPocket" + ], + "MT": { + "HLA-E*01:01": [ + 14.0, + 5.8984375 + ] + }, + "WT": { + "HLA-E*01:01": [ + 60.0, + 81.0 + ] + } + }, + "individual_el_calls": { + "algorithms": [], + "MT": { + "HLA-E*01:01": [] + }, + "WT": { + "HLA-E*01:01": [] + } + }, + "individual_el_percentile_calls": { + "algorithms": [], + "MT": { + "HLA-E*01:01": [] + }, + "WT": { + "HLA-E*01:01": [] + } + }, + "wt_peptide": "LPLLLLLLG" + } + }, + "transcripts": [ + "ENST00000233809.4-IGFBP2-L/LLP-20" + ], + "transcript_expr": [ + "NA" + ], + "tsl": [ + "Not Supported" + ], + "biotype": [ + "protein_coding" + ], + "transcript_length": [ + 325 + ], + "transcript_count": 1, + "peptide_count": 2, + "total_expr": 0 + } + }, + "sets": [ + "Transcript Set 1" + ], + "transcript_counts": [ + 1 + ], + "peptide_counts": [ + 2 + ], + "set_expr": [ + 0 + ], + "DNA VAF": 0.891, + "RNA VAF": "NA", + "gene_expr": "NA", + "best_peptide_mt": "LLPLLPLLL", + "best_peptide_wt": "LLPLLLLLL", + "best_hla_allele": "HLA-E*01:01" + } +} diff --git a/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.tsv.metrics.json b/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.tsv.metrics.json index 4de3a922e..08132e50a 100644 --- a/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.tsv.metrics.json +++ b/tests/test_data/calculate_reference_proteome_similarity/Test.all_epitopes.aggregated.tsv.metrics.json @@ -3275,4 +3275,4 @@ "best_peptide_wt": "ATLSRTLLA", "best_hla_allele": "HLA-E*01:01" } -} \ No newline at end of file +} diff --git a/tests/test_data/calculate_reference_proteome_similarity/Test.mouse.fasta b/tests/test_data/calculate_reference_proteome_similarity/Test.mouse.fasta new file mode 100644 index 000000000..d53a50074 --- /dev/null +++ b/tests/test_data/calculate_reference_proteome_similarity/Test.mouse.fasta @@ -0,0 +1,4 @@ +>WT.Rp1.ENSMUST00000027032.missense.1453N/S +IAGTLKFNPETDYLTGTDG +>MT.Rp1.ENSMUST00000027032.missense.1453N/S +IAGTLKFNPQTDYLTGTDG diff --git a/tests/test_data/calculate_reference_proteome_similarity/input.aggregated.tsv b/tests/test_data/calculate_reference_proteome_similarity/input.aggregated.tsv deleted file mode 100644 index 69f5a081c..000000000 --- a/tests/test_data/calculate_reference_proteome_similarity/input.aggregated.tsv +++ /dev/null @@ -1,24 +0,0 @@ -ID E*01:01 G*01:09 Gene AA Change Num Passing Transcripts Best Peptide Best Transcript TSL Allele Pos Prob Pos Num Passing Peptides IC50 MT IC50 WT %ile MT %ile WT RNA Expr RNA VAF Allele Expr RNA Depth DNA VAF Tier Evaluation -22-41920894-41920895-G-C 2 1 ACO2 E510Q 1 KFNPQTDYL ENST00000216254.4 Not Supported HLA-G*01:09 5 None 3 1262.760 1318.61 0.500 0.6 NA NA NA NA 0.250 Poor Pending -22-22550509-22550510-T-G 2 1 IGLV6-57 S63A 1 QRPGSAPTT ENST00000390285.3 Not Supported HLA-E*01:01 6 None 3 1362.110 1517.76 0.300 0.3 NA NA NA NA 0.571 Poor Pending -22-46653595-46653596-G-A 1 5 PKDREJ T1875I 1 LYYSYGLLHI ENST00000253255.5 Not Supported HLA-G*01:09 10 None 6 1469.280 2365.16 0.300 0.4 NA NA NA NA 0.233 Poor Pending -22-38027027-38027028-C-G 2 GGA1 P484A 1 ARPPQQPVP ENST00000343632.4 Not Supported HLA-E*01:01 1 None 2 1654.990 4242.33 0.400 4.8 NA NA NA NA 0.486 Poor Pending -22-39994238-39994239-G-A 2 1 CACNA1I C107Y 1 YQPCDDMDY ENST00000402142.3 Not Supported HLA-E*01:01 9 None 3 1864.160 1804.62 0.600 0.6 NA NA NA NA 0.043 Poor Pending -6-41754573-41754573-C-CCTT 1 1 PRICKLE4 -287-288L 1 ATLSRTLLL ENST00000458694.1 Not Supported HLA-E*01:01 9 None 1 2122.610 3272.12 0.120 5.1 NA NA NA NA 0.158 Poor Pending -22-18020271-18020272-G-A 1 CECR2 R535H 1 WTHSRDPEG ENST00000262608.8 Not Supported HLA-E*01:01 3 None 1 2523.800 1765.99 1.400 0.5 NA NA NA NA 0.071 Poor Pending -2-217498305-217498305-T-TGCTGCC 2 1 IGFBP2 L20LLP 1 LLPLLPLLL ENST00000233809.4 Not Supported HLA-E*01:01 6-7 None 2 2551.250 3099.81 0.170 0.33 NA NA NA NA 0.891 Poor Pending -22-18644672-18644673-C-T 1 USP18 A124V 1 LVYCLQKCN ENST00000215794.7 Not Supported HLA-G*01:09 2 None 1 3099.810 6399.79 3.301 12.0 NA NA NA NA 0.053 Poor Pending -22-50615580-50615581-C-T 1 1 PANX2 S147F 1 FLAFTRLTS ENST00000395842.2 Not Supported HLA-E*01:01 4 None 2 3343.700 3202.08 2.699 2.4 NA NA NA NA 0.959 Poor Pending -22-37771017-37771018-G-A 1 ELFN2 P186L 1 MVCELAGNL ENST00000402918.2 Not Supported HLA-G*01:09 9 None 1 3454.020 10191.11 4.102 21.0 NA NA NA NA 0.135 Poor Pending -22-37966274-37966275-C-G 1 LGALS2 E132Q 1 NMSSFKLKQ ENST00000215886.4 Not Supported HLA-E*01:01 9 None 1 3890.570 3848.7 4.000 3.9 NA NA NA NA 0.496 Poor Pending -22-41895790-41895791-C-A 2 ACO2 A33E 1 EMSHFEPNE ENST00000216254.4 Not Supported HLA-E*01:01 1 None 2 3932.890 2443.19 4.199 1.3 NA NA NA NA 0.044 Poor Pending -22-50682229-50682230-T-C 1 1 TUBGCP6 H220R 1 RSRTYDMDV ENST00000248846.5 Not Supported HLA-G*01:09 1 None 2 4576.120 7609.38 6.301 15.0 NA NA NA NA 0.686 Poor Pending -22-19175521-19175522-G-T 1 CLTCL1 H1469N 1 SVNEALNNL ENST00000263200.10 Not Supported HLA-G*01:09 8 None 1 4989.870 7775.84 7.301 15.0 NA NA NA NA 0.100 Poor Pending -22-50869713-50869714-C-A PPP6R2 S414Y 0 GYESRVEPP ENST00000395741.3 Not Supported HLA-G*01:09 2 None 0 5620.540 22209.93 8.703 44.0 NA NA NA NA 0.043 Poor Pending -22-20709231-20709232-G-C FAM230A E322Q 0 ANQDAAQGI ENST00000434783.3 Not Supported HLA-G*01:09 3 None 0 5681.680 9654.43 8.797 20.0 NA NA NA NA 0.500 Poor Pending -22-26936775-26936776-G-T TPST2 P274H 0 KHGGVSLSK ENST00000338754.4 Not Supported HLA-E*01:01 2 None 0 6539.790 20149.14 13.000 53.0 NA NA NA NA 0.179 Poor Pending -22-29886116-29886117-C-A NEFH P830T 0 KTQEVKVKE ENST00000310624.6 Not Supported HLA-G*01:09 2 None 0 7366.350 25842.4 14.000 50.0 NA NA NA NA 0.038 Poor Pending -22-38119219-38119220-GA-G TRIOBP FS219 0 GEKAGCPWS ENST00000406386.3 Not Supported HLA-E*01:01 0-10 None 0 8119.760 NA 18.000 NA NA NA NA NA 0.768 Poor Pending -22-22550449-22550450-C-G IGLV6-57 R43G 0 KTVTISCTG ENST00000390285.3 Not Supported HLA-G*01:09 9 None 0 9447.760 15208.39 19.000 31.0 NA NA NA NA 1.000 Poor Pending -22-50555769-50555770-G-A MOV10L1 A482T 0 KTTVVVTTQ ENST00000262794.5 Not Supported HLA-G*01:09 8 None 0 10874.650 16763.86 23.000 34.0 NA NA NA NA 0.042 Poor Pending -4-40434704-40434725-AGCGGCTGCGGCGGCTGCGGCC-A RBM47 AAAAAAAA495-502A 0 SAAAAAAAV ENST00000381793.2 Not Supported HLA-E*01:01 8-9 None 0 21040.320 21040.32 21.000 30.0 NA NA NA NA 0.977 Poor Pending diff --git a/tests/test_data/calculate_reference_proteome_similarity/output.aggregated.peptide_fasta.mouse.tsv b/tests/test_data/calculate_reference_proteome_similarity/output.aggregated.peptide_fasta.mouse.tsv new file mode 100644 index 000000000..4be294020 --- /dev/null +++ b/tests/test_data/calculate_reference_proteome_similarity/output.aggregated.peptide_fasta.mouse.tsv @@ -0,0 +1,2 @@ +ID E*01:01 G*01:09 Gene AA Change Num Passing Transcripts Best Peptide Best Transcript TSL Allele Pos Prob Pos Num Passing Peptides IC50 MT IC50 WT %ile MT %ile WT RNA Expr RNA VAF Allele Expr RNA Depth DNA VAF Tier Ref Match Evaluation +22-41920894-41920895-G-C 2 1 ACO2 N1453S 1 KFNPQTDYL ENSMUST00000027032 Not Supported HLA-G*01:09 5 None 3 1262.760 1318.61 0.500 0.6 NA NA NA NA 0.250 Poor False Pending