Skip to content

Commit

Permalink
paper results comes from this version
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafakalhor committed Oct 15, 2024
1 parent 434f41e commit 414bb2a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 11 additions & 13 deletions spectrum_fundamentals/metrics/percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def __init__(
self.all_features_flag = all_features_flag
self.regression_method = regression_method
self.fdr_cutoff = fdr_cutoff
self.xl = "CROSSLINKER_TYPE" in self.metadata.columns

super().__init__(pred_intensities, true_intensities, mz)

super().__init__(pred_intensities, true_intensities, mz, xl="CROSSLINKER_TYPE" in self.metadata.columns)


@staticmethod
def sample_balanced_over_bins(retention_time_df: pd.DataFrame, sample_size: int = 5000) -> pd.Index:
Expand Down Expand Up @@ -278,12 +278,10 @@ def add_percolator_metadata_columns(self):
"""Add metadata columns needed by percolator, e.g. to identify a PSM."""
if self.xl:
spec_id_cols = ["RAW_FILE", "SCAN_NUMBER", "MODIFIED_SEQUENCE_A", "MODIFIED_SEQUENCE_B", "PRECURSOR_CHARGE"]
self.metrics_val["Peptide"] = (
self.metadata["MODIFIED_SEQUENCE_A"] + "_" + self.metadata["MODIFIED_SEQUENCE_B"]
).apply(lambda x: "_." + x + "._")
self.metrics_val["Proteins"] = (
self.metadata["MODIFIED_SEQUENCE_A"] + "_" + self.metadata["MODIFIED_SEQUENCE_B"]
)
modified_sequence_a = self.metadata["MODIFIED_SEQUENCE_A"].astype(str)
modified_sequence_b = self.metadata["MODIFIED_SEQUENCE_B"].astype(str)
self.metrics_val["Peptide"] = (modified_sequence_a + "_" + modified_sequence_b).apply(lambda x: "_." + x + "._")
self.metrics_val["Proteins"] = (modified_sequence_a + "_" + modified_sequence_b)
self.metrics_val["Label"] = self.target_decoy_labels
else:
spec_id_cols = ["RAW_FILE", "SCAN_NUMBER", "MODIFIED_SEQUENCE", "PRECURSOR_CHARGE"]
Expand Down Expand Up @@ -466,10 +464,10 @@ def calc(self):
# self.metrics_val['spectral_angle_delta_score'] = Percolator.get_delta_score(self.metrics_val[['ScanNr',
# 'spectral_angle']], 'spectral_angle')
pass
else:
self.metrics_val["andromeda_delta_score"] = Percolator.get_delta_score(
self.metrics_val[["ScanNr", "andromeda"]], "andromeda"
)
#else:
# self.metrics_val["andromeda_delta_score"] = Percolator.get_delta_score(
# self.metrics_val[["ScanNr", "andromeda"]], "andromeda"
# )

self._reorder_columns_for_percolator()

Expand Down
8 changes: 5 additions & 3 deletions spectrum_fundamentals/metrics/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,7 @@ def _calc_additional_metrics(
true_intensities, pred_intensities, "max"
)
self.metrics_val[f"mse{key_suffix}"] = SimilarityMetrics.abs_diff(true_intensities, pred_intensities, "mse")
self.metrics_val[f"modified_cosine{key_suffix}"] = SimilarityMetrics.modified_cosine(
true_intensities, pred_intensities, self.mz, self.mz
)


col_names_spectral_angle = [
f"spectral_angle_{amount}_charge{key_suffix}" for amount in ["single", "double", "triple"]
Expand Down Expand Up @@ -539,3 +537,7 @@ def _calc_additional_metrics(
self.metrics_val[col_name_spearman_corr] = SimilarityMetrics.correlation(
true_intensities, pred_intensities, i + 1, "spearman"
)

self.metrics_val[f"modified_cosine{key_suffix}"] = SimilarityMetrics.modified_cosine(
true_intensities, pred_intensities, self.mz, self.mz
)

0 comments on commit 414bb2a

Please sign in to comment.