Skip to content

Commit

Permalink
rename class
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Jun 5, 2024
1 parent 67dbe4c commit d38aea2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/depiction/calibration/spectrum/calibration_method_mcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
from depiction.calibration.calibration_method import CalibrationMethod
from depiction.calibration.spectrum.calibration_smoothing import smooth_image_features

# rename to Mass Cluster Center Model MCCM
class CalibrationMethodMCC(CalibrationMethod):

class CalibrationMethodMassClusterCenterModel(CalibrationMethod):
"""Implements the Mass Cluster Center Model (MCCM) calibration method as described in the paper by
Wolski, W.E., Farrow, M., Emde, AK. et al. Analytical model of peptide mass cluster centres with applications.
Proteome Sci 4, 18 (2006). https://doi.org/10.1186/1477-5956-4-18
"""

def __init__(
self,
model_smoothing_activated: bool = True,
Expand Down Expand Up @@ -42,7 +47,8 @@ def extract_spectrum_features(self, peak_mz_arr: NDArray[float], peak_int_arr: N
intercept_coef = scipy.stats.trim_mean(delta_intercept, 0.3)
return DataArray([intercept_coef, slope], dims=["c"])

def compute_distance_from_MCC(delta: NDArray[float], l_none = 1.000482) -> NDArray[float]:
@staticmethod
def compute_distance_from_MCC(delta: NDArray[float], l_none: float = 1.000482) -> NDArray[float]:
delta_lambda = np.zeros_like(delta)
for i, mi in enumerate(delta):
term1 = mi % l_none
Expand Down Expand Up @@ -71,5 +77,5 @@ def apply_spectrum_model(
intercept, slope = model_coef.values
# Apply the model to the spectrum
# need to check if it should be -intercept or +intercept
spectrum_corrected = spectrum_mz_arr * (1 - slope) - intercept
spectrum_corrected = spectrum_mz_arr * (1 - slope) + intercept
return spectrum_corrected, spectrum_int_arr
4 changes: 2 additions & 2 deletions src/depiction_targeted_preproc/workflow/proc/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
CalibrationMethodChemicalPeptideNoise,
)
from depiction.calibration.spectrum.calibration_method_global_constant_shift import CalibrationMethodGlobalConstantShift
from depiction.calibration.spectrum.calibration_method_mcc import CalibrationMethodMCC
from depiction.calibration.spectrum.calibration_method_mcc import CalibrationMethodMassClusterCenterModel
from depiction.calibration.spectrum.calibration_method_regress_shift import CalibrationMethodRegressShift
from depiction.parallel_ops import ParallelConfig
from depiction.persistence import ImzmlReadFile, ImzmlWriteFile, ImzmlModeEnum
Expand Down Expand Up @@ -44,7 +44,7 @@ def get_calibration_from_config(mass_list: pl.DataFrame, config: PipelineParamet
use_ppm_space=calib_config.use_ppm_space,
)
case model.CalibrationMCC() as calib_config:
return CalibrationMethodMCC(
return CalibrationMethodMassClusterCenterModel(
model_smoothing_activated=calib_config.model_smoothing_activated,
model_smoothing_kernel_size=calib_config.model_smoothing_kernel_size,
model_smoothing_kernel_std=calib_config.model_smoothing_kernel_std,
Expand Down

0 comments on commit d38aea2

Please sign in to comment.