diff --git a/scripts/run_benchmark/param_sweep/mapmycells_params.yaml b/scripts/run_benchmark/param_sweep/mapmycells_params.yaml new file mode 100644 index 000000000..92400a3e9 --- /dev/null +++ b/scripts/run_benchmark/param_sweep/mapmycells_params.yaml @@ -0,0 +1,34 @@ +# Parameter sweep for the mapmycells (Allen cell_type_mapper / MapMyCells) cell-type +# annotation method. Committed source of truth for run_test_mapmycells_nebius.sh (read +# from GitHub via a raw URL, since the Nebius compute env pulls the repo but cannot see +# the launch host's local files). +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf). For every method the workflow builds: +# * one "default" variant using the `default:` args below, and +# * one extra variant per value in each `sweep:` list, with that ONE arg overridden. +# The benchmark varies a SINGLE parameter at a time (a "star" around the default, not +# a full grid), so total mapmycells variants = 1 default + sum(sweep list lengths) = 5. +# +# See src/methods_cell_type_annotation/mapmycells/NOTES.md ("Optimization / tuning") for +# the rationale. +# +# ⚠️ bootstrap_iteration / bootstrap_factor were JUST ADDED to config.vsh.yaml, so the +# build/main container must be rebuilt + pushed before this sweep runs (check-component). +parameters: + mapmycells: + # Baseline (fast anchor). NB the SHIPPED component default is (1, 1.0) = no + # bootstrapping. Here bootstrap_factor is pinned to the tool default 0.9 (not 1.0) + # ON PURPOSE: with factor 1.0 every bootstrap iteration is identical, which would + # make the bootstrap_iteration sweep below inert. 0.9 makes the axis meaningful. + default: + bootstrap_iteration: 1 + bootstrap_factor: 0.9 + sweep: + # bootstrap_iteration: how many times each query cell is re-mapped on a random + # 90% (bootstrap_factor) subset of markers before the majority vote. 1 (the + # default variant above) = single pass; the Allen tool default for bootstrapped + # correlation mapping is 100. Walks the shipped speed-tuned value up toward the + # tool default. 1 is omitted here (covered by the default variant); 100 is the + # slowest / most-robust endpoint. + bootstrap_iteration: [10, 25, 50, 100] diff --git a/scripts/run_benchmark/param_sweeps_full/baysor_params.yaml b/scripts/run_benchmark/param_sweeps_full/baysor_params.yaml new file mode 100644 index 000000000..662348fbe --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/baysor_params.yaml @@ -0,0 +1,32 @@ +# Parameter sweep for the baysor transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in ~/projects/txsim_results/param_sweep_tests/transcript_assignment/baysor +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total baysor variants = 1 default + 6 swept values. +parameters: + baysor: + default: + force_2d: true + min_molecules_per_cell: 50 + scale: -1.0 + scale_std: "25%" + n_clusters: 4 + prior_segmentation_confidence: 0.8 + sweep: + # on front in 2/3 datasets, beats default in 3; picked: 0.2 (front + max distance), 0.5 (distance top-up) + prior_segmentation_confidence: [0.2, 0.5] + # on front in 1/3 datasets, beats default in 3; picked: 10 (front + max distance), 25 (distance top-up) + min_molecules_per_cell: [10, 25] + # on front in 0/3 datasets, beats default in 1; picked: 8 (max distance), 6 (distance top-up) + n_clusters: [6, 8] diff --git a/scripts/run_benchmark/param_sweeps_full/clustermap_params.yaml b/scripts/run_benchmark/param_sweeps_full/clustermap_params.yaml new file mode 100644 index 000000000..56cb34f8c --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/clustermap_params.yaml @@ -0,0 +1,38 @@ +# Parameter sweep for the clustermap transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in ~/projects/txsim_results/param_sweep_tests/transcript_assignment/clustermap +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total clustermap variants = 1 default + 8 swept values. +parameters: + clustermap: + default: + window_size: 700 + xy_radius: 40 + z_radius: 0 + fast_preprocess: false + gauss_blur: true + sigma: 1.0 + pct_filter: 0.0 + LOF: false + contamination: 0 + min_spot_per_cell: 5 + dapi_grid_interval: 5 + cell_num_threshold: 0.1 + sweep: + # on front in 0/3 datasets, beats default in 2; picked: 60 (max distance), 30 (distance top-up), 20 (distance top-up) + xy_radius: [20, 30, 60] + # on front in 0/3 datasets, beats default in 2; picked: 0.01 (max distance), 0.05 (distance top-up), 0.2 (distance top-up) + cell_num_threshold: [0.01, 0.05, 0.2] + # on front in 0/3 datasets, beats default in 2; picked: 0.05 (max distance), 0.1 (distance top-up) + pct_filter: [0.05, 0.1] diff --git a/scripts/run_benchmark/param_sweeps_full/comseg_params.yaml b/scripts/run_benchmark/param_sweeps_full/comseg_params.yaml new file mode 100644 index 000000000..3a5a07ea5 --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/comseg_params.yaml @@ -0,0 +1,32 @@ +# Parameter sweep for the comseg transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/transcript_assignment/comseg +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total comseg variants = 1 default + 7 swept values. +parameters: + comseg: + default: + mean_cell_diameter: 15.0 + max_cell_radius: 25.0 + alpha: 0.5 + min_rna_per_cell: 5 + norm_vector: false + allow_disconnected_polygon: true + sweep: + # on front in 1/3 datasets, beats default in 1; picked: 10.0 (front + max distance), 20.0 (on front) + mean_cell_diameter: [10.0, 20.0] + # on front in 1/3 datasets, beats default in 0; picked: 1.0 (front + max distance), 0.75 (on front), 0.25 (on front) + alpha: [0.25, 0.75, 1.0] + # on front in 0/3 datasets, beats default in 0; picked: 20 (max distance), 10 (distance top-up) + min_rna_per_cell: [10, 20] diff --git a/scripts/run_benchmark/param_sweeps_full/fastreseg_params.yaml b/scripts/run_benchmark/param_sweeps_full/fastreseg_params.yaml new file mode 100644 index 000000000..933261dd0 --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/fastreseg_params.yaml @@ -0,0 +1,30 @@ +# Parameter sweep for the fastreseg transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/transcript_assignment/fastreseg +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total fastreseg variants = 1 default + 0 swept values. +parameters: + fastreseg: + default: + molecular_distance_cutoff: 2.7 + flagCell_lrtest_cutoff: 5 + svmClass_score_cutoff: -2 + cutoff_spatialMerge: 0.5 + sweep: + # on front in 1/3 datasets, beats default in 0; picked: + cutoff_spatialMerge: [] + # on front in 1/3 datasets, beats default in 0; picked: + flagCell_lrtest_cutoff: [] + # on front in 1/3 datasets, beats default in 0; picked: + molecular_distance_cutoff: [] diff --git a/scripts/run_benchmark/param_sweeps_full/moscot_params.yaml b/scripts/run_benchmark/param_sweeps_full/moscot_params.yaml new file mode 100644 index 000000000..26e1b03ec --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/moscot_params.yaml @@ -0,0 +1,32 @@ +# Parameter sweep for the moscot cell type annotation method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_cell_type_annotation.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/cell_type_annotation/moscot +# +# Selection: the 3 parameter families that reach the Pareto front (max per-cell-type +# co-expression similarity, max negative marker purity) in the most datasets, tie-broken by +# how many datasets they beat `default` in and then by Euclidean distance from `default`. +# Within each family: every value on the front in >=1 dataset, plus the highest-distance +# value, topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total moscot variants = 1 default + 7 swept values. +parameters: + moscot: + default: + alpha: 0.8 + epsilon: 0.01 + tau: 0.3 + rank: 500 + batch_size: 1024 + mapping_mode: "max" + sweep: + # on front in 0/3 datasets, beats default in 2; picked: sum (max distance) + mapping_mode: ["sum"] + # on front in 0/3 datasets, beats default in 2; picked: 0.1 (max distance), 0.001 (distance top-up), 0.05 (distance top-up) + epsilon: [0.001, 0.05, 0.1] + # on front in 0/3 datasets, beats default in 1; picked: 0.5 (max distance), 0.7 (distance top-up), 0.9 (distance top-up) + alpha: [0.5, 0.7, 0.9] diff --git a/scripts/run_benchmark/param_sweeps_full/pciseq_params.yaml b/scripts/run_benchmark/param_sweeps_full/pciseq_params.yaml new file mode 100644 index 000000000..347928af0 --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/pciseq_params.yaml @@ -0,0 +1,31 @@ +# Parameter sweep for the pciseq transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/transcript_assignment/pciseq +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total pciseq variants = 1 default + 8 swept values. +parameters: + pciseq: + default: + InsideCellBonus: 2 + MisreadDensity: 1e-05 + nNeighbors: 3 + Inefficiency: 0.2 + rGene: 20 + sweep: + # on front in 3/3 datasets, beats default in 2; picked: 0.001 (front + max distance), 1.0E-4 (on front), 1.0E-6 (distance top-up) + MisreadDensity: [1.0E-6, 1.0E-4, 0.001] + # on front in 2/3 datasets, beats default in 2; picked: 0 (front + max distance), 1 (on front), 6 (distance top-up) + InsideCellBonus: [0, 1, 6] + # on front in 1/3 datasets, beats default in 2; picked: 40 (front + max distance), 10 (distance top-up) + rGene: [10, 40] diff --git a/scripts/run_benchmark/param_sweeps_full/proseg_params.yaml b/scripts/run_benchmark/param_sweeps_full/proseg_params.yaml new file mode 100644 index 000000000..29a3cce10 --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/proseg_params.yaml @@ -0,0 +1,30 @@ +# Parameter sweep for the proseg transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/transcript_assignment/proseg +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total proseg variants = 1 default + 7 swept values. +parameters: + proseg: + default: + cell_compactness: 0.04 + nuclear_reassignment_prob: 0.2 + diffusion_probability: 0.2 + ncomponents: 10 + sweep: + # on front in 1/3 datasets, beats default in 3; picked: 0.03 (front + max distance), 0.06 (distance top-up), 0.02 (distance top-up) + cell_compactness: [0.02, 0.03, 0.06] + # on front in 1/3 datasets, beats default in 2; picked: 0.5 (front + max distance), 0.05 (distance top-up) + nuclear_reassignment_prob: [0.05, 0.5] + # on front in 1/3 datasets, beats default in 1; picked: 15 (on front), 5 (max distance) + ncomponents: [5, 15] diff --git a/scripts/run_benchmark/param_sweeps_full/resolvi_correction_params.yaml b/scripts/run_benchmark/param_sweeps_full/resolvi_correction_params.yaml new file mode 100644 index 000000000..fb2e1cf42 --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/resolvi_correction_params.yaml @@ -0,0 +1,30 @@ +# Parameter sweep for the resolvi_correction expression correction method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_expression_correction.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/expression_correction/resolvi_correction +# +# Selection: the 3 parameter families that reach the Pareto front (max per-cell-type +# co-expression similarity, max negative marker purity) in the most datasets, tie-broken by +# how many datasets they beat `default` in and then by Euclidean distance from `default`. +# Within each family: every value on the front in >=1 dataset, plus the highest-distance +# value, topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total resolvi_correction variants = 1 default + 4 swept values. +parameters: + resolvi_correction: + default: + celltype_key: "cell_type" + n_hidden: 32 + encode_covariates: false + downsample_counts: true + sweep: + # on front in 0/3 datasets, beats default in 3; picked: 128 (max distance), 64 (distance top-up) + n_hidden: [64, 128] + # on front in 0/3 datasets, beats default in 2; picked: false (max distance) + downsample_counts: [false] + # on front in 0/3 datasets, beats default in 1; picked: true (max distance) + encode_covariates: [true] diff --git a/scripts/run_benchmark/param_sweeps_full/run_full_cellposev4_nebius.sh b/scripts/run_benchmark/param_sweeps_full/run_full_cellposev4_nebius.sh index 1f2755d51..dddc9269b 100644 --- a/scripts/run_benchmark/param_sweeps_full/run_full_cellposev4_nebius.sh +++ b/scripts/run_benchmark/param_sweeps_full/run_full_cellposev4_nebius.sh @@ -28,10 +28,10 @@ set -e resources_s3=/scratch/task_ist_preprocessing/datasets publish_dir="/scratch/results/runs/$(date +%Y-%m-%d_%H-%M-%S)_cellposev4_full_sweep" -# The sweep lives in a committed file, read from GitHub at runtime. $params_branch -# defaults to the branch you are on; the file must be pushed there on GitHub. +# The sweep lives in a committed file, read from GitHub at runtime from the `main` +# branch; the file must be committed AND pushed to main on GitHub before launching. params_repo="openproblems-bio/task_ist_preprocessing" -params_branch="$(git rev-parse --abbrev-ref HEAD)" +params_branch="main" params_url="https://raw.githubusercontent.com/${params_repo}/${params_branch}/scripts/run_benchmark/param_sweeps_full/cellposev4_params.yaml" cat > /tmp/params_settings_cellposev4_full.yaml << HERE diff --git a/scripts/run_benchmark/param_sweeps_full/run_full_stardist_nebius.sh b/scripts/run_benchmark/param_sweeps_full/run_full_stardist_nebius.sh index 4b6860bcf..c284ecad2 100644 --- a/scripts/run_benchmark/param_sweeps_full/run_full_stardist_nebius.sh +++ b/scripts/run_benchmark/param_sweeps_full/run_full_stardist_nebius.sh @@ -28,10 +28,10 @@ set -e resources_s3=/scratch/task_ist_preprocessing/datasets publish_dir="/scratch/results/runs/$(date +%Y-%m-%d_%H-%M-%S)_stardist_full_sweep" -# The sweep lives in a committed file, read from GitHub at runtime. $params_branch -# defaults to the branch you are on; the file must be pushed there on GitHub. +# The sweep lives in a committed file, read from GitHub at runtime from the `main` +# branch; the file must be committed AND pushed to main on GitHub before launching. params_repo="openproblems-bio/task_ist_preprocessing" -params_branch="$(git rev-parse --abbrev-ref HEAD)" +params_branch="main" params_url="https://raw.githubusercontent.com/${params_repo}/${params_branch}/scripts/run_benchmark/param_sweeps_full/stardist_params.yaml" cat > /tmp/params_settings_stardist_full.yaml << HERE diff --git a/scripts/run_benchmark/param_sweeps_full/run_full_watershed_nebius.sh b/scripts/run_benchmark/param_sweeps_full/run_full_watershed_nebius.sh index d5397acb8..af549342d 100644 --- a/scripts/run_benchmark/param_sweeps_full/run_full_watershed_nebius.sh +++ b/scripts/run_benchmark/param_sweeps_full/run_full_watershed_nebius.sh @@ -28,10 +28,10 @@ set -e resources_s3=/scratch/task_ist_preprocessing/datasets publish_dir="/scratch/results/runs/$(date +%Y-%m-%d_%H-%M-%S)_watershed_full_sweep" -# The sweep lives in a committed file, read from GitHub at runtime. $params_branch -# defaults to the branch you are on; the file must be pushed there on GitHub. +# The sweep lives in a committed file, read from GitHub at runtime from the `main` +# branch; the file must be committed AND pushed to main on GitHub before launching. params_repo="openproblems-bio/task_ist_preprocessing" -params_branch="$(git rev-parse --abbrev-ref HEAD)" +params_branch="main" params_url="https://raw.githubusercontent.com/${params_repo}/${params_branch}/scripts/run_benchmark/param_sweeps_full/watershed_params.yaml" cat > /tmp/params_settings_watershed_full.yaml << HERE diff --git a/scripts/run_benchmark/param_sweeps_full/segger_params.yaml b/scripts/run_benchmark/param_sweeps_full/segger_params.yaml new file mode 100644 index 000000000..09790f57e --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/segger_params.yaml @@ -0,0 +1,30 @@ +# Parameter sweep for the segger transcript assignment method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_transcript_assignment.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/transcript_assignment/segger +# +# Selection: the 3 parameter families that reach the Pareto front (max cells, +# max negative marker purity) in the most datasets, tie-broken by how many datasets +# they beat `default` in and then by Euclidean distance from `default`. Within each +# family: every value on the front in >=1 dataset, plus the highest-distance value, +# topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total segger variants = 1 default + 6 swept values. +parameters: + segger: + default: + n_epochs: 20 + prediction_graph_buffer_ratio: 0.05 + prediction_mode: "cell" + node_representation_dim: 128 + sweep: + # on front in 1/3 datasets, beats default in 2; picked: 0.1 (on front), 0.25 (max distance), 0.5 (distance top-up) + prediction_graph_buffer_ratio: [0.1, 0.25, 0.5] + # on front in 0/3 datasets, beats default in 2; picked: 60 (max distance), 40 (distance top-up) + n_epochs: [40, 60] + # on front in 0/3 datasets, beats default in 1; picked: nucleus (max distance) + prediction_mode: ["nucleus"] diff --git a/scripts/run_benchmark/param_sweeps_full/split_params.yaml b/scripts/run_benchmark/param_sweeps_full/split_params.yaml new file mode 100644 index 000000000..9359146de --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/split_params.yaml @@ -0,0 +1,32 @@ +# Parameter sweep for the split expression correction method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_expression_correction.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/expression_correction/split +# +# Selection: the 3 parameter families that reach the Pareto front (max per-cell-type +# co-expression similarity, max negative marker purity) in the most datasets, tie-broken by +# how many datasets they beat `default` in and then by Euclidean distance from `default`. +# Within each family: every value on the front in >=1 dataset, plus the highest-distance +# value, topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total split variants = 1 default + 6 swept values. +parameters: + split: + default: + gene_cutoff: 0.0 + fc_cutoff: 0.1 + gene_cutoff_reg: 0.0 + fc_cutoff_reg: 0.1 + umi_min: 20 + umi_min_sigma: 20 + sweep: + # on front in 2/3 datasets, beats default in 3; picked: 100 (front + max distance), 50 (distance top-up) + umi_min: [50, 100] + # on front in 1/3 datasets, beats default in 2; picked: 1.0E-4 (on front), 2.0E-4 (max distance) + gene_cutoff_reg: [1.0E-4, 2.0E-4] + # on front in 0/3 datasets, beats default in 3; picked: 0.75 (max distance), 0.4 (distance top-up) + fc_cutoff_reg: [0.4, 0.75] diff --git a/scripts/run_benchmark/param_sweeps_full/tangram_params.yaml b/scripts/run_benchmark/param_sweeps_full/tangram_params.yaml new file mode 100644 index 000000000..634153dbb --- /dev/null +++ b/scripts/run_benchmark/param_sweeps_full/tangram_params.yaml @@ -0,0 +1,26 @@ +# Parameter sweep for the tangram cell type annotation method - FOLLOW-UP (narrowed) sweep. +# +# AUTO-GENERATED - do not hand-edit; regenerate by rendering +# results/param_sweeps/Yaml_to_heatmap_cell_type_annotation.qmd +# from the sweep results in /Users/daria.romanovskaia/projects/txsim_results/param_sweep_tests/cell_type_annotation/tangram +# +# Selection: the 3 parameter families that reach the Pareto front (max per-cell-type +# co-expression similarity, max negative marker purity) in the most datasets, tie-broken by +# how many datasets they beat `default` in and then by Euclidean distance from `default`. +# Within each family: every value on the front in >=1 dataset, plus the highest-distance +# value, topped up by distance to 3 values where the family has that many. +# +# Consumed by the run_benchmark workflow via the `method_parameters_yaml` setting +# (src/workflows/run_benchmark/main.nf): one "default" variant from `default:`, +# plus one variant per value in each `sweep:` list, varying a SINGLE arg at a time. +# Total tangram variants = 1 default + 4 swept values. +parameters: + tangram: + default: + mode: "clusters" + num_epochs: 1000 + sweep: + # on front in 1/3 datasets, beats default in 1; picked: cells (front + max distance) + mode: ["cells"] + # on front in 0/3 datasets, beats default in 1; picked: 3000 (max distance), 2000 (distance top-up), 100 (distance top-up) + num_epochs: [100, 2000, 3000] diff --git a/src/data_processors/process_dataset/script.py b/src/data_processors/process_dataset/script.py index aeb2b63eb..c1d97e262 100644 --- a/src/data_processors/process_dataset/script.py +++ b/src/data_processors/process_dataset/script.py @@ -447,6 +447,18 @@ def subsample_adata_group_balanced(adata, group_key, n_samples, seed=0): print("No cell_labels found; rasterizing cell_boundaries -> cell_labels", flush=True) sdata_output["cell_labels"] = rasterize_boundaries_to_labels(sdata_output) +# Normalize a single-scale image to a multiscale pyramid. Some loaders build the image with no +# scale_factors (e.g. allen_brain_cell_atlas_merfish's DAPI image), giving a plain DataArray. +# The segmentation methods and custom_segmentation index sdata['image']['scale0'], which only +# exists on a multiscale DataTree, so a single-scale image raises KeyError: 'scale0'. Promote to +# the scale0..scale4 pyramid (Xenium convention); parse() preserves the element's existing +# transform, so don't also pass transformations=. +from xarray import DataArray +from spatialdata.models import Image2DModel +if isinstance(sdata_output["image"], DataArray): + print("Single-scale image; promoting to multiscale pyramid (scale0..scale4)", flush=True) + sdata_output["image"] = Image2DModel.parse(sdata_output["image"], scale_factors=[2, 2, 2, 2]) + # Rechunk to uniform chunks before writing (NOTE: rechunking currently needed, # https://github.com/scverse/spatialdata/issues/929). Run unconditionally so # that uncropped datasets (e.g. 10x Atera, whose store has rectilinear chunk diff --git a/src/methods_cell_type_annotation/mapmycells/config.vsh.yaml b/src/methods_cell_type_annotation/mapmycells/config.vsh.yaml index e37a79d3f..1db974552 100644 --- a/src/methods_cell_type_annotation/mapmycells/config.vsh.yaml +++ b/src/methods_cell_type_annotation/mapmycells/config.vsh.yaml @@ -9,8 +9,36 @@ references: doi: "10.1038/s41586-023-06812-z" __merge__: /src/api/comp_method_cell_type_annotation.yaml - - + +arguments: + # --- MapMyCells correlation-mapping bootstrap knobs (Allen cell_type_mapper) --- + # The mapper labels each query cell by correlating it to the reference cell-type + # profiles. With bootstrapping it repeats that assignment `bootstrap_iteration` times, + # each on a random `bootstrap_factor` fraction of the marker genes, and takes the + # majority vote -> more robust labels. The tool's bootstrapped default is (100, 0.9); + # this component shipped (1, 1.0) = NO bootstrapping (single deterministic pass), the + # fastest setting. See NOTES.md "Optimization / tuning". + - name: --bootstrap_iteration + required: false + direction: input + type: integer + default: 1 + description: | + Number of bootstrap iterations for correlation type-assignment (cell_type_mapper + `type_assignment.bootstrap_iteration`). 1 = no bootstrapping (single pass, fastest); + the tool default for bootstrapped mapping is 100. Only has an effect when + bootstrap_factor < 1.0 (otherwise every iteration is identical). + - name: --bootstrap_factor + required: false + direction: input + type: double + default: 1.0 + description: | + Fraction of marker genes sampled in each bootstrap iteration (cell_type_mapper + `type_assignment.bootstrap_factor`). 1.0 = use all markers every time (no + downsampling, so bootstrapping adds no variance); the tool default for bootstrapped + mapping is 0.9. + resources: - type: python_script path: script.py diff --git a/src/methods_cell_type_annotation/mapmycells/script.py b/src/methods_cell_type_annotation/mapmycells/script.py index d9e9c760a..058a84182 100644 --- a/src/methods_cell_type_annotation/mapmycells/script.py +++ b/src/methods_cell_type_annotation/mapmycells/script.py @@ -9,7 +9,9 @@ 'input_spatial_normalized_counts': 'resources_test/task_ist_preprocessing/mouse_brain_combined/spatial_normalized_counts.h5ad', 'input_scrnaseq_reference': 'resources_test/task_ist_preprocessing/mouse_brain_combined/scrnaseq_reference.h5ad', 'celltype_key': 'cell_type', - "output": 'spatial_with_celltypes.h5ad' + "output": 'spatial_with_celltypes.h5ad', + 'bootstrap_iteration': 1, + 'bootstrap_factor': 1.0, } meta = { "temp_dir": './tmp/'} @@ -78,10 +80,10 @@ os.path.join(meta["temp_dir"], "extended_results.json"), "--flatten", "True", - "--type_assignment.bootstrap_iteration", - "1", + "--type_assignment.bootstrap_iteration", + str(par['bootstrap_iteration']), "--type_assignment.bootstrap_factor", - "1.0" + str(par['bootstrap_factor']), ] subprocess.run(command)