Skip to content

Commit

Permalink
generate a config with smoothing deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Nov 12, 2024
1 parent 6a6af2a commit bea8240
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import cyclopts
import yaml
from pathlib import Path

from depiction.tools.calibrate.config import (
CalibrationConfig,
CalibrationRegressShiftConfig,
CalibrationChemicalPeptideNoiseConfig,
CalibrationMCCConfig,
CalibrationConstantGlobalShiftConfig,
)

app = cyclopts.App()


def remove_smoothing(config: CalibrationConfig) -> CalibrationConfig:
match config:
case CalibrationRegressShiftConfig():
return config.model_copy(update={"spatial_smoothing": None})
case CalibrationChemicalPeptideNoiseConfig():
return config
case CalibrationMCCConfig():
return config.model_copy(update={"coef_smoothing_activated": False})
case CalibrationConstantGlobalShiftConfig():
return config
case _:
raise NotImplementedError(f"Smoothing removal for {config.method.calibration_method} not implemented.")


@app.default
def prepare(input_config_path: Path, output_config_path: Path) -> None:
config = CalibrationConfig.model_validate(yaml.safe_load(input_config_path.read_text()))
config_new = remove_smoothing(config)
output_config_path.write_text(yaml.safe_dump(config_new.model_dump(mode="json")))


if __name__ == "__main__":
app()
10 changes: 10 additions & 0 deletions src/depiction_targeted_preproc/workflow/experimental.smk
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ rule exp_plot_map_comparison:
# " --input-mass-shift-path {input.mass_shift}"
# " --output-pdf-path {output.pdf}"
#


rule exp_prepare_calibration_config_with_no_smoothing:
input:
config="{sample}/config/proc_calibrate.yml",
output:
config="{sample}/config/proc_calibrate_no_smoothing.yml",
shell:
"python -m depiction_targeted_preproc.workflow.exp.prepare_calibration_config_with_no_smoothing"
" --input-config-path {input.config} --output-config-path {output.config}"

0 comments on commit bea8240

Please sign in to comment.