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

Fix/xl percolator gen features #153

Merged
merged 6 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .cookietemple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ full_name: Victor Giurcoiu
email: [email protected]
project_name: spectrum_fundamentals
project_short_description: Fundamentals public repo
version: 0.7.7
version: 0.7.8
license: MIT
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: "0.7.7 " # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.7.7 # <<COOKIETEMPLE_FORCE_BUMP>>
name-template: "0.7.8 " # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.7.8 # <<COOKIETEMPLE_FORCE_BUMP>>
exclude-labels:
- "skip-changelog"

Expand Down
2 changes: 1 addition & 1 deletion cookietemple.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.7
current_version = 0.7.8

[bumpversion_files_whitelisted]
init_file = spectrum_fundamentals/__init__.py
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
# the built documents.
#
# The short X.Y version.
version = "0.7.7"
version = "0.7.8"
# The full version, including alpha/beta/rc tags.
release = "0.7.7"
release = "0.7.8"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spectrum_fundamentals"
version = "0.7.7" # <<COOKIETEMPLE_FORCE_BUMP>>
version = "0.7.8" # <<COOKIETEMPLE_FORCE_BUMP>>
description = "Fundamental functions, annotation pipeline and constants for oktoberfest"
authors = ["Wilhelmlab at Technical University of Munich"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__author__ = """The Oktoberfest development team (Wilhelmlab at Technical University of Munich)"""
__copyright__ = f"Copyright {datetime.now():%Y}, Wilhelmlab at Technical University of Munich"
__license__ = "MIT"
__version__ = "0.7.7"
__version__ = "0.7.8"

import logging
import logging.handlers
Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@click.command()
@click.version_option(version="0.7.7", message=click.style("spectrum_fundamentals Version: 0.7.7"))
@click.version_option(version="0.7.8", message=click.style("spectrum_fundamentals Version: 0.7.8"))
def main() -> None:
"""spectrum_fundamentals."""

Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class RescoreType(Enum):

CHARGES = [1, 2, 3] # limited to uint8 (0-255) when array is created
POSITIONS = [x for x in range(1, 30)] # fragment numbers 1-29 -- limited to uint8 (0-255) when array is created

POSITIONS_XL = [x for x in range(1, 59)]
ANNOTATION_FRAGMENT_TYPE = []
ANNOTATION_FRAGMENT_CHARGE = []
ANNOTATION_FRAGMENT_NUMBER = []
Expand Down
16 changes: 8 additions & 8 deletions spectrum_fundamentals/metrics/percolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __init__(
drop_miss_cleavage_flag: Optional[bool] = False,
):
"""Initialize a Percolator obj."""
super().__init__(pred_intensities, true_intensities, mz, "CROSSLINKER_TYPE" in metadata.columns)

self.metadata = metadata
self.input_type = input_type
self.all_features_flag = all_features_flag
Expand All @@ -70,7 +72,7 @@ def __init__(
self.fdr_cutoff = fdr_cutoff
self.neutral_loss_flag = neutral_loss_flag
self.drop_miss_cleavage_flag = drop_miss_cleavage_flag
self.xl = "CROSSLINKER_TYPE" in self.metadata.columns

self.base_columns = [
"raw_file",
"scan_number",
Expand All @@ -97,8 +99,6 @@ def __init__(
"proteins",
]

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

@staticmethod
def sample_balanced_over_bins(retention_time_df: pd.DataFrame, sample_size: int = 5000) -> pd.Index:
"""
Expand Down Expand Up @@ -327,12 +327,12 @@ 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
7 changes: 4 additions & 3 deletions spectrum_fundamentals/metrics/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ 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 +536,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
)
Loading