name: "from_xenium_to_spatialexperiment"
namespace: "convert"
scope: "public"
description: |
  Creates a SpatialExperiment object from the downloaded unzipped Xenium Output Bundle directory
  for 10x Genomics Xenium spatial gene expression data, and saves it as a SpatialExperiment object.
  The constructor assumes the downloaded unzipped Xenium Output Bundle has the following structure:

  Mandatory files
  · | — cell_feature_matrix.h5
  · | — cells.parquet
  Optional files, by default added to the metadata() as a list of paths (will be converted to parquet):
  · | — transcripts.parquet
  · | — cell_boundaries.parquet
  · | — nucleus_boundaries.parquet
  · | — experiment.xenium

authors:
  - __merge__: /src/authors/dorien_roosen.yaml
    roles: [ author, maintainer ]
arguments:
  - name: "--input"
    alternatives: ["-i"]
    type: file
    description: Input Xenium Output Bundle
    direction: input
    required: true
    example: path/to/xenium_bundle
  - name: "--add_experiment_xenium"
    type: boolean
    default: true
    description: Whether to add xenium.experiment parameters to the metadata.
  - name: "--add_parquet_paths"
    type: boolean
    default: true
    description: |
      Whether to add parquet paths to the metadata. 
      If True, `transcripts.parquet`, `cell_boundaries.parquet`, `nucleus_boundaries.parquet` will be added to the metadata. 
  - name: "--alternative_experiment_features"
    type: string
    multiple: true
    description: Feature names containing these strings will be moved to altExps(sxe) slots as separate SpatialExperiment objects.
    default: [NegControlProbe, UnassignedCodeword, NegControlCodeword, antisense, BLANK]
  - name: "--output"
    alternatives: ["-o"]
    type: file
    description: Output SpatialExperiment file
    direction: output
    required: true
    example: output.rds
resources:
  - type: r_script
    path: script.R
test_resources:
  - type: r_script
    path: test.R
  - path: /resources_test/xenium/xenium_tiny
engines:
  - type: docker
    image: rocker/r2u:24.04
    setup:
      - type: apt
        packages: 
          - libhdf5-dev
          - libgeos-dev
      - type: r
        bioc: [ SpatialExperimentIO ]
    test_setup:
      - type: r
        cran: [ testthat ]
runners:
  - type: executable
  - type: nextflow
    directives:
      label: [lowmem, singlecpu]