From 1992aac6a79adc1ccb8a3bab0ca5a048647a20ef Mon Sep 17 00:00:00 2001 From: Leonardo Schwarz Date: Fri, 28 Jun 2024 10:20:25 +0200 Subject: [PATCH] improve pre-commit setup --- .github/workflows/pr-checks.yml | 25 ++++----- .pre-commit-config.yaml | 54 +++++++++++++++---- .../workflow/Snakefile | 1 + .../workflow/experimental.smk | 36 ++++++++----- .../workflow/rules/rules_proc.smk | 45 +++++++++------- .../workflow/rules/rules_qc.smk | 45 +++++++++------- .../workflow/rules/rules_simulate.smk | 7 +-- .../workflow/rules/rules_vis.smk | 28 ++++++---- 8 files changed, 151 insertions(+), 90 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index a5f5244..53dfd29 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -1,12 +1,10 @@ name: PR Checks - on: push: branches: [main, dev] pull_request: branches: [main, dev] workflow_dispatch: - jobs: unit_tests: name: PR Checks @@ -21,15 +19,14 @@ jobs: - name: Code style run: ruff check || true if: success() || failure() - - #code_style: - # name: Code Style - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./.github/actions/setup-depiction - # with: - # python-version: 3.11 - # - name: Check code with ruff - # run: - # ruff check || true +#code_style: +# name: Code Style +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: ./.github/actions/setup-depiction +# with: +# python-version: 3.11 +# - name: Check code with ruff +# run: +# ruff check || true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1fcd50..8efa927 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,60 @@ ci: autoupdate_commit_msg: "chore: update pre-commit hooks" autofix_commit_msg: "style: pre-commit fixes" - repos: - repo: https://github.com/psf/black rev: "24.4.2" hooks: - id: black - - - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" - hooks: - - id: prettier - types_or: [yaml, markdown, html, css, scss, javascript, json] - args: [--prose-wrap=always] - + - repo: https://github.com/adamchainz/blacken-docs + rev: "1.16.0" + hooks: + - id: blacken-docs + additional_dependencies: [black==24.*] + # TODO add later, when improved + #- repo: https://github.com/astral-sh/ruff-pre-commit + # rev: "v0.4.1" + # hooks: + # - id: ruff + # args: ["--fix", "--show-fixes"] + # - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.6.0" + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: name-tests-test + args: ["--pytest-test-first"] + - id: requirements-txt-fixer + - id: trailing-whitespace + - id: pretty-format-json + args: + - "--autofix" + - "--indent=4" + - "--no-sort-keys" + - repo: https://github.com/google/yamlfmt + rev: "v0.13.0" + hooks: + - id: yamlfmt + - repo: https://github.com/snakemake/snakefmt + rev: "v0.10.2" + hooks: + - id: snakefmt + - repo: https://github.com/executablebooks/mdformat/ + rev: "0.7.17" + hooks: + - id: mdformat - repo: https://github.com/abravalheri/validate-pyproject rev: "v0.16" hooks: - id: validate-pyproject additional_dependencies: ["validate-pyproject-schema-store[all]"] - - repo: https://github.com/python-jsonschema/check-jsonschema rev: "0.28.2" hooks: diff --git a/src/depiction_targeted_preproc/workflow/Snakefile b/src/depiction_targeted_preproc/workflow/Snakefile index 6f36af1..977b6e6 100644 --- a/src/depiction_targeted_preproc/workflow/Snakefile +++ b/src/depiction_targeted_preproc/workflow/Snakefile @@ -1,5 +1,6 @@ version: "3" + include: "rules/rules_proc.smk" include: "rules/rules_vis.smk" include: "rules/rules_qc.smk" diff --git a/src/depiction_targeted_preproc/workflow/experimental.smk b/src/depiction_targeted_preproc/workflow/experimental.smk index c8dadd9..540a42f 100644 --- a/src/depiction_targeted_preproc/workflow/experimental.smk +++ b/src/depiction_targeted_preproc/workflow/experimental.smk @@ -1,28 +1,34 @@ version: "3" + include: "rules/rules_proc.smk" include: "rules/rules_vis.smk" include: "rules/rules_qc.smk" include: "rules/rules_simulate.smk" + exp_variants = ["chem_noise", "mass_cluster", "reg_shift"] + rule exp_compare_cluster_stats: input: - csv=expand("{{sample}}/{exp_variant}/cluster_default_stats_hdbscan.csv",exp_variant=exp_variants) + csv=expand("{{sample}}/{exp_variant}/cluster_default_stats_hdbscan.csv", exp_variant=exp_variants), output: - pdf="{sample}/exp_compare_cluster_stats.pdf" + pdf="{sample}/exp_compare_cluster_stats.pdf", shell: "python -m depiction_targeted_preproc.workflow.exp.compare_cluster_stats" " {input.csv}" " --output-pdf {output}" + rule exp_plot_compare_peak_density: input: - tables_marker_distance=expand("{{sample}}/{exp_variant}/qc/table_marker_distances_calib.parquet",exp_variant=exp_variants), + tables_marker_distance=expand( + "{{sample}}/{exp_variant}/qc/table_marker_distances_calib.parquet", exp_variant=exp_variants + ), table_marker_distance_uncalib="{sample}/reg_shift/qc/table_marker_distances_baseline.parquet", output: - pdf="{sample}/exp_plot_compare_peak_density.pdf" + pdf="{sample}/exp_plot_compare_peak_density.pdf", shell: "python -m depiction_targeted_preproc.workflow.exp.plot_compare_peak_density" " {input.tables_marker_distance}" @@ -33,32 +39,34 @@ rule exp_plot_compare_peak_density: # for the poster: rule qc_table_marker_distances_baseline_mini: input: - imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.peaks", ".imzML", ".ibd"), mass_list="{sample}/mass_list.visualization_mini.csv", output: - table="{sample}/qc/table_marker_distances_baseline_mini.parquet" + table="{sample}/qc/table_marker_distances_baseline_mini.parquet", shell: "python -m depiction_targeted_preproc.workflow.qc.table_marker_distances" " --imzml-peaks {input.imzml[0]} --mass-list {input.mass_list}" " --output-table {output.table}" + rule qc_table_marker_distances_calib_mini: input: imzml_peaks="{sample}/calibrated.imzML", mass_list="{sample}/mass_list.visualization_mini.csv", output: - table="{sample}/qc/table_marker_distances_calib_mini.parquet" + table="{sample}/qc/table_marker_distances_calib_mini.parquet", shell: "python -m depiction_targeted_preproc.workflow.qc.table_marker_distances" " --imzml-peaks {input.imzml_peaks} --mass-list {input.mass_list}" " --output-table {output.table}" + rule qc_plot_marker_presence_mini: input: table_marker_distances_baseline="{sample}/qc/table_marker_distances_baseline_mini.parquet", - table_marker_distances_calib="{sample}/qc/table_marker_distances_calib_mini.parquet" + table_marker_distances_calib="{sample}/qc/table_marker_distances_calib_mini.parquet", output: - pdf="{sample}/qc/plot_marker_presence_mini.pdf" + pdf="{sample}/qc/plot_marker_presence_mini.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_marker_presence" " --table-marker-distances-baseline {input.table_marker_distances_baseline}" @@ -66,20 +74,22 @@ rule qc_plot_marker_presence_mini: " --layout-vertical" " --output-pdf {output.pdf}" + variants_with_map = ["mass_cluster", "reg_shift"] + rule exp_plot_map_comparison: input: - mass_shifts=expand("{{sample}}/{exp_variant}/test_mass_shifts.hdf5",exp_variant=variants_with_map) + mass_shifts=expand("{{sample}}/{exp_variant}/test_mass_shifts.hdf5", exp_variant=variants_with_map), output: - pdf="{sample}/exp_plot_map_comparison.pdf" + pdf="{sample}/exp_plot_map_comparison.pdf", shell: "python -m depiction_targeted_preproc.workflow.exp.plot_map_comparison" " {input.mass_shifts}" " --output-pdf-path {output.pdf}" -#rule exp_plot_map_single_for_poster: +# rule exp_plot_map_single_for_poster: # input: # mass_shift="{sample}/test_mass_shifts.hdf5" # output: @@ -88,4 +98,4 @@ rule exp_plot_map_comparison: # "python -m depiction_targeted_preproc.workflow.exp.plot_map_single" # " --input-mass-shift-path {input.mass_shift}" # " --output-pdf-path {output.pdf}" -# \ No newline at end of file +# diff --git a/src/depiction_targeted_preproc/workflow/rules/rules_proc.smk b/src/depiction_targeted_preproc/workflow/rules/rules_proc.smk index 457bf0b..8a2ddc0 100644 --- a/src/depiction_targeted_preproc/workflow/rules/rules_proc.smk +++ b/src/depiction_targeted_preproc/workflow/rules/rules_proc.smk @@ -1,9 +1,9 @@ rule proc_correct_baseline: input: - imzml=multiext("{sample}/raw",".imzML",".ibd"), + imzml=multiext("{sample}/raw", ".imzML", ".ibd"), config="{sample}/pipeline_params.yml", output: - imzml=temp(multiext("{sample}/corrected.original",".imzML",".ibd")) + imzml=temp(multiext("{sample}/corrected.original", ".imzML", ".ibd")), shell: "python -m depiction_targeted_preproc.workflow.proc.correct_baseline " " --input-imzml-path {input.imzml[0]} --config-path {input.config} " @@ -12,10 +12,10 @@ rule proc_correct_baseline: rule proc_pick_peaks: input: - imzml=multiext("{sample}/corrected.original",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.original", ".imzML", ".ibd"), config="{sample}/pipeline_params.yml", output: - imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.peaks", ".imzML", ".ibd"), shell: "python -m depiction_targeted_preproc.workflow.proc.pick_peaks " " --input-imzml-path {input.imzml[0]} --config-path {input.config} " @@ -23,7 +23,7 @@ rule proc_pick_peaks: # TODO currently needed for peak picked data, e.g. from timsTOF -#rule proc_pick_peaks: +# rule proc_pick_peaks: # input: # imzml=multiext("{sample}/corrected.original",".imzML",".ibd"), # config="{sample}/pipeline_params.yml", @@ -36,7 +36,7 @@ rule proc_pick_peaks: # # ## TODO very experimental to be removed later again -#rule proc_filter_peaks: +# rule proc_filter_peaks: # input: # imzml=multiext("{sample}/corrected.peaks_all",".imzML",".ibd"), # output: @@ -46,78 +46,85 @@ rule proc_pick_peaks: # " --input-imzml-path {input.imzml[0]} " # " --output-imzml-path {output.imzml[0]}" + # TODO this should be solved more efficiently in the future, but for now it is solved by calling the script twice rule proc_calibrate_remove_global_shift: input: - imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.peaks", ".imzML", ".ibd"), config="{sample}/pipeline_params.yml", #mass_list="{sample}/mass_list.standards.csv", mass_list="{sample}/mass_list.calibration.csv", output: - imzml=temp(multiext("{sample}/calibrated.tmp",".imzML",".ibd")), + imzml=temp(multiext("{sample}/calibrated.tmp", ".imzML", ".ibd")), shell: "python -m depiction_targeted_preproc.workflow.proc.calibrate " " --input-imzml-path {input.imzml[0]} --config-path {input.config} --mass-list-path {input.mass_list} " " --use-global-constant-shift" " --output-imzml-path {output.imzml[0]}" + rule proc_calibrate_actual: input: - imzml=multiext("{sample}/calibrated.tmp",".imzML",".ibd"), + imzml=multiext("{sample}/calibrated.tmp", ".imzML", ".ibd"), config="{sample}/pipeline_params.yml", mass_list="{sample}/mass_list.calibration.csv", output: - imzml=multiext("{sample}/calibrated",".imzML",".ibd"), + imzml=multiext("{sample}/calibrated", ".imzML", ".ibd"), calib_data="{sample}/calib_data.hdf5", shell: "python -m depiction_targeted_preproc.workflow.proc.calibrate " " --input-imzml-path {input.imzml[0]} --config-path {input.config} --mass-list-path {input.mass_list} " " --output-imzml-path {output.imzml[0]} --output-calib-data-path {output.calib_data}" + rule proc_export_raw_metadata: input: imzml="{sample}/raw.imzML", output: - json="{sample}/raw_metadata.json" + json="{sample}/raw_metadata.json", shell: "python -m depiction_targeted_preproc.workflow.proc.export_raw_metadata " " --input-imzml-path {input.imzml} --output-json-path {output.json}" + rule proc_cluster_kmeans: input: - netcdf="{sample}/images_default.hdf5" + netcdf="{sample}/images_default.hdf5", output: - netcdf="{sample}/cluster_default_kmeans.hdf5" + netcdf="{sample}/cluster_default_kmeans.hdf5", shell: "python -m depiction_targeted_preproc.workflow.proc.cluster_kmeans " " --input-netcdf-path {input.netcdf} --output-netcdf-path {output.netcdf}" + rule proc_cluster_hdbscan: input: - netcdf="{sample}/images_default.hdf5" + netcdf="{sample}/images_default.hdf5", output: - netcdf="{sample}/cluster_default_hdbscan.hdf5" + netcdf="{sample}/cluster_default_hdbscan.hdf5", shell: "python -m depiction_targeted_preproc.workflow.proc.cluster_hdbscan " " --input-netcdf-path {input.netcdf} --output-netcdf-path {output.netcdf}" + rule proc_cluster_stats: input: - netcdf="{sample}/cluster_default_{variant}.hdf5" + netcdf="{sample}/cluster_default_{variant}.hdf5", output: - csv="{sample}/cluster_default_stats_{variant}.csv" + csv="{sample}/cluster_default_stats_{variant}.csv", shell: "python -m depiction_targeted_preproc.workflow.proc.cluster_stats" " --input-netcdf-path {input.netcdf} --output-csv-path {output.csv}" + rule proc_mass_list_preparation: input: - csv="{sample}/mass_list.raw.csv" + csv="{sample}/mass_list.raw.csv", output: calibration_csv="{sample}/mass_list.calibration.csv", standards_csv="{sample}/mass_list.standards.csv", visualization_csv="{sample}/mass_list.visualization.csv", - visualization_mini_csv="{sample}/mass_list.visualization_mini.csv" + visualization_mini_csv="{sample}/mass_list.visualization_mini.csv", shell: "python -m depiction_targeted_preproc.workflow.proc.mass_list_preparation" " --input-csv-path {input.csv}" diff --git a/src/depiction_targeted_preproc/workflow/rules/rules_qc.smk b/src/depiction_targeted_preproc/workflow/rules/rules_qc.smk index cde076c..e8e4b17 100644 --- a/src/depiction_targeted_preproc/workflow/rules/rules_qc.smk +++ b/src/depiction_targeted_preproc/workflow/rules/rules_qc.smk @@ -1,20 +1,21 @@ rule qc_table_marker_distances_baseline: input: - imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.peaks", ".imzML", ".ibd"), mass_list="{sample}/mass_list.visualization.csv", output: - table="{sample}/qc/table_marker_distances_baseline.parquet" + table="{sample}/qc/table_marker_distances_baseline.parquet", shell: "python -m depiction_targeted_preproc.workflow.qc.table_marker_distances" " --imzml-peaks {input.imzml[0]} --mass-list {input.mass_list}" " --output-table {output.table}" + rule qc_table_marker_distances_calib: input: imzml_peaks="{sample}/calibrated.imzML", mass_list="{sample}/mass_list.visualization.csv", output: - table="{sample}/qc/table_marker_distances_calib.parquet" + table="{sample}/qc/table_marker_distances_calib.parquet", shell: "python -m depiction_targeted_preproc.workflow.qc.table_marker_distances" " --imzml-peaks {input.imzml_peaks} --mass-list {input.mass_list}" @@ -24,9 +25,9 @@ rule qc_table_marker_distances_calib: rule qc_plot_marker_presence: input: table_marker_distances_baseline="{sample}/qc/table_marker_distances_baseline.parquet", - table_marker_distances_calib="{sample}/qc/table_marker_distances_calib.parquet" + table_marker_distances_calib="{sample}/qc/table_marker_distances_calib.parquet", output: - pdf="{sample}/qc/plot_marker_presence.pdf" + pdf="{sample}/qc/plot_marker_presence.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_marker_presence" " --table-marker-distances-baseline {input.table_marker_distances_baseline}" @@ -36,9 +37,9 @@ rule qc_plot_marker_presence: rule qc_plot_marker_presence_cv: input: - image_hdf5="{sample}/images_default.hdf5" + image_hdf5="{sample}/images_default.hdf5", output: - pdf="{sample}/qc/plot_marker_presence_cv.pdf" + pdf="{sample}/qc/plot_marker_presence_cv.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_marker_presence_cv" " --image-hdf5 {input.image_hdf5}" @@ -48,9 +49,9 @@ rule qc_plot_marker_presence_cv: rule qc_plot_peak_density_combined: input: table_marker_distances_baseline="{sample}/qc/table_marker_distances_baseline.parquet", - table_marker_distances_calib="{sample}/qc/table_marker_distances_calib.parquet" + table_marker_distances_calib="{sample}/qc/table_marker_distances_calib.parquet", output: - pdf="{sample}/qc/plot_peak_density_combined.pdf" + pdf="{sample}/qc/plot_peak_density_combined.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_peak_density" " --table-marker-distances-baseline {input.table_marker_distances_baseline}" @@ -62,9 +63,9 @@ rule qc_plot_peak_density_combined: rule qc_plot_peak_density_grouped: input: table_marker_distances_baseline="{sample}/qc/table_marker_distances_baseline.parquet", - table_marker_distances_calib="{sample}/qc/table_marker_distances_calib.parquet" + table_marker_distances_calib="{sample}/qc/table_marker_distances_calib.parquet", output: - pdf="{sample}/qc/plot_peak_density_grouped.pdf" + pdf="{sample}/qc/plot_peak_density_grouped.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_peak_density" " --table-marker-distances-baseline {input.table_marker_distances_baseline}" @@ -80,7 +81,7 @@ rule qc_plot_calibration_map: calib_data="{sample}/calib_data.hdf5", mass_list="{sample}/mass_list.visualization.csv", output: - pdf="{sample}/qc/plot_calibration_map.pdf" + pdf="{sample}/qc/plot_calibration_map.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_calibration_map" " --calib-data {input.calib_data} --mass-list {input.mass_list}" @@ -91,54 +92,58 @@ rule qc_plot_calibration_map_v2: input: mass_shifts="{sample}/test_mass_shifts.hdf5", output: - pdf="{sample}/qc/plot_calibration_map_v2.pdf" + pdf="{sample}/qc/plot_calibration_map_v2.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_calibration_map_v2" " --input-mass-shifts {input.mass_shifts}" " --output-pdf {output.pdf}" + rule qc_plot_sample_spectra_before_after: input: imzml_baseline="{sample}/peaks.imzML", imzml_calib="{sample}/calibrated.imzML", mass_list="{sample}/mass_list.visualization.csv", output: - pdf="{sample}/qc/plot_sample_spectra_before_after.pdf" + pdf="{sample}/qc/plot_sample_spectra_before_after.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_sample_spectra_before_after" " --imzml-baseline {input.imzml_baseline} --imzml-calib {input.imzml_calib}" " --mass-list {input.mass_list}" " --output-pdf {output.pdf}" -#TODO + +# TODO rule qc_plot_spectra_for_marker: input: marker_surrounding_baseline="{sample}/qc/table_marker_distances_baseline.parquet", marker_surrounding_calib="{sample}/qc/table_marker_distances_calib.parquet", output: - pdf="{sample}/qc/plot_spectra_for_marker.pdf" + pdf="{sample}/qc/plot_spectra_for_marker.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_spectra_for_marker" " --marker-surrounding-baseline {input.marker_surrounding_baseline}" " --marker-surrounding-calib {input.marker_surrounding_calib}" " --output-pdf {output.pdf}" + rule qc_plot_peak_counts: input: - imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.peaks", ".imzML", ".ibd"), config="{sample}/pipeline_params.yml", output: - pdf="{sample}/qc/plot_peak_counts.pdf" + pdf="{sample}/qc/plot_peak_counts.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_peak_counts" " --config-path {input.config} --imzml-peaks {input.imzml[0]}" " --output-pdf {output.pdf}" + rule qc_plot_scan_direction: input: - imzml=multiext("{sample}/corrected.peaks",".imzML",".ibd"), + imzml=multiext("{sample}/corrected.peaks", ".imzML", ".ibd"), output: - pdf="{sample}/qc/plot_scan_direction.pdf" + pdf="{sample}/qc/plot_scan_direction.pdf", shell: "python -m depiction_targeted_preproc.workflow.qc.plot_scan_direction" " --input-imzml-path {input.imzml[0]}" diff --git a/src/depiction_targeted_preproc/workflow/rules/rules_simulate.smk b/src/depiction_targeted_preproc/workflow/rules/rules_simulate.smk index c1a563a..e99569c 100644 --- a/src/depiction_targeted_preproc/workflow/rules/rules_simulate.smk +++ b/src/depiction_targeted_preproc/workflow/rules/rules_simulate.smk @@ -2,9 +2,10 @@ # virtual "sample" maybe not in the raw directory just to be clear about the intentions # -> but then it will require some adjustment in the code that calls it + rule simulate_create_labels: input: - config = "{sample}_sim/config/simulate.yml", + config="{sample}_sim/config/simulate.yml", output: image="{sample}_sim/true_labels.hdf5", overview_image="{sample}_sim/true_labels_overview.png", @@ -18,7 +19,7 @@ rule simulate_create_mass_list: input: config="{sample}_sim/config/simulate.yml", output: - mass_list="{sample}_sim/mass_list.raw.csv" + mass_list="{sample}_sim/mass_list.raw.csv", shell: "python -m depiction_targeted_preproc.workflow.simulate.create_mass_list" " --config-path {input.config}" @@ -31,7 +32,7 @@ rule simulate_generate_imzml: mass_list="{sample}_sim/mass_list.raw.csv", config="{sample}_sim/config/simulate.yml", output: - imzml=multiext("{sample}_sim/raw",".imzML",".ibd"), + imzml=multiext("{sample}_sim/raw", ".imzML", ".ibd"), shell: "python -m depiction_targeted_preproc.workflow.simulate.generate_imzml" " --input-image-path {input.image} --input-mass-list-path {input.mass_list} --config-path {input.config}" diff --git a/src/depiction_targeted_preproc/workflow/rules/rules_vis.smk b/src/depiction_targeted_preproc/workflow/rules/rules_vis.smk index 2f6173b..b6c633e 100644 --- a/src/depiction_targeted_preproc/workflow/rules/rules_vis.smk +++ b/src/depiction_targeted_preproc/workflow/rules/rules_vis.smk @@ -1,50 +1,56 @@ rule vis_images: input: - imzml=multiext("{sample}/calibrated",".imzML",".ibd"), + imzml=multiext("{sample}/calibrated", ".imzML", ".ibd"), config="{sample}/pipeline_params.yml", - mass_list="{sample}/mass_list.visualization.csv" + mass_list="{sample}/mass_list.visualization.csv", output: - hdf5="{sample}/images_default.hdf5" + hdf5="{sample}/images_default.hdf5", # TODO how can i pass n-jobs nicely here shell: "python -m depiction.tools.cli.cli_generate_ion_images" " --imzml-path {input.imzml[0]} --mass-list-path {input.mass_list}" " --output-hdf5-path {output.hdf5} --n-jobs 10" + rule vis_images_norm: - input: hdf5="{sample}/images_{label}.hdf5" - output: hdf5="{sample}/images_{label}_norm.hdf5" + input: + hdf5="{sample}/images_{label}.hdf5", + output: + hdf5="{sample}/images_{label}_norm.hdf5", shell: "python -m depiction_targeted_preproc.workflow.vis.images_norm " " --input-hdf5-path {input.hdf5} --output-hdf5-path {output.hdf5}" + rule vis_images_ome_tiff: input: netcdf="{sample}/images_{label}.hdf5", - raw_metadata="{sample}/raw_metadata.json" + raw_metadata="{sample}/raw_metadata.json", output: - ometiff="{sample}/images_{label}.ome.tiff" + ometiff="{sample}/images_{label}.ome.tiff", shell: "python -m depiction_targeted_preproc.workflow.vis.images_ome_tiff " " --input-netcdf-path {input.netcdf} --output-ometiff-path {output.ometiff}" " --input-raw-metadata-path {input.raw_metadata}" + rule vis_clustering: input: - netcdf="{sample}/cluster_{label}.hdf5" + netcdf="{sample}/cluster_{label}.hdf5", output: - png="{sample}/cluster_{label}.png" + png="{sample}/cluster_{label}.png", shell: "python -m depiction_targeted_preproc.workflow.vis.clustering " " --input-netcdf-path {input.netcdf} --output-png-path {output.png}" + rule vis_test_mass_shifts: input: calib_hdf5="{sample}/calib_data.hdf5", config="{sample}/pipeline_params.yml", - mass_list="{sample}/mass_list.calibration.csv" + mass_list="{sample}/mass_list.calibration.csv", output: - hdf5="{sample}/test_mass_shifts.hdf5" + hdf5="{sample}/test_mass_shifts.hdf5", shell: "python -m depiction_targeted_preproc.workflow.vis.test_mass_shifts " " --calib-hdf5-path {input.calib_hdf5} --mass-list-path {input.mass_list} "