From 06cb10cbc16371dd8fda39e8544155e27ea8577e Mon Sep 17 00:00:00 2001 From: Chananchida Sang-aram VSCODE Date: Thu, 3 Oct 2024 09:00:33 +0200 Subject: [PATCH] split up c2l; skip test for dstg due to stochasticity --- .../test_run_dataset_cell2location.yml | 69 +++++++++++++++++++ .github/workflows/test_run_dataset_python.yml | 4 +- unit-test/test_run_dataset.R | 29 ++++---- 3 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/test_run_dataset_cell2location.yml diff --git a/.github/workflows/test_run_dataset_cell2location.yml b/.github/workflows/test_run_dataset_cell2location.yml new file mode 100644 index 0000000..df6708a --- /dev/null +++ b/.github/workflows/test_run_dataset_cell2location.yml @@ -0,0 +1,69 @@ +name: test run_dataset mode for Python tools +# This workflow runs the pipeline with the minimal test dataset to check that it completes without any syntax errors +on: [ pull_request, workflow_dispatch ] + +jobs: + run_dataset: + name: Run workflow with run_dataset mode + runs-on: ubuntu-latest + strategy: + matrix: + # Nextflow versions: check pipeline minimum and latest edge version + nxf_ver: + - 'NXF_VER=21.04.3' + steps: + - name: Check out pipeline code + uses: actions/checkout@v3 + # with + # lfs: true + + - name: Download test dataset + run: | + wget https://zenodo.org/record/5763377/files/test_data.tar.gz?download=1 -O test_data.tar.gz + tar -xzvf test_data.tar.gz + echo $(ls) + + # - name: Checkout LFS objects + # run: git lfs checkout + + - name: Install Nextflow + run: | + wget -qO- get.nextflow.io | bash + sudo mv nextflow /usr/local/bin/ + export ${{ matrix.nxf_ver }} + nextflow self-update + + - name: Run pipeline with test data + run: | + nextflow run main.nf -profile test,docker --mode run_dataset \ + --methods cell2location + + - name: Upload proportions and metrics + uses: actions/upload-artifact@v3 + with: + name: deconv-proportions-and-metrics + path: | + deconv_proportions/* + results/* + trace.txt + + test_output_run_dataset: + name: Tests outputs of the pipeline + needs: run_dataset + runs-on: ubuntu-latest + container: rocker/tidyverse:3.6.3 + steps: + - name: Check out pipeline code + uses: actions/checkout@v3 + + - name: Download proportions from test run + uses: actions/download-artifact@v3 + with: + name: deconv-proportions-and-metrics + + - name: Check proportions and metrics with testthat + shell: bash + run: | + echo $(ls) + Rscript unit-test/test_run_dataset.R \ + cell2location \ No newline at end of file diff --git a/.github/workflows/test_run_dataset_python.yml b/.github/workflows/test_run_dataset_python.yml index 7e26597..31e8514 100644 --- a/.github/workflows/test_run_dataset_python.yml +++ b/.github/workflows/test_run_dataset_python.yml @@ -36,7 +36,7 @@ jobs: - name: Run pipeline with test data run: | nextflow run main.nf -profile test,docker --mode run_dataset \ - --methods cell2location,stereoscope,destvi,tangram,stride + --methods stereoscope,destvi,tangram,stride - name: Upload proportions and metrics uses: actions/upload-artifact@v3 @@ -66,4 +66,4 @@ jobs: run: | echo $(ls) Rscript unit-test/test_run_dataset.R \ - cell2location,stereoscope,destvi,tangram,stride \ No newline at end of file + stereoscope,destvi,tangram,stride \ No newline at end of file diff --git a/unit-test/test_run_dataset.R b/unit-test/test_run_dataset.R index 5657165..d5f8e4f 100644 --- a/unit-test/test_run_dataset.R +++ b/unit-test/test_run_dataset.R @@ -26,15 +26,16 @@ for (method in methods){ expect_equal(colnames(output_props), celltypenames) # Check 2 - cat(">>> Checking whether proportions are correct...\n") - expected_props <- read.table(paste0("unit-test/test_run_dataset/", - "proportions_", method, "_test_sp_data"), - sep="\t", header=TRUE) - expect_equal(rowSums(output_props), rep(1, 16), tolerance=1e-6) - expect_equal(sum(output_props$L23IT), sum(expected_props$L23IT), tolerance=1e-3) - expect_equal(output_props[15,1:10], expected_props[15,1:10], tolerance=1e-3) + if (method != "dstg"){ + cat(">>> Checking whether proportions are correct...\n") + expected_props <- read.table(paste0("unit-test/test_run_dataset/", + "proportions_", method, "_test_sp_data"), + sep="\t", header=TRUE) + expect_equal(rowSums(output_props), rep(1, 16), tolerance=1e-6) + expect_equal(sum(output_props$L23IT), sum(expected_props$L23IT), tolerance=1e-3) + expect_equal(output_props[15,1:10], expected_props[15,1:10], tolerance=1e-3) + } - # Check 3 cat(">>> Checking whether metrics file is formatted correctly...\n") output_metrics <- read.table(paste0("results/test_sp_data/metrics_", method, "_test_sp_data"), @@ -47,12 +48,14 @@ for (method in methods){ expect_equal(colnames(output_metrics), metric_names) # Check 4 - cat(">>> Checking whether metrics are correct...\n") - expected_metrics <- read.table(paste0("unit-test/test_run_dataset/", - "metrics_", method, "_test_sp_data"), - sep=" ", header=TRUE) + if (method != "dstg"){ + cat(">>> Checking whether metrics are correct...\n") + expected_metrics <- read.table(paste0("unit-test/test_run_dataset/", + "metrics_", method, "_test_sp_data"), + sep=" ", header=TRUE) - expect_equal(output_metrics, expected_metrics, tolerance=1e-3) + expect_equal(output_metrics, expected_metrics, tolerance=1e-3) + } }