From 808e944b1df5e85df84a930835e352c3727cbf72 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 08:54:23 +0000 Subject: [PATCH 01/11] Try newer version --- test-environment.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-environment.yml b/test-environment.yml index 3cf67db..8434fd6 100644 --- a/test-environment.yml +++ b/test-environment.yml @@ -1,16 +1,16 @@ name: test dependencies: - - bats + - bats-core - r-optparse - libpng - r-cairo - r-workflowscriptscommon >=0.0.8 - - r-seurat=4.0.0 - - r-uwot <0.1.11 + - r-seurat<=4.3 + # - r-uwot - r-loom - r-svglite - bioconductor-scater - - r-seuratdisk + # - r-seuratdisk - r-remotes - bioconductor-multtest - r-metap From 796e30fe6e76b3da7c253fbf578ab2e066ca3302 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 09:58:34 +0000 Subject: [PATCH 02/11] Seurat disk and micromamba --- .github/workflows/pr.yaml | 31 +++++++++---------------------- test-environment.yml | 2 +- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 3aeaacf..9b4e21a 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -20,32 +20,19 @@ jobs: run: | echo "${GITHUB_WORKSPACE}" >> $GITHUB_PATH - - name: Cache conda - uses: actions/cache@v1 - env: - # Increase this value to reset cache if etc/example-environment.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: - ${{ matrix.os }}-conda-${{ env.CACHE_NUMBER }}-${{hashFiles('test-environment.yml') }} - - - uses: conda-incubator/setup-miniconda@v2 + - uses: mamba-org/setup-micromamba@v1 with: - activate-environment: test + micromamba-version: '1.3.1-0' environment-file: test-environment.yml - mamba-version: "*" - miniforge-variant: Mambaforge - use-mamba: true - miniforge-version: latest - python-version: 3.6 - channels: conda-forge,bioconda,defaults - allow-softlinks: true - channel-priority: flexible - show-channel-urls: true - use-only-tar-bz2: true + init-shell: >- + bash + cache-environment: true + create-args: | + python=${{ matrix.python-version }} + post-cleanup: 'all' - name: Run tests + shell: bash -el {0} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/test-environment.yml b/test-environment.yml index 8434fd6..ada6a37 100644 --- a/test-environment.yml +++ b/test-environment.yml @@ -10,7 +10,7 @@ dependencies: - r-loom - r-svglite - bioconductor-scater - # - r-seuratdisk + - r-seuratdisk - r-remotes - bioconductor-multtest - r-metap From 0082c55948be73d558c671ce9395aed3453963c0 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 10:07:42 +0000 Subject: [PATCH 03/11] Update micromamba install --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 9b4e21a..a662582 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,7 +22,7 @@ jobs: - uses: mamba-org/setup-micromamba@v1 with: - micromamba-version: '1.3.1-0' + micromamba-version: '1.4.4' environment-file: test-environment.yml init-shell: >- bash From 4946ece589f7a1ffeb8efb1105dac798fdc8f0e3 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 10:09:29 +0000 Subject: [PATCH 04/11] Micromamba version --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index a662582..31443b7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,7 +22,7 @@ jobs: - uses: mamba-org/setup-micromamba@v1 with: - micromamba-version: '1.4.4' + micromamba-version: '1.4.5-0' environment-file: test-environment.yml init-shell: >- bash From b3e0c360d0eec2dd611a463c221b1cea42641a08 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 10:11:22 +0000 Subject: [PATCH 05/11] Missing channels new setup --- test-environment.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-environment.yml b/test-environment.yml index ada6a37..3931dfc 100644 --- a/test-environment.yml +++ b/test-environment.yml @@ -1,4 +1,8 @@ name: test +channels: + - defaults + - conda-forge + - bioconda dependencies: - bats-core - r-optparse From 5c22a0b65e225dfb4456f92ac79a289b98b5317b Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 20:45:45 +0000 Subject: [PATCH 06/11] IO tests passing --- r-seurat-scripts-post-install-tests.bats | 2 +- seurat-classify-against-reference.R | 18 ++++++++++++++++++ seurat-convert.R | 12 +++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/r-seurat-scripts-post-install-tests.bats b/r-seurat-scripts-post-install-tests.bats index 73278d7..e298a0e 100755 --- a/r-seurat-scripts-post-install-tests.bats +++ b/r-seurat-scripts-post-install-tests.bats @@ -515,7 +515,7 @@ run rm -rf ${loom_converted_cluster_object}.loom && \ seurat-convert.R -i $singlecellexperiment_converted_cluster_object \ --input-format singlecellexperiment -o $loom_converted_cluster_object \ - --output-format loom + --output-format loom --input-assay NULL echo "status = ${status}" echo "output = ${output}" diff --git a/seurat-classify-against-reference.R b/seurat-classify-against-reference.R index 45a54e7..b7430e8 100755 --- a/seurat-classify-against-reference.R +++ b/seurat-classify-against-reference.R @@ -93,6 +93,13 @@ option_list = list( type = 'character', help = "Dimensional reduction to perform when finding anchors." ), + make_option( + c("--reference_reduction"), + action = "store", + default = "pca", + type = 'character', + help = "Name of dimensional reduction to use from the reference if running the pcaproject workflow. Optionally enables reuse of precomputed reference dimensional reduction. If NULL (default), use a PCA computed on the reference object." + ), make_option( c("--project-query"), action = "store_false", @@ -285,6 +292,16 @@ if (opt$query_format == "singlecellexperiment" | opt$reference_format == "single seurat_query <- read_seurat4_object(input_path = opt$query_file, format = opt$query_format) seurat_reference <- read_seurat4_object(input_path = opt$reference_file, format = opt$reference_format) + +if(!(opt$reference_reduction %in% names(seurat_reference@reductions))) { + print(paste0("Calculating reduction ", opt$reference_reduction," as it is not present in the reference object.")) + if(opt$reference_reduction == "pca") { + seurat_reference <- ScaleData(seurat_reference, verbose = FALSE) + seurat_reference <- RunPCA(seurat_reference, npcs=30, verbose = FALSE) + } else { + stop((paste('Reduction default calculation on reference not implemented for ', opt$reference_reduction, ', please compute previously on reference object.'))) + } +} #make the function work anchor_object <- FindTransferAnchors(seurat_reference, seurat_query, @@ -292,6 +309,7 @@ anchor_object <- FindTransferAnchors(seurat_reference, reference.assay = opt$reference_assay, query.assay = opt$query_assay, reduction = opt$reduction, + reference.reduction = opt$reference_reduction, project.query = opt$project_query, features = opt$features, npcs = opt$npcs, diff --git a/seurat-convert.R b/seurat-convert.R index 6666df8..41a3951 100755 --- a/seurat-convert.R +++ b/seurat-convert.R @@ -39,6 +39,13 @@ option_list <- list( default = "seurat", type = "character", help = "Either seurat, h5seurat, loom, singlecellexperiment or h5seurat (partial support)") +, + make_option( + c("--input-assay"), + action = "store", + default = "RNA", + type = "character", + help = "The assay to be read from the input object, if it corresponds") ) opt <- wsc_parse_args(option_list, @@ -49,9 +56,12 @@ if (!file.exists(opt$input_object_file)) { stop((paste("File", opt$input_object_file, "does not exist"))) } +if(opt$input_assay == "NULL") { + opt$input_assay <- NULL +} seurat_object <- read_seurat4_object(input_path = opt$input_object_file, - format = opt$input_format) + format = opt$input_format, assay = opt$input_assay) write_seurat4_object(seurat_object = seurat_object, output_path = opt$output_object_file, From 1fca307c2568992345187311468b46024745952a Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 20:46:19 +0000 Subject: [PATCH 07/11] improve eval safety --- seurat-find-conserved-markers.R | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/seurat-find-conserved-markers.R b/seurat-find-conserved-markers.R index 1ab446c..9ecd6e4 100755 --- a/seurat-find-conserved-markers.R +++ b/seurat-find-conserved-markers.R @@ -10,6 +10,7 @@ suppressPackageStartupMessages(require(optparse)) suppressPackageStartupMessages(require(scater)) suppressPackageStartupMessages(require(Seurat)) suppressPackageStartupMessages(require(workflowscriptscommon)) +suppressPackageStartupMessages(require(metap)) option_list <- list( make_option( @@ -65,9 +66,9 @@ option_list <- list( make_option( c("--meta-method"), action = "store", - default = "metap::minimump", + default = "minimump", type = "character", - help = "method for combining p-values. Should be a function from the metap package (NOTE: pass the function, not a string)" + help = "method for combining p-values. Should be a function from the metap package: invchisq, invt, logitp, meanp, meanz, maximump, minimump, sumlog, sumz, truncated, votep, wilkinsonp" ), make_option( c("--reduction"), @@ -204,13 +205,19 @@ if (!file.exists(opt$input_object_file)) { stop((paste("File", opt$input_object_file, "does not exist"))) } +list_of_meta_methods <- ls("package:metap") +metap_method <- NULL +if(!is.null(opt$meta_method) && !(opt$meta_method %in% list_of_meta_methods)) { + stop((paste("Metap method requested ", opt$meta_method, " doesn't exist, please choose from: ", list_of_meta_methods))) +} else { + # safer way of running eval parse + opt$meta_method <- eval(parse(text=paste0("metap::", opt$meta_method))) +} load_seurat4_packages_for_format(formats = c(opt$query_format, opt$anchors_format, opt$reference_format)) seurat_object <- read_seurat4_object(input_path = opt$input_object_file, format = opt$input_format) -# transform method name into actual R function. This should probably be sanitised in Galaxy -opt$meta_method <- eval(parse(text=opt$meta_method)) conserved_markers <- FindConservedMarkers(object = seurat_object, ident.1 = opt$ident_1, From 0c5d26cb1206049df97ee34c94a5dde047184163 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sun, 24 Sep 2023 21:10:08 +0000 Subject: [PATCH 08/11] Pass conserved markers tests --- r-seurat-scripts-post-install-tests.bats | 3 ++- test-environment.yml | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/r-seurat-scripts-post-install-tests.bats b/r-seurat-scripts-post-install-tests.bats index e298a0e..5322f92 100755 --- a/r-seurat-scripts-post-install-tests.bats +++ b/r-seurat-scripts-post-install-tests.bats @@ -309,6 +309,7 @@ } @test "Classify against reference" { + # maybe this should be moved after PCA and UMAP of integrated object if [ "$use_existing_outputs" = 'true' ] && [ -f "$classify_result_object" ]; then skip "$classify_result_object exists and use_existing_outputs is set to true" fi @@ -466,7 +467,7 @@ -o $tmp_conserved_markers_fn_object && \ seurat-find-clusters.R -i $tmp_conserved_markers_fn_object --resolution 0.5 \ -o $tmp_conserved_markers_cl_object -t $cluster_text_file".conserved_tmp.txt" && \ - seurat-find-conserved-markers.R -i $tmp_conserved_markers_cl_object --ident-1 6 --ident-2 4 --grouping-var "tech" -o $conserved_markers_result + seurat-find-conserved-markers.R -i $tmp_conserved_markers_cl_object --ident-1 1 --ident-2 2 --grouping-var "tech" -o $conserved_markers_result [ "$status" -eq 0 ] [ -f "$conserved_markers_result" ] diff --git a/test-environment.yml b/test-environment.yml index 3931dfc..fa2ff7a 100644 --- a/test-environment.yml +++ b/test-environment.yml @@ -1,4 +1,4 @@ -name: test +name: seurat-scripts@4.3 channels: - defaults - conda-forge @@ -18,4 +18,5 @@ dependencies: - r-remotes - bioconductor-multtest - r-metap - - pandoc \ No newline at end of file + - pandoc + - bioconductor-limma \ No newline at end of file From 9e64c8c7fd661d02c6005206200a34d96dfd998f Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sat, 2 Mar 2024 10:55:38 +0000 Subject: [PATCH 09/11] Drop macos support --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 31443b7..dca6197 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - os: ["ubuntu-latest", "macos-latest"] + os: ["ubuntu-latest"] defaults: run: shell: bash -l {0} From 461073f2bb38f14836fb581cbc3fe05f98a15947 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Sat, 2 Mar 2024 12:38:35 +0000 Subject: [PATCH 10/11] Move to Seurat 4.4 --- test-environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-environment.yml b/test-environment.yml index fa2ff7a..8edabe7 100644 --- a/test-environment.yml +++ b/test-environment.yml @@ -1,4 +1,4 @@ -name: seurat-scripts@4.3 +name: seurat-scripts@4.4 channels: - defaults - conda-forge @@ -9,7 +9,7 @@ dependencies: - libpng - r-cairo - r-workflowscriptscommon >=0.0.8 - - r-seurat<=4.3 + - r-seurat<=4.4 # - r-uwot - r-loom - r-svglite From 157e8ee355c6ee6641451d92b0cb19ba38b360cf Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Thu, 28 Mar 2024 08:28:35 +0000 Subject: [PATCH 11/11] Explain drop of macOS --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61558e3..204e97d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -# seurat-scripts 4.x.y for Seurat 4.0.0 [![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat)](http://bioconda.github.io/recipes/seurat-scripts/README.html) +# seurat-scripts 4.x.y for Seurat 4.4.0 [![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat)](http://bioconda.github.io/recipes/seurat-scripts/README.html) In order to wrap Seurat's internal workflow in any given workflow language, it's important to have scripts to call each of those steps, which is what this package provides. This version of seurat-scripts uses native conversions to Loom, SCE, Seurat H5 and AnnData. +Please note that given the little man power available to maintain this, we dropped MacOS support for Seurat version 4.4.0 onwards (not all tests were passing and there was no bandwidth to take care of the dependencies issues on both linux and macOS). + ## Install -The recommended method for script installation is via a Bioconda recipe called seurat-scripts. +The recommended method for usage is through the [biocontainer](https://quay.io/repository/biocontainers/seurat-scripts?tab=tags&tag=latest) produced by Bioconda. If needed, scripts installation is via a Bioconda recipe called seurat-scripts. With the [Bioconda channels](https://bioconda.github.io/#set-up-channels) configured the latest release version of the package can be installed via the regular conda install command: