From cfb110c6bbbe0b25e060c31c12d7177c1e548aef Mon Sep 17 00:00:00 2001 From: CI Date: Wed, 27 Aug 2025 16:53:27 +0000 Subject: [PATCH] Build branch allow-compressed-output-bundles with version allow-compressed-output-bundles (f951825) Build pipeline: openpipelines-bio.openpipeline-spatial.allow-compressed-oumm2z7 Source commit: https://github.com/openpipelines-bio/openpipeline_spatial/commit/f951825e3f6f7d9ad09b4803220f5af99fe4ae14 Source message: cleanup --- .gitignore | 8 ++- CHANGELOG.md | 8 ++- ruff.toml | 43 ----------- .../config.vsh.yaml | 1 + .../from_cosmx_to_spatialexperiment/script.R | 22 +++++- .../from_cosmx_to_spatialexperiment/test.R | 66 +++++++++++++++++ .../from_xenium_to_spatialdata/script.py | 8 ++- .../config.vsh.yaml | 1 + .../from_xenium_to_spatialexperiment/script.R | 20 +++++- .../from_xenium_to_spatialexperiment/test.R | 72 +++++++++++++++++++ src/utils/unzip_archived_folder.R | 22 ++++++ .../from_cells2stats_to_h5mu/.config.vsh.yaml | 2 +- .../from_cells2stats_to_h5mu | 4 +- .../from_cosmx_to_h5mu/.config.vsh.yaml | 2 +- .../from_cosmx_to_h5mu/from_cosmx_to_h5mu | 4 +- .../.config.vsh.yaml | 4 +- .../from_cosmx_to_spatialexperiment | 21 +++++- .../unzip_archived_folder.R | 22 ++++++ .../.config.vsh.yaml | 2 +- .../from_h5mu_to_spatialexperiment | 4 +- .../from_spatialdata_to_h5mu/.config.vsh.yaml | 2 +- .../from_spatialdata_to_h5mu | 4 +- .../from_xenium_to_h5mu/.config.vsh.yaml | 2 +- .../from_xenium_to_h5mu/from_xenium_to_h5mu | 4 +- .../.config.vsh.yaml | 2 +- .../from_xenium_to_spatialdata | 12 ++-- .../.config.vsh.yaml | 4 +- .../from_xenium_to_spatialexperiment | 21 +++++- .../unzip_archived_folder.R | 22 ++++++ .../filter/subset_cosmx/.config.vsh.yaml | 2 +- .../filter/subset_cosmx/subset_cosmx | 4 +- .../spaceranger_count/.config.vsh.yaml | 2 +- .../spaceranger_count/spaceranger_count | 4 +- .../from_cells2stats_to_h5mu/.config.vsh.yaml | 2 +- .../convert/from_cells2stats_to_h5mu/main.nf | 2 +- .../from_cosmx_to_h5mu/.config.vsh.yaml | 2 +- .../convert/from_cosmx_to_h5mu/main.nf | 2 +- .../.config.vsh.yaml | 4 +- .../from_cosmx_to_spatialexperiment/main.nf | 23 +++++- .../unzip_archived_folder.R | 22 ++++++ .../.config.vsh.yaml | 2 +- .../from_h5mu_to_spatialexperiment/main.nf | 2 +- .../from_spatialdata_to_h5mu/.config.vsh.yaml | 2 +- .../convert/from_spatialdata_to_h5mu/main.nf | 2 +- .../from_xenium_to_h5mu/.config.vsh.yaml | 2 +- .../convert/from_xenium_to_h5mu/main.nf | 2 +- .../.config.vsh.yaml | 2 +- .../from_xenium_to_spatialdata/main.nf | 10 +-- .../.config.vsh.yaml | 4 +- .../from_xenium_to_spatialexperiment/main.nf | 23 +++++- .../unzip_archived_folder.R | 22 ++++++ .../filter/subset_cosmx/.config.vsh.yaml | 2 +- target/nextflow/filter/subset_cosmx/main.nf | 2 +- .../spaceranger_count/.config.vsh.yaml | 2 +- .../mapping/spaceranger_count/main.nf | 2 +- .../spatial_process_samples/.config.vsh.yaml | 2 +- .../spatial_process_samples/main.nf | 2 +- .../workflows/qc/spatial_qc/.config.vsh.yaml | 2 +- .../nextflow/workflows/qc/spatial_qc/main.nf | 2 +- 59 files changed, 452 insertions(+), 115 deletions(-) delete mode 100644 ruff.toml create mode 100644 src/utils/unzip_archived_folder.R create mode 100644 target/executable/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R create mode 100644 target/executable/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R create mode 100644 target/nextflow/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R create mode 100644 target/nextflow/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R diff --git a/.gitignore b/.gitignore index e48038b..15390e7 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,10 @@ trace*.txt # vscode .vscode/launch.json -.vscode/settings.json \ No newline at end of file +.vscode/settings.json + +# linting +ruff.toml +renv.lock +.Rprofile +renv/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bf9cb3..b12f02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ -# openpipeline_spatial 0.0.0 +# openpipeline_spatial x.x.x + +## NEW FUNCTIONALITY + +* `convert`: Updated multiple components to accept spatial output bundles in .zip format (for CosMx, Xenium and Aviti) as input (PR #19). + +# openpipeline_spatial 0.1.0 ## NEW FUNCTIONALITY diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 0b94ce2..0000000 --- a/ruff.toml +++ /dev/null @@ -1,43 +0,0 @@ -# Exclude a variety of commonly ignored directories. -exclude = [ - ".git", - ".pyenv", - ".pytest_cache", - ".ruff_cache", - ".venv", - ".vscode", - "__pypackages__", - "_build", - "build", - "dist", - "node_modules", - "site-packages", -] - -builtins = ["meta"] - - - - -[format] -# Like Black, use double quotes for strings. -quote-style = "double" - -# Like Black, indent with spaces, rather than tabs. -indent-style = "space" - -# Like Black, respect magic trailing commas. -skip-magic-trailing-comma = false - -# Like Black, automatically detect the appropriate line ending. -line-ending = "auto" - -[lint.flake8-pytest-style] -fixture-parentheses = false -mark-parentheses = false - -[lint] -ignore = [ - # module level import not at top of file - "E402" -] \ No newline at end of file diff --git a/src/convert/from_cosmx_to_spatialexperiment/config.vsh.yaml b/src/convert/from_cosmx_to_spatialexperiment/config.vsh.yaml index 12a2ca9..45a3ce4 100644 --- a/src/convert/from_cosmx_to_spatialexperiment/config.vsh.yaml +++ b/src/convert/from_cosmx_to_spatialexperiment/config.vsh.yaml @@ -58,6 +58,7 @@ arguments: resources: - type: r_script path: script.R + - path: /src/utils/unzip_archived_folder.R test_resources: - type: r_script path: test.R diff --git a/src/convert/from_cosmx_to_spatialexperiment/script.R b/src/convert/from_cosmx_to_spatialexperiment/script.R index e6734e1..2de9093 100644 --- a/src/convert/from_cosmx_to_spatialexperiment/script.R +++ b/src/convert/from_cosmx_to_spatialexperiment/script.R @@ -2,7 +2,7 @@ library(SpatialExperimentIO) ### VIASH START par <- list( - input = "resources_test/cosmx/Lung5_Rep2_tiny", + input = "resources_test/cosmx/test2.zip", add_tx_path = TRUE, add_polygon_path = FALSE, add_fov_positions = TRUE, @@ -11,16 +11,34 @@ par <- list( ), output = "spe_cosmx_test.rds" ) +meta <- list( + resources_dir = "src/utils/" +) ### VIASH END +source(paste0(meta$resources_dir, "/unzip_archived_folder.R")) + if (par$add_polygon_path == FALSE && par$add_tx_path == FALSE) { add_parquet_paths <- FALSE } else { add_parquet_paths <- TRUE } +cosmx_output_bundle <- par$input +if (grepl("\\.zip$", cosmx_output_bundle)) { + expected_file_patterns <- c( + "*.csv", + "*.parquet" + ) + + cosmx_output_bundle <- extract_selected_files( + cosmx_output_bundle, + members = expected_file_patterns + ) +} + spe <- readCosmxSXE( - dirName = par$input, + dirName = cosmx_output_bundle, returnType = "SPE", countMatPattern = "exprMat_file.csv", metaDataPattern = "metadata_file.csv", diff --git a/src/convert/from_cosmx_to_spatialexperiment/test.R b/src/convert/from_cosmx_to_spatialexperiment/test.R index bbdd5b3..32d1db9 100644 --- a/src/convert/from_cosmx_to_spatialexperiment/test.R +++ b/src/convert/from_cosmx_to_spatialexperiment/test.R @@ -69,6 +69,72 @@ dim_input <- dim(input) expect_equal(dim_rds, dim_input) +cat("> Checking execution with compressed input\n") + +spe <- paste0(meta[["resources_dir"]], "/Lung5_Rep2_tiny") +out_rds <- "output.rds" + +create_folder_archive <- function(folder_path, archive = "temp_dir.zip") { + old_wd <- getwd() + on.exit(setwd(old_wd)) + setwd(folder_path) + system2("zip", c("-r", archive, ".")) + paste0(folder_path, "/", archive) +} + +zipped_spe <- create_folder_archive(spe) + +cat("> Running ", meta[["name"]], "\n", sep = "") +out <- processx::run( + meta[["executable"]], + c( + "--input", zipped_spe, + "--add_tx_path", TRUE, + "--add_polygon_path", FALSE, + "--output", out_rds + ) +) + +cat("> Checking whether output file exists\n") +expect_equal(out$status, 0) +expect_true(file.exists(out_rds)) + +cat("> Reading output file\n") +obj <- readRDS(file = out_rds) + +cat("> Checking whether Seurat object is in the right format\n") +# Object type +expect_is(obj, "SpatialExperiment") +# Assay structure +expect_equal(names(slot(obj, "assays")), "counts") +# Spatial coordinates +expect_equal( + spatialCoordsNames(obj), + c("CenterX_global_px", "CenterY_global_px") +) +# Alternative experiments +expect_equal(altExpNames(obj), c("NegPrb")) +# Metadata components +expect_named( + metadata(obj), + c("fov_positions", "transcripts"), + ignore.order = TRUE +) +# Parquet paths +expect_true(grepl("\\.parquet$", metadata(obj)[["transcripts"]])) +# Dimensions +input <- readCosmxSXE( + dirName = spe, + addParquetPaths = FALSE, + returnType = "SPE" +) + +dim_rds <- dim(obj) +dim_input <- dim(input) + +expect_equal(dim_rds, dim_input) + + cat("> Checking parameter functionality\n") out_rds_ext <- "output_ext.rds" diff --git a/src/convert/from_xenium_to_spatialdata/script.py b/src/convert/from_xenium_to_spatialdata/script.py index 2dc15a8..c5b39c6 100644 --- a/src/convert/from_xenium_to_spatialdata/script.py +++ b/src/convert/from_xenium_to_spatialdata/script.py @@ -28,11 +28,13 @@ from unzip_archived_folder import unzip_archived_folder logger = setup_logger() logger.info("Reading in Xenium data...") -if zipfile.is_zipfile(par["input"]): - par["input"] = unzip_archived_folder(par["input"]) +if zipfile.is_zipfile(par["input"]): + xenium_output_bundle = unzip_archived_folder(par["input"]) +else: + xenium_output_bundle = par["input"] sdata = xenium( - par["input"], + xenium_output_bundle, cells_boundaries=par["cells_boundaries"], nucleus_boundaries=par["nucleus_boundaries"], cells_as_circles=par["cells_as_circles"], diff --git a/src/convert/from_xenium_to_spatialexperiment/config.vsh.yaml b/src/convert/from_xenium_to_spatialexperiment/config.vsh.yaml index 2c6d45d..569a44c 100644 --- a/src/convert/from_xenium_to_spatialexperiment/config.vsh.yaml +++ b/src/convert/from_xenium_to_spatialexperiment/config.vsh.yaml @@ -51,6 +51,7 @@ arguments: resources: - type: r_script path: script.R + - path: /src/utils/unzip_archived_folder.R test_resources: - type: r_script path: test.R diff --git a/src/convert/from_xenium_to_spatialexperiment/script.R b/src/convert/from_xenium_to_spatialexperiment/script.R index 4060410..66f2385 100644 --- a/src/convert/from_xenium_to_spatialexperiment/script.R +++ b/src/convert/from_xenium_to_spatialexperiment/script.R @@ -11,11 +11,29 @@ par <- list( ), output = "spe_test.rds" ) +meta <- list( + resources_dir = "src/utils/" +) ### VIASH END +source(paste0(meta$resources_dir, "/unzip_archived_folder.R")) + +xenium_output_bundle <- par$input +if (grepl("\\.zip$", xenium_output_bundle)) { + expected_file_patterns <- c( + "cell_feature_matrix.h5", + "*.parquet", + "experiment.xenium" + ) + + xenium_output_bundle <- extract_selected_files( + xenium_output_bundle, + members = expected_file_patterns + ) +} spe <- readXeniumSXE( - dirName = par$input, + dirName = xenium_output_bundle, returnType = "SPE", countMatPattern = "cell_feature_matrix.h5", metaDataPattern = "cells.parquet", diff --git a/src/convert/from_xenium_to_spatialexperiment/test.R b/src/convert/from_xenium_to_spatialexperiment/test.R index 22f1095..6055f61 100644 --- a/src/convert/from_xenium_to_spatialexperiment/test.R +++ b/src/convert/from_xenium_to_spatialexperiment/test.R @@ -71,6 +71,78 @@ dim_input <- dim(input) expect_equal(dim_rds, dim_input) + +cat("> Checking execution with compressed input\n") + +spe <- paste0( + meta[["resources_dir"]], + "/xenium_tiny" +) +out_rds <- "output.rds" + +create_folder_archive <- function(folder_path, archive = "temp_dir.zip") { + old_wd <- getwd() + on.exit(setwd(old_wd)) + setwd(folder_path) + system2("zip", c("-r", archive, ".")) + paste0(folder_path, "/", archive) +} + +zipped_spe <- create_folder_archive(spe) + +cat("> Running ", meta[["name"]], "\n", sep = "") +out <- processx::run( + meta[["executable"]], + c( + "--input", zipped_spe, + "--output", out_rds + ) +) + +cat("> Checking whether output file exists\n") +expect_equal(out$status, 0) +expect_true(file.exists(out_rds)) + +cat("> Reading output file\n") +obj <- readRDS(file = out_rds) + +cat("> Checking whether Seurat object is in the right format\n") +# Object type +expect_is(obj, "SpatialExperiment") +# Assay structure +expect_equal(names(slot(obj, "assays")), "counts") +# Spatial coordinates +expect_equal(spatialCoordsNames(obj), c("x_centroid", "y_centroid")) +# Alternative experiments +expect_equal( + altExpNames(obj), + c("NegControlProbe", "UnassignedCodeword", "NegControlCodeword") +) +# Metadata components +metadata_components <- c( + "experiment.xenium", "transcripts", "cell_boundaries", "nucleus_boundaries" +) +expect_named( + metadata(obj), + metadata_components, + ignore.order = TRUE +) +# Parquet paths +parquet_components <- c("transcripts", "cell_boundaries", "nucleus_boundaries") +for (component in parquet_components) { + expect_true(grepl("\\.parquet$", metadata(obj)[[component]])) +} +# Dimensions +input <- readXeniumSXE( + dirName = spe, + returnType = "SPE" +) +dim_rds <- dim(obj) +dim_input <- dim(input) + +expect_equal(dim_rds, dim_input) + + cat("> Checking parameter functionality\n") out_rds_ext <- "output_ext.rds" diff --git a/src/utils/unzip_archived_folder.R b/src/utils/unzip_archived_folder.R new file mode 100644 index 0000000..78966bc --- /dev/null +++ b/src/utils/unzip_archived_folder.R @@ -0,0 +1,22 @@ +extract_selected_files <- function(zip_path, members) { + # Create a temporary directory for extraction + temp_dir <- tempfile("unzip_dir_") + dir.create(temp_dir) + + # List all files in the archive + all_files <- utils::unzip(zip_path, list = TRUE)$Name + + # Find files matching any of the glob patterns in 'members' + selected <- unique(unlist( + lapply(members, function(pattern) { + regex <- glob2rx(pattern) + grep(regex, all_files, value = TRUE) + }) + )) + + # Extract only the selected files + utils::unzip(zip_path, files = selected, exdir = temp_dir) + + # Return the path to the extracted folder + file.path(temp_dir) +} diff --git a/target/executable/convert/from_cells2stats_to_h5mu/.config.vsh.yaml b/target/executable/convert/from_cells2stats_to_h5mu/.config.vsh.yaml index 2d6a232..283470f 100644 --- a/target/executable/convert/from_cells2stats_to_h5mu/.config.vsh.yaml +++ b/target/executable/convert/from_cells2stats_to_h5mu/.config.vsh.yaml @@ -296,7 +296,7 @@ build_info: output: "target/executable/convert/from_cells2stats_to_h5mu" executable: "target/executable/convert/from_cells2stats_to_h5mu/from_cells2stats_to_h5mu" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_cells2stats_to_h5mu/from_cells2stats_to_h5mu b/target/executable/convert/from_cells2stats_to_h5mu/from_cells2stats_to_h5mu index dd8b98f..dd0b2ac 100755 --- a/target/executable/convert/from_cells2stats_to_h5mu/from_cells2stats_to_h5mu +++ b/target/executable/convert/from_cells2stats_to_h5mu/from_cells2stats_to_h5mu @@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \ LABEL org.opencontainers.image.authors="Dorien Roosen" LABEL org.opencontainers.image.description="Companion container for running component convert from_cells2stats_to_h5mu" -LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:54Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/executable/convert/from_cosmx_to_h5mu/.config.vsh.yaml b/target/executable/convert/from_cosmx_to_h5mu/.config.vsh.yaml index 107b11f..cc817a1 100644 --- a/target/executable/convert/from_cosmx_to_h5mu/.config.vsh.yaml +++ b/target/executable/convert/from_cosmx_to_h5mu/.config.vsh.yaml @@ -231,7 +231,7 @@ build_info: output: "target/executable/convert/from_cosmx_to_h5mu" executable: "target/executable/convert/from_cosmx_to_h5mu/from_cosmx_to_h5mu" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_cosmx_to_h5mu/from_cosmx_to_h5mu b/target/executable/convert/from_cosmx_to_h5mu/from_cosmx_to_h5mu index a756057..3803876 100755 --- a/target/executable/convert/from_cosmx_to_h5mu/from_cosmx_to_h5mu +++ b/target/executable/convert/from_cosmx_to_h5mu/from_cosmx_to_h5mu @@ -459,9 +459,9 @@ RUN pip install --upgrade pip && \ LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz" LABEL org.opencontainers.image.description="Companion container for running component convert from_cosmx_to_h5mu" -LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:55Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/executable/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml b/target/executable/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml index b270d10..d6cb8f0 100644 --- a/target/executable/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml +++ b/target/executable/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml @@ -98,6 +98,8 @@ resources: - type: "r_script" path: "script.R" is_executable: true +- type: "file" + path: "unzip_archived_folder.R" - type: "file" path: "nextflow_labels.config" dest: "nextflow_labels.config" @@ -232,7 +234,7 @@ build_info: output: "target/executable/convert/from_cosmx_to_spatialexperiment" executable: "target/executable/convert/from_cosmx_to_spatialexperiment/from_cosmx_to_spatialexperiment" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_cosmx_to_spatialexperiment/from_cosmx_to_spatialexperiment b/target/executable/convert/from_cosmx_to_spatialexperiment/from_cosmx_to_spatialexperiment index 84d8eac..6429893 100755 --- a/target/executable/convert/from_cosmx_to_spatialexperiment/from_cosmx_to_spatialexperiment +++ b/target/executable/convert/from_cosmx_to_spatialexperiment/from_cosmx_to_spatialexperiment @@ -457,9 +457,9 @@ RUN Rscript -e 'options(warn = 2); if (!requireNamespace("BiocManager", quietly LABEL org.opencontainers.image.authors="Dorien Roosen" LABEL org.opencontainers.image.description="Companion container for running component convert from_cosmx_to_spatialexperiment" -LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:54Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER @@ -1221,14 +1221,29 @@ rm(.viash_orig_warn) ### VIASH END +source(paste0(meta\$resources_dir, "/unzip_archived_folder.R")) + if (par\$add_polygon_path == FALSE && par\$add_tx_path == FALSE) { add_parquet_paths <- FALSE } else { add_parquet_paths <- TRUE } +cosmx_output_bundle <- par\$input +if (grepl("\\\\.zip\$", cosmx_output_bundle)) { + expected_file_patterns <- c( + "*.csv", + "*.parquet" + ) + + cosmx_output_bundle <- extract_selected_files( + cosmx_output_bundle, + members = expected_file_patterns + ) +} + spe <- readCosmxSXE( - dirName = par\$input, + dirName = cosmx_output_bundle, returnType = "SPE", countMatPattern = "exprMat_file.csv", metaDataPattern = "metadata_file.csv", diff --git a/target/executable/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R b/target/executable/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R new file mode 100644 index 0000000..78966bc --- /dev/null +++ b/target/executable/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R @@ -0,0 +1,22 @@ +extract_selected_files <- function(zip_path, members) { + # Create a temporary directory for extraction + temp_dir <- tempfile("unzip_dir_") + dir.create(temp_dir) + + # List all files in the archive + all_files <- utils::unzip(zip_path, list = TRUE)$Name + + # Find files matching any of the glob patterns in 'members' + selected <- unique(unlist( + lapply(members, function(pattern) { + regex <- glob2rx(pattern) + grep(regex, all_files, value = TRUE) + }) + )) + + # Extract only the selected files + utils::unzip(zip_path, files = selected, exdir = temp_dir) + + # Return the path to the extracted folder + file.path(temp_dir) +} diff --git a/target/executable/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml b/target/executable/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml index b318869..f0f9d79 100644 --- a/target/executable/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml +++ b/target/executable/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml @@ -224,7 +224,7 @@ build_info: output: "target/executable/convert/from_h5mu_to_spatialexperiment" executable: "target/executable/convert/from_h5mu_to_spatialexperiment/from_h5mu_to_spatialexperiment" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_h5mu_to_spatialexperiment/from_h5mu_to_spatialexperiment b/target/executable/convert/from_h5mu_to_spatialexperiment/from_h5mu_to_spatialexperiment index 0f70996..b867120 100755 --- a/target/executable/convert/from_h5mu_to_spatialexperiment/from_h5mu_to_spatialexperiment +++ b/target/executable/convert/from_h5mu_to_spatialexperiment/from_h5mu_to_spatialexperiment @@ -458,9 +458,9 @@ RUN Rscript -e 'options(warn = 2); if (!requireNamespace("remotes", quietly = TR LABEL org.opencontainers.image.authors="Dorien Roosen" LABEL org.opencontainers.image.description="Companion container for running component convert from_h5mu_to_spatialexperiment" -LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:55Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/executable/convert/from_spatialdata_to_h5mu/.config.vsh.yaml b/target/executable/convert/from_spatialdata_to_h5mu/.config.vsh.yaml index 9abe0fc..946f0c6 100644 --- a/target/executable/convert/from_spatialdata_to_h5mu/.config.vsh.yaml +++ b/target/executable/convert/from_spatialdata_to_h5mu/.config.vsh.yaml @@ -220,7 +220,7 @@ build_info: output: "target/executable/convert/from_spatialdata_to_h5mu" executable: "target/executable/convert/from_spatialdata_to_h5mu/from_spatialdata_to_h5mu" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_spatialdata_to_h5mu/from_spatialdata_to_h5mu b/target/executable/convert/from_spatialdata_to_h5mu/from_spatialdata_to_h5mu index 6389f9c..0b0dbe2 100755 --- a/target/executable/convert/from_spatialdata_to_h5mu/from_spatialdata_to_h5mu +++ b/target/executable/convert/from_spatialdata_to_h5mu/from_spatialdata_to_h5mu @@ -459,9 +459,9 @@ RUN pip install --upgrade pip && \ LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz" LABEL org.opencontainers.image.description="Companion container for running component convert from_spatialdata_to_h5mu" -LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:55Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/executable/convert/from_xenium_to_h5mu/.config.vsh.yaml b/target/executable/convert/from_xenium_to_h5mu/.config.vsh.yaml index e321876..fbc4af1 100644 --- a/target/executable/convert/from_xenium_to_h5mu/.config.vsh.yaml +++ b/target/executable/convert/from_xenium_to_h5mu/.config.vsh.yaml @@ -239,7 +239,7 @@ build_info: output: "target/executable/convert/from_xenium_to_h5mu" executable: "target/executable/convert/from_xenium_to_h5mu/from_xenium_to_h5mu" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_xenium_to_h5mu/from_xenium_to_h5mu b/target/executable/convert/from_xenium_to_h5mu/from_xenium_to_h5mu index 83af172..050ae5e 100755 --- a/target/executable/convert/from_xenium_to_h5mu/from_xenium_to_h5mu +++ b/target/executable/convert/from_xenium_to_h5mu/from_xenium_to_h5mu @@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \ LABEL org.opencontainers.image.authors="Dorien Roosen" LABEL org.opencontainers.image.description="Companion container for running component convert from_xenium_to_h5mu" -LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:54Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/executable/convert/from_xenium_to_spatialdata/.config.vsh.yaml b/target/executable/convert/from_xenium_to_spatialdata/.config.vsh.yaml index 32bdbc1..11ce2bf 100644 --- a/target/executable/convert/from_xenium_to_spatialdata/.config.vsh.yaml +++ b/target/executable/convert/from_xenium_to_spatialdata/.config.vsh.yaml @@ -320,7 +320,7 @@ build_info: output: "target/executable/convert/from_xenium_to_spatialdata" executable: "target/executable/convert/from_xenium_to_spatialdata/from_xenium_to_spatialdata" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_xenium_to_spatialdata/from_xenium_to_spatialdata b/target/executable/convert/from_xenium_to_spatialdata/from_xenium_to_spatialdata index ce37e3d..c456434 100755 --- a/target/executable/convert/from_xenium_to_spatialdata/from_xenium_to_spatialdata +++ b/target/executable/convert/from_xenium_to_spatialdata/from_xenium_to_spatialdata @@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \ LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz" LABEL org.opencontainers.image.description="Companion container for running component convert from_xenium_to_spatialdata" -LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:55Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER @@ -1392,11 +1392,13 @@ from unzip_archived_folder import unzip_archived_folder logger = setup_logger() logger.info("Reading in Xenium data...") -if zipfile.is_zipfile(par["input"]): - par["input"] = unzip_archived_folder(par["input"]) +if zipfile.is_zipfile(par["input"]): + xenium_output_bundle = unzip_archived_folder(par["input"]) +else: + xenium_output_bundle = par["input"] sdata = xenium( - par["input"], + xenium_output_bundle, cells_boundaries=par["cells_boundaries"], nucleus_boundaries=par["nucleus_boundaries"], cells_as_circles=par["cells_as_circles"], diff --git a/target/executable/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml b/target/executable/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml index a90536c..5478cb8 100644 --- a/target/executable/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml +++ b/target/executable/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml @@ -88,6 +88,8 @@ resources: - type: "r_script" path: "script.R" is_executable: true +- type: "file" + path: "unzip_archived_folder.R" - type: "file" path: "nextflow_labels.config" dest: "nextflow_labels.config" @@ -222,7 +224,7 @@ build_info: output: "target/executable/convert/from_xenium_to_spatialexperiment" executable: "target/executable/convert/from_xenium_to_spatialexperiment/from_xenium_to_spatialexperiment" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/convert/from_xenium_to_spatialexperiment/from_xenium_to_spatialexperiment b/target/executable/convert/from_xenium_to_spatialexperiment/from_xenium_to_spatialexperiment index 81642d3..6ba1bbb 100755 --- a/target/executable/convert/from_xenium_to_spatialexperiment/from_xenium_to_spatialexperiment +++ b/target/executable/convert/from_xenium_to_spatialexperiment/from_xenium_to_spatialexperiment @@ -457,9 +457,9 @@ RUN Rscript -e 'options(warn = 2); if (!requireNamespace("BiocManager", quietly LABEL org.opencontainers.image.authors="Dorien Roosen" LABEL org.opencontainers.image.description="Companion container for running component convert from_xenium_to_spatialexperiment" -LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:54Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER @@ -1195,9 +1195,24 @@ rm(.viash_orig_warn) ### VIASH END +source(paste0(meta\$resources_dir, "/unzip_archived_folder.R")) + +xenium_output_bundle <- par\$input +if (grepl("\\\\.zip\$", xenium_output_bundle)) { + expected_file_patterns <- c( + "cell_feature_matrix.h5", + "*.parquet", + "experiment.xenium" + ) + + xenium_output_bundle <- extract_selected_files( + xenium_output_bundle, + members = expected_file_patterns + ) +} spe <- readXeniumSXE( - dirName = par\$input, + dirName = xenium_output_bundle, returnType = "SPE", countMatPattern = "cell_feature_matrix.h5", metaDataPattern = "cells.parquet", diff --git a/target/executable/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R b/target/executable/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R new file mode 100644 index 0000000..78966bc --- /dev/null +++ b/target/executable/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R @@ -0,0 +1,22 @@ +extract_selected_files <- function(zip_path, members) { + # Create a temporary directory for extraction + temp_dir <- tempfile("unzip_dir_") + dir.create(temp_dir) + + # List all files in the archive + all_files <- utils::unzip(zip_path, list = TRUE)$Name + + # Find files matching any of the glob patterns in 'members' + selected <- unique(unlist( + lapply(members, function(pattern) { + regex <- glob2rx(pattern) + grep(regex, all_files, value = TRUE) + }) + )) + + # Extract only the selected files + utils::unzip(zip_path, files = selected, exdir = temp_dir) + + # Return the path to the extracted folder + file.path(temp_dir) +} diff --git a/target/executable/filter/subset_cosmx/.config.vsh.yaml b/target/executable/filter/subset_cosmx/.config.vsh.yaml index 350ed0c..95d0ea1 100644 --- a/target/executable/filter/subset_cosmx/.config.vsh.yaml +++ b/target/executable/filter/subset_cosmx/.config.vsh.yaml @@ -227,7 +227,7 @@ build_info: output: "target/executable/filter/subset_cosmx" executable: "target/executable/filter/subset_cosmx/subset_cosmx" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/filter/subset_cosmx/subset_cosmx b/target/executable/filter/subset_cosmx/subset_cosmx index a20a644..812482d 100755 --- a/target/executable/filter/subset_cosmx/subset_cosmx +++ b/target/executable/filter/subset_cosmx/subset_cosmx @@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \ LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz" LABEL org.opencontainers.image.description="Companion container for running component filter subset_cosmx" -LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:54Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/executable/mapping/spaceranger_count/.config.vsh.yaml b/target/executable/mapping/spaceranger_count/.config.vsh.yaml index 92b8e1c..c8017f4 100644 --- a/target/executable/mapping/spaceranger_count/.config.vsh.yaml +++ b/target/executable/mapping/spaceranger_count/.config.vsh.yaml @@ -426,7 +426,7 @@ build_info: output: "target/executable/mapping/spaceranger_count" executable: "target/executable/mapping/spaceranger_count/spaceranger_count" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/executable/mapping/spaceranger_count/spaceranger_count b/target/executable/mapping/spaceranger_count/spaceranger_count index 3971e28..556cee6 100755 --- a/target/executable/mapping/spaceranger_count/spaceranger_count +++ b/target/executable/mapping/spaceranger_count/spaceranger_count @@ -453,9 +453,9 @@ apt upgrade -y && apt install -y procps && rm -rf /var/lib/apt/lists/* LABEL org.opencontainers.image.authors="Jakub Majercik" LABEL org.opencontainers.image.description="Companion container for running component mapping spaceranger_count" -LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z" +LABEL org.opencontainers.image.created="2025-08-27T16:31:54Z" LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial" -LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628" +LABEL org.opencontainers.image.revision="f951825e3f6f7d9ad09b4803220f5af99fe4ae14" LABEL org.opencontainers.image.version="allow-compressed-output-bundles" VIASHDOCKER diff --git a/target/nextflow/convert/from_cells2stats_to_h5mu/.config.vsh.yaml b/target/nextflow/convert/from_cells2stats_to_h5mu/.config.vsh.yaml index d1033db..526281e 100644 --- a/target/nextflow/convert/from_cells2stats_to_h5mu/.config.vsh.yaml +++ b/target/nextflow/convert/from_cells2stats_to_h5mu/.config.vsh.yaml @@ -296,7 +296,7 @@ build_info: output: "target/nextflow/convert/from_cells2stats_to_h5mu" executable: "target/nextflow/convert/from_cells2stats_to_h5mu/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_cells2stats_to_h5mu/main.nf b/target/nextflow/convert/from_cells2stats_to_h5mu/main.nf index 93dbd5a..de02591 100644 --- a/target/nextflow/convert/from_cells2stats_to_h5mu/main.nf +++ b/target/nextflow/convert/from_cells2stats_to_h5mu/main.nf @@ -3393,7 +3393,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_cells2stats_to_h5mu", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/convert/from_cosmx_to_h5mu/.config.vsh.yaml b/target/nextflow/convert/from_cosmx_to_h5mu/.config.vsh.yaml index 27b96e5..199a997 100644 --- a/target/nextflow/convert/from_cosmx_to_h5mu/.config.vsh.yaml +++ b/target/nextflow/convert/from_cosmx_to_h5mu/.config.vsh.yaml @@ -231,7 +231,7 @@ build_info: output: "target/nextflow/convert/from_cosmx_to_h5mu" executable: "target/nextflow/convert/from_cosmx_to_h5mu/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_cosmx_to_h5mu/main.nf b/target/nextflow/convert/from_cosmx_to_h5mu/main.nf index f314778..4647c26 100644 --- a/target/nextflow/convert/from_cosmx_to_h5mu/main.nf +++ b/target/nextflow/convert/from_cosmx_to_h5mu/main.nf @@ -3342,7 +3342,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_cosmx_to_h5mu", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml b/target/nextflow/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml index d2b75de..fbbb028 100644 --- a/target/nextflow/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml +++ b/target/nextflow/convert/from_cosmx_to_spatialexperiment/.config.vsh.yaml @@ -98,6 +98,8 @@ resources: - type: "r_script" path: "script.R" is_executable: true +- type: "file" + path: "unzip_archived_folder.R" - type: "file" path: "nextflow_labels.config" dest: "nextflow_labels.config" @@ -232,7 +234,7 @@ build_info: output: "target/nextflow/convert/from_cosmx_to_spatialexperiment" executable: "target/nextflow/convert/from_cosmx_to_spatialexperiment/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_cosmx_to_spatialexperiment/main.nf b/target/nextflow/convert/from_cosmx_to_spatialexperiment/main.nf index a5499af..c1e88c2 100644 --- a/target/nextflow/convert/from_cosmx_to_spatialexperiment/main.nf +++ b/target/nextflow/convert/from_cosmx_to_spatialexperiment/main.nf @@ -3158,6 +3158,10 @@ meta = [ "path" : "script.R", "is_executable" : true }, + { + "type" : "file", + "path" : "/src/utils/unzip_archived_folder.R" + }, { "type" : "file", "path" : "/src/workflows/utils/labels.config", @@ -3322,7 +3326,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_cosmx_to_spatialexperiment", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { @@ -3418,14 +3422,29 @@ rm(.viash_orig_warn) ### VIASH END +source(paste0(meta\\$resources_dir, "/unzip_archived_folder.R")) + if (par\\$add_polygon_path == FALSE && par\\$add_tx_path == FALSE) { add_parquet_paths <- FALSE } else { add_parquet_paths <- TRUE } +cosmx_output_bundle <- par\\$input +if (grepl("\\\\\\\\.zip\\$", cosmx_output_bundle)) { + expected_file_patterns <- c( + "*.csv", + "*.parquet" + ) + + cosmx_output_bundle <- extract_selected_files( + cosmx_output_bundle, + members = expected_file_patterns + ) +} + spe <- readCosmxSXE( - dirName = par\\$input, + dirName = cosmx_output_bundle, returnType = "SPE", countMatPattern = "exprMat_file.csv", metaDataPattern = "metadata_file.csv", diff --git a/target/nextflow/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R b/target/nextflow/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R new file mode 100644 index 0000000..78966bc --- /dev/null +++ b/target/nextflow/convert/from_cosmx_to_spatialexperiment/unzip_archived_folder.R @@ -0,0 +1,22 @@ +extract_selected_files <- function(zip_path, members) { + # Create a temporary directory for extraction + temp_dir <- tempfile("unzip_dir_") + dir.create(temp_dir) + + # List all files in the archive + all_files <- utils::unzip(zip_path, list = TRUE)$Name + + # Find files matching any of the glob patterns in 'members' + selected <- unique(unlist( + lapply(members, function(pattern) { + regex <- glob2rx(pattern) + grep(regex, all_files, value = TRUE) + }) + )) + + # Extract only the selected files + utils::unzip(zip_path, files = selected, exdir = temp_dir) + + # Return the path to the extracted folder + file.path(temp_dir) +} diff --git a/target/nextflow/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml b/target/nextflow/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml index 1545d6d..69955cb 100644 --- a/target/nextflow/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml +++ b/target/nextflow/convert/from_h5mu_to_spatialexperiment/.config.vsh.yaml @@ -224,7 +224,7 @@ build_info: output: "target/nextflow/convert/from_h5mu_to_spatialexperiment" executable: "target/nextflow/convert/from_h5mu_to_spatialexperiment/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_h5mu_to_spatialexperiment/main.nf b/target/nextflow/convert/from_h5mu_to_spatialexperiment/main.nf index 56a8c86..35ce677 100644 --- a/target/nextflow/convert/from_h5mu_to_spatialexperiment/main.nf +++ b/target/nextflow/convert/from_h5mu_to_spatialexperiment/main.nf @@ -3332,7 +3332,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_h5mu_to_spatialexperiment", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/convert/from_spatialdata_to_h5mu/.config.vsh.yaml b/target/nextflow/convert/from_spatialdata_to_h5mu/.config.vsh.yaml index dbb63a0..780aee3 100644 --- a/target/nextflow/convert/from_spatialdata_to_h5mu/.config.vsh.yaml +++ b/target/nextflow/convert/from_spatialdata_to_h5mu/.config.vsh.yaml @@ -220,7 +220,7 @@ build_info: output: "target/nextflow/convert/from_spatialdata_to_h5mu" executable: "target/nextflow/convert/from_spatialdata_to_h5mu/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_spatialdata_to_h5mu/main.nf b/target/nextflow/convert/from_spatialdata_to_h5mu/main.nf index 4b3c85b..a18bbc1 100644 --- a/target/nextflow/convert/from_spatialdata_to_h5mu/main.nf +++ b/target/nextflow/convert/from_spatialdata_to_h5mu/main.nf @@ -3330,7 +3330,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_spatialdata_to_h5mu", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/convert/from_xenium_to_h5mu/.config.vsh.yaml b/target/nextflow/convert/from_xenium_to_h5mu/.config.vsh.yaml index 7b4e617..fe3bac5 100644 --- a/target/nextflow/convert/from_xenium_to_h5mu/.config.vsh.yaml +++ b/target/nextflow/convert/from_xenium_to_h5mu/.config.vsh.yaml @@ -239,7 +239,7 @@ build_info: output: "target/nextflow/convert/from_xenium_to_h5mu" executable: "target/nextflow/convert/from_xenium_to_h5mu/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_xenium_to_h5mu/main.nf b/target/nextflow/convert/from_xenium_to_h5mu/main.nf index bc731ea..77af031 100644 --- a/target/nextflow/convert/from_xenium_to_h5mu/main.nf +++ b/target/nextflow/convert/from_xenium_to_h5mu/main.nf @@ -3342,7 +3342,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_xenium_to_h5mu", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/convert/from_xenium_to_spatialdata/.config.vsh.yaml b/target/nextflow/convert/from_xenium_to_spatialdata/.config.vsh.yaml index 991e6b0..98f115f 100644 --- a/target/nextflow/convert/from_xenium_to_spatialdata/.config.vsh.yaml +++ b/target/nextflow/convert/from_xenium_to_spatialdata/.config.vsh.yaml @@ -320,7 +320,7 @@ build_info: output: "target/nextflow/convert/from_xenium_to_spatialdata" executable: "target/nextflow/convert/from_xenium_to_spatialdata/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_xenium_to_spatialdata/main.nf b/target/nextflow/convert/from_xenium_to_spatialdata/main.nf index aa98d83..50aecd5 100644 --- a/target/nextflow/convert/from_xenium_to_spatialdata/main.nf +++ b/target/nextflow/convert/from_xenium_to_spatialdata/main.nf @@ -3436,7 +3436,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_xenium_to_spatialdata", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { @@ -3540,11 +3540,13 @@ from unzip_archived_folder import unzip_archived_folder logger = setup_logger() logger.info("Reading in Xenium data...") -if zipfile.is_zipfile(par["input"]): - par["input"] = unzip_archived_folder(par["input"]) +if zipfile.is_zipfile(par["input"]): + xenium_output_bundle = unzip_archived_folder(par["input"]) +else: + xenium_output_bundle = par["input"] sdata = xenium( - par["input"], + xenium_output_bundle, cells_boundaries=par["cells_boundaries"], nucleus_boundaries=par["nucleus_boundaries"], cells_as_circles=par["cells_as_circles"], diff --git a/target/nextflow/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml b/target/nextflow/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml index c96aaf1..9baaaf7 100644 --- a/target/nextflow/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml +++ b/target/nextflow/convert/from_xenium_to_spatialexperiment/.config.vsh.yaml @@ -88,6 +88,8 @@ resources: - type: "r_script" path: "script.R" is_executable: true +- type: "file" + path: "unzip_archived_folder.R" - type: "file" path: "nextflow_labels.config" dest: "nextflow_labels.config" @@ -222,7 +224,7 @@ build_info: output: "target/nextflow/convert/from_xenium_to_spatialexperiment" executable: "target/nextflow/convert/from_xenium_to_spatialexperiment/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/convert/from_xenium_to_spatialexperiment/main.nf b/target/nextflow/convert/from_xenium_to_spatialexperiment/main.nf index fc096ef..ec567d9 100644 --- a/target/nextflow/convert/from_xenium_to_spatialexperiment/main.nf +++ b/target/nextflow/convert/from_xenium_to_spatialexperiment/main.nf @@ -3147,6 +3147,10 @@ meta = [ "path" : "script.R", "is_executable" : true }, + { + "type" : "file", + "path" : "/src/utils/unzip_archived_folder.R" + }, { "type" : "file", "path" : "/src/workflows/utils/labels.config", @@ -3311,7 +3315,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/convert/from_xenium_to_spatialexperiment", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { @@ -3406,9 +3410,24 @@ rm(.viash_orig_warn) ### VIASH END +source(paste0(meta\\$resources_dir, "/unzip_archived_folder.R")) + +xenium_output_bundle <- par\\$input +if (grepl("\\\\\\\\.zip\\$", xenium_output_bundle)) { + expected_file_patterns <- c( + "cell_feature_matrix.h5", + "*.parquet", + "experiment.xenium" + ) + + xenium_output_bundle <- extract_selected_files( + xenium_output_bundle, + members = expected_file_patterns + ) +} spe <- readXeniumSXE( - dirName = par\\$input, + dirName = xenium_output_bundle, returnType = "SPE", countMatPattern = "cell_feature_matrix.h5", metaDataPattern = "cells.parquet", diff --git a/target/nextflow/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R b/target/nextflow/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R new file mode 100644 index 0000000..78966bc --- /dev/null +++ b/target/nextflow/convert/from_xenium_to_spatialexperiment/unzip_archived_folder.R @@ -0,0 +1,22 @@ +extract_selected_files <- function(zip_path, members) { + # Create a temporary directory for extraction + temp_dir <- tempfile("unzip_dir_") + dir.create(temp_dir) + + # List all files in the archive + all_files <- utils::unzip(zip_path, list = TRUE)$Name + + # Find files matching any of the glob patterns in 'members' + selected <- unique(unlist( + lapply(members, function(pattern) { + regex <- glob2rx(pattern) + grep(regex, all_files, value = TRUE) + }) + )) + + # Extract only the selected files + utils::unzip(zip_path, files = selected, exdir = temp_dir) + + # Return the path to the extracted folder + file.path(temp_dir) +} diff --git a/target/nextflow/filter/subset_cosmx/.config.vsh.yaml b/target/nextflow/filter/subset_cosmx/.config.vsh.yaml index 0b79562..e9dbc87 100644 --- a/target/nextflow/filter/subset_cosmx/.config.vsh.yaml +++ b/target/nextflow/filter/subset_cosmx/.config.vsh.yaml @@ -227,7 +227,7 @@ build_info: output: "target/nextflow/filter/subset_cosmx" executable: "target/nextflow/filter/subset_cosmx/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/filter/subset_cosmx/main.nf b/target/nextflow/filter/subset_cosmx/main.nf index 84c0b57..e79159b 100644 --- a/target/nextflow/filter/subset_cosmx/main.nf +++ b/target/nextflow/filter/subset_cosmx/main.nf @@ -3333,7 +3333,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/filter/subset_cosmx", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/mapping/spaceranger_count/.config.vsh.yaml b/target/nextflow/mapping/spaceranger_count/.config.vsh.yaml index 036be1e..c503c30 100644 --- a/target/nextflow/mapping/spaceranger_count/.config.vsh.yaml +++ b/target/nextflow/mapping/spaceranger_count/.config.vsh.yaml @@ -426,7 +426,7 @@ build_info: output: "target/nextflow/mapping/spaceranger_count" executable: "target/nextflow/mapping/spaceranger_count/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" package_config: name: "openpipeline_spatial" diff --git a/target/nextflow/mapping/spaceranger_count/main.nf b/target/nextflow/mapping/spaceranger_count/main.nf index 737b668..e040b40 100644 --- a/target/nextflow/mapping/spaceranger_count/main.nf +++ b/target/nextflow/mapping/spaceranger_count/main.nf @@ -3548,7 +3548,7 @@ meta = [ "engine" : "docker|native", "output" : "/workdir/root/repo/target/nextflow/mapping/spaceranger_count", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/workflows/multiomics/spatial_process_samples/.config.vsh.yaml b/target/nextflow/workflows/multiomics/spatial_process_samples/.config.vsh.yaml index 0da151a..314b88a 100644 --- a/target/nextflow/workflows/multiomics/spatial_process_samples/.config.vsh.yaml +++ b/target/nextflow/workflows/multiomics/spatial_process_samples/.config.vsh.yaml @@ -640,7 +640,7 @@ build_info: output: "target/nextflow/workflows/multiomics/spatial_process_samples" executable: "target/nextflow/workflows/multiomics/spatial_process_samples/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" dependencies: - "target/dependencies/vsh/vsh/openpipeline/v3.0.0/nextflow/workflows/multiomics/process_samples" diff --git a/target/nextflow/workflows/multiomics/spatial_process_samples/main.nf b/target/nextflow/workflows/multiomics/spatial_process_samples/main.nf index b1f02fb..1fbc89e 100644 --- a/target/nextflow/workflows/multiomics/spatial_process_samples/main.nf +++ b/target/nextflow/workflows/multiomics/spatial_process_samples/main.nf @@ -3807,7 +3807,7 @@ meta = [ "engine" : "native", "output" : "/workdir/root/repo/target/nextflow/workflows/multiomics/spatial_process_samples", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : { diff --git a/target/nextflow/workflows/qc/spatial_qc/.config.vsh.yaml b/target/nextflow/workflows/qc/spatial_qc/.config.vsh.yaml index c0e3387..7942d2f 100644 --- a/target/nextflow/workflows/qc/spatial_qc/.config.vsh.yaml +++ b/target/nextflow/workflows/qc/spatial_qc/.config.vsh.yaml @@ -387,7 +387,7 @@ build_info: output: "target/nextflow/workflows/qc/spatial_qc" executable: "target/nextflow/workflows/qc/spatial_qc/main.nf" viash_version: "0.9.4" - git_commit: "2cc934cef9746e6befa3e91c82080bc071294628" + git_commit: "f951825e3f6f7d9ad09b4803220f5af99fe4ae14" git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial" dependencies: - "target/dependencies/vsh/vsh/openpipeline/v3.0.0/nextflow/workflows/qc/qc" diff --git a/target/nextflow/workflows/qc/spatial_qc/main.nf b/target/nextflow/workflows/qc/spatial_qc/main.nf index cbe494d..40815d8 100644 --- a/target/nextflow/workflows/qc/spatial_qc/main.nf +++ b/target/nextflow/workflows/qc/spatial_qc/main.nf @@ -3505,7 +3505,7 @@ meta = [ "engine" : "native", "output" : "/workdir/root/repo/target/nextflow/workflows/qc/spatial_qc", "viash_version" : "0.9.4", - "git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628", + "git_commit" : "f951825e3f6f7d9ad09b4803220f5af99fe4ae14", "git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial" }, "package_config" : {