-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/openproblems-bio/task-spati…
- Loading branch information
Showing
55 changed files
with
3,174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "common"] | ||
path = common | ||
url = https://github.com/openproblems-bio/common-resources.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
echo "This script is not supposed to be run directly." | ||
echo "Please run the script step-by-step." | ||
exit 1 | ||
|
||
# create a new component (types: method, metric, control_method) | ||
type="method" | ||
lang="python" # change this to "r" if need be | ||
|
||
common/create_component/create_component \ | ||
--task spatial_decomposition \ | ||
--type $type \ | ||
--name component_name \ | ||
--language $lang | ||
|
||
# TODO: fill in required fields in src/methods/foo/config.vsh.yaml | ||
# TODO: edit src/methods/foo/script.py/R | ||
|
||
# test the component | ||
viash test src/$type/component_name/config.vsh.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Build all components in namespace | ||
viash ns build --parallel --setup cb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Downloading test resources | ||
directories=("common" "spatial_decomposition") | ||
for dir in ${directories[@]}; do | ||
common/sync_resources/sync_resources \ | ||
--input "s3://openproblems-data/resources_test/$dir/cxg_mouse_pancreas_atlas" \ | ||
--output "resources_test/$dir/cxg_mouse_pancreas_atlas" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
common/create_task_readme/create_task_readme \ | ||
--task "spatial_decomposition" \ | ||
--task_dir "src/" \ | ||
--github_url "https://github.com/openproblems-bio/task-spatial-decomposition/tree/main/" \ | ||
--output "README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Process dataset | ||
RAW_DATA=resources_test/common | ||
DATASET_DIR=resources_test/spatial_decomposition | ||
echo "Running process_dataset" | ||
nextflow run . \ | ||
-main-script target/nextflow/workflows/process_datasets/main.nf \ | ||
-profile docker \ | ||
-entry auto \ | ||
-c common/nextflow_helpers/labels_ci.config \ | ||
--input_states "$RAW_DATA/**/state.yaml" \ | ||
--rename_keys 'input:output_dataset' \ | ||
--settings '{"output_spatial_masked": "$id/spatial_masked.h5ad", "output_single_cell": "$id/single_cell_ref.h5ad", "output_solution": "$id/solution.h5ad", "alpha": 1.0, "simulated_data": "$id/dataset_simulated.h5ad"}' \ | ||
--publish_dir "$DATASET_DIR" \ | ||
--output_state '$id/state.yaml' | ||
|
||
# Run benchmark | ||
DATASETS_DIR="resources_test/spatial_decomposition" | ||
OUTPUT_DIR="output/temp" | ||
if [ ! -d "$OUTPUT_DIR" ]; then | ||
mkdir -p "$OUTPUT_DIR" | ||
fi | ||
echo "Running the benchmark" | ||
nextflow run . \ | ||
-main-script target/nextflow/workflows/run_benchmark/main.nf \ | ||
-profile docker \ | ||
-resume \ | ||
-entry auto \ | ||
-c common/nextflow_helpers/labels_ci.config \ | ||
--input_states "$DATASETS_DIR/**/state.yaml" \ | ||
--rename_keys 'input_single_cell:output_single_cell,input_spatial_masked:output_spatial_masked,input_solution:output_solution' \ | ||
--settings '{"output_scores": "scores.yaml", "output_dataset_info": "dataset_info.yaml", "output_method_configs": "method_configs.yaml", "output_metric_configs": "metric_configs.yaml", "output_task_info": "task_info.yaml"}' \ | ||
--publish_dir "$OUTPUT_DIR" \ | ||
--output_state "state.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
### Process datasets | ||
# Simulating spot-resolution spatial data with alpha = 1 | ||
|
||
cat > /tmp/params.yaml << 'HERE' | ||
id: spatial_decomposition_process_datasets | ||
input_states: s3://openproblems-data/resources/datasets/**/log_cp10k/state.yaml | ||
settings: '{"output_spatial_masked": "$id/spatial_masked.h5ad", "output_single_cell": "$id/single_cell_ref.h5ad", "output_solution": "$id/solution.h5ad", "alpha": 1.0, "simulated_data": "$id/dataset_simulated.h5ad"}' | ||
rename_keys: 'input:output_dataset' | ||
output_state: "$id/state.yaml" | ||
publish_dir: s3://openproblems-data/resources/spatial_decomposition/datasets | ||
HERE | ||
|
||
cat > /tmp/nextflow.config << HERE | ||
process { | ||
executor = 'awsbatch' | ||
withName:'.*publishStatesProc' { | ||
memory = '16GB' | ||
disk = '100GB' | ||
} | ||
withLabel:highmem { | ||
memory = '350GB' | ||
} | ||
} | ||
HERE | ||
|
||
tw launch https://github.com/openproblems-bio/task-spatial-decomposition.git \ | ||
--revision main_build \ | ||
--pull-latest \ | ||
--main-script target/nextflow/workflows/process_datasets/main.nf \ | ||
--workspace 53907369739130 \ | ||
--compute-env 6TeIFgV5OY4pJCk8I0bfOh \ | ||
--params-file /tmp/params.yaml \ | ||
--entry-name auto \ | ||
--config /tmp/nextflow.config \ | ||
|
||
|
||
|
||
### Run benchmark | ||
|
||
RUN_ID="run_$(date +%Y-%m-%d_%H-%M-%S)" | ||
publish_dir="s3://openproblems-data/resources/spatial_decomposition/results/${RUN_ID}" | ||
|
||
cat > /tmp/params.yaml << HERE | ||
input_states: s3://openproblems-data/resources/spatial_decomposition/datasets/**/log_cp10k/state.yaml | ||
rename_keys: 'input_single_cell:output_single_cell,input_spatial_masked:output_spatial_masked,input_solution:output_solution' | ||
output_state: "state.yaml" | ||
publish_dir: "$publish_dir" | ||
HERE | ||
|
||
tw launch https://github.com/openproblems-bio/task-spatial-decomposition.git \ | ||
--revision main_build \ | ||
--pull-latest \ | ||
--main-script target/nextflow/workflows/run_benchmark/main.nf \ | ||
--workspace 53907369739130 \ | ||
--compute-env 6TeIFgV5OY4pJCk8I0bfOh \ | ||
--params-file /tmp/params.yaml \ | ||
--entry-name auto \ | ||
--config common/nextflow_helpers/labels_tw.config \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Test all components in a namespace (refer https://viash.io/reference/cli/ns_test.html) | ||
viash ns test --parallel | ||
|
||
# Test individual components | ||
viash test src/methods/nnls/config.vsh.yaml | ||
|
||
|
||
DATASET_DIR=resources_test/spatial_decomposition | ||
|
||
# run one method | ||
viash run src/methods/nnls/config.vsh.yaml -- \ | ||
--input_single_cell $DATASET_DIR/cxg_mouse_pancreas_atlas/single_cell_ref.h5ad \ | ||
--input_spatial_masked $DATASET_DIR/cxg_mouse_pancreas_atlas/spatial_masked.h5ad \ | ||
--output $DATASET_DIR/cxg_mouse_pancreas_atlas/output.h5ad | ||
|
||
# run one metric | ||
viash run src/metrics/r2/config.vsh.yaml -- \ | ||
--input_method $DATASET_DIR/cxg_mouse_pancreas_atlas/output.h5ad \ | ||
--input_solution $DATASET_DIR/cxg_mouse_pancreas_atlas/solution.h5ad \ | ||
--output $DATASET_DIR/cxg_mouse_pancreas_atlas/score.h5ad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
functionality: | ||
namespace: "control_methods" | ||
info: | ||
type: control_method | ||
type_info: | ||
label: Control method | ||
summary: Quality control methods for verifying the pipeline. | ||
description: | | ||
Control methods have the same interface as the regular methods | ||
but also receive the solution object as input. It serves as a | ||
starting point to test the relative accuracy of new methods in | ||
the task, and also as a quality control for the metrics defined | ||
in the task. | ||
arguments: | ||
- name: "--input_single_cell" | ||
__merge__: file_single_cell.yaml | ||
direction: input | ||
required: true | ||
- name: "--input_spatial_masked" | ||
__merge__: file_spatial_masked.yaml | ||
direction: input | ||
required: true | ||
- name: "--input_solution" | ||
__merge__: file_solution.yaml | ||
direction: input | ||
required: true | ||
- name: "--output" | ||
__merge__: file_output.yaml | ||
direction: output | ||
required: true | ||
test_resources: | ||
- type: python_script | ||
path: /common/component_tests/check_method_config.py | ||
- type: python_script | ||
path: /common/component_tests/run_and_check_output.py | ||
- path: /resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
dest: resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
- path: /common/library.bib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
functionality: | ||
namespace: "methods" | ||
info: | ||
type: method | ||
type_info: | ||
label: Method | ||
summary: A spatial composition method. | ||
description: "Method to estimate cell type proportions from spatial and single cell data" | ||
arguments: | ||
- name: "--input_single_cell" | ||
__merge__: file_single_cell.yaml | ||
direction: input | ||
required: true | ||
- name: "--input_spatial_masked" | ||
__merge__: file_spatial_masked.yaml | ||
direction: input | ||
required: true | ||
- name: "--output" | ||
__merge__: file_output.yaml | ||
direction: output | ||
required: true | ||
test_resources: | ||
- type: python_script | ||
path: /common/component_tests/check_method_config.py | ||
- type: python_script | ||
path: /common/component_tests/run_and_check_output.py | ||
- path: /resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
dest: resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
- path: /common/library.bib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
functionality: | ||
namespace: "metrics" | ||
info: | ||
type: metric | ||
type_info: | ||
label: Metric | ||
summary: A spatial decomposition metric. | ||
description: | | ||
A metric for evaluating accuracy of cell type proportion estimate | ||
arguments: | ||
- name: "--input_method" | ||
__merge__: file_output.yaml | ||
direction: input | ||
required: true | ||
- name: "--input_solution" | ||
__merge__: file_solution.yaml | ||
direction: input | ||
required: true | ||
- name: "--output" | ||
__merge__: file_score.yaml | ||
direction: output | ||
required: true | ||
test_resources: | ||
- type: python_script | ||
path: /common/component_tests/check_metric_config.py | ||
- type: python_script | ||
path: /common/component_tests/run_and_check_output.py | ||
- path: /resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
dest: resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
- path: /common/library.bib | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
functionality: | ||
namespace: process_dataset | ||
info: | ||
type: process_dataset | ||
type_info: | ||
label: Data processor | ||
summary: A spatial decomposition dataset processor. | ||
description: | | ||
Prepare a common dataset for the spatial_decomposition task. | ||
arguments: | ||
- name: "--input" | ||
__merge__: file_common_dataset.yaml | ||
direction: input | ||
required: true | ||
- name: "--output_single_cell" | ||
__merge__: file_single_cell.yaml | ||
direction: output | ||
required: true | ||
- name: "--output_spatial_masked" | ||
__merge__: file_spatial_masked.yaml | ||
direction: output | ||
required: true | ||
- name: "--output_solution" | ||
__merge__: file_solution.yaml | ||
direction: output | ||
required: true | ||
test_resources: | ||
- type: python_script | ||
path: /common/component_tests/run_and_check_output.py | ||
# - path: /resources_test/common/cxg_mouse_pancreas_atlas | ||
# dest: resources_test/common/cxg_mouse_pancreas_atlas | ||
- path: /resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas | ||
dest: resources_test/spatial_decomposition/cxg_mouse_pancreas_atlas |
Oops, something went wrong.