Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sainirmayi committed Jun 21, 2024
2 parents 1e06489 + c8473a9 commit aa8ff52
Show file tree
Hide file tree
Showing 55 changed files with 3,174 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: viash-io/viash-actions/setup@v5

Expand Down Expand Up @@ -83,6 +85,8 @@ jobs:
- uses: data-intuitive/reclaim-the-bytes@v2

- uses: actions/checkout@v4
with:
submodules: true

- uses: viash-io/viash-actions/setup@v5

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- uses: viash-io/viash-actions/setup@v5

Expand Down Expand Up @@ -86,6 +87,8 @@ jobs:
- uses: data-intuitive/reclaim-the-bytes@v2

- uses: actions/checkout@v4
with:
submodules: true

- uses: viash-io/viash-actions/setup@v5

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
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
374 changes: 374 additions & 0 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common
Submodule common added at 81d426
21 changes: 21 additions & 0 deletions scripts/add_component.sh
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
4 changes: 4 additions & 0 deletions scripts/build_components.sh
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
9 changes: 9 additions & 0 deletions scripts/download_resources.sh
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
7 changes: 7 additions & 0 deletions scripts/render_readme.sh
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"
35 changes: 35 additions & 0 deletions scripts/run_benchmark.sh
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"
60 changes: 60 additions & 0 deletions scripts/run_benchmark_tw.sh
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 \
22 changes: 22 additions & 0 deletions scripts/test_components.sh
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
38 changes: 38 additions & 0 deletions src/api/comp_control_method.yaml
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
29 changes: 29 additions & 0 deletions src/api/comp_method.yaml
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
31 changes: 31 additions & 0 deletions src/api/comp_metric.yaml
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

33 changes: 33 additions & 0 deletions src/api/comp_process_dataset.yaml
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
Loading

0 comments on commit aa8ff52

Please sign in to comment.