name: "from_xenium_to_spatialdata"
namespace: "convert"
scope: "public"
description: |
  Converts the output from 10X Genomics Xenium dataset into a SpatialData objcet.
  By default, the following files will be converted:
    - `experiment.xenium`: File containing specifications.
    - `nucleus_boundaries.parquet`: Polygons of nucleus boundaries.
    - `cell_boundaries.parquet`: Polygons of cell boundaries.
    - `transcripts.parquet`: File containing transcripts.
    - `cell_feature_matrix.h5`: File containing cell feature matrix.
    - `cells.parquet`: File containing cell metadata.
    - `morphology_mip.ome.tif`: File containing morphology mip.
    - `morphology_focus.ome.tif`: File containing morphology focus.
authors:
  - __merge__: /src/authors/dorien_roosen.yaml
    roles: [ maintainer ]
  - __merge__: /src/authors/weiwei_schultz.yaml
    roles: [ contributor ]
arguments:
  - name: "--input"
    alternatives: ["-i"]
    type: file
    description: Input folder. Must contain the output from a xenium run.
    example: xenium_data
    direction: input
    required: true
  - name: "--output"
    alternatives: ["-o"]
    type: file
    description: Zarr directory where the SpatialData object will be stored
    example: "xenium_data.zarr"
    direction: output
  - name: "--cells_boundaries"
    type: boolean
    default: True
    description: Whether to read cell boundaries (polygons).
  - name: "--nucleus_boundaries"
    type: boolean
    default: True
    description: Whether to read nucleus boundaries (polygons).
  - name: "--cells_as_circles"
    type: boolean_true
    description: Whether to read cells also as circles (the center and the radius of each circle is computed from the corresponding labels cell).
  - name: "--cells_labels"
    type: boolean
    default: True
    description: Whether to read cell labels (raster). The polygonal version of the cell labels are simplified for visualization purposes, and using the raster version is recommended for analysis.
  - name: "--transcripts"
    type: boolean
    default: True
    description: Whether to read transcripts.
  - name: "--nucleus_labels"
    type: boolean
    default: True
    description: Whether to read nucleus labels (raster). The polygonal version of the nucleus labels are simplified for visualization purposes, and using the raster version is recommended for analysis.
  - name: "--morphology_mip"
    type: boolean
    default: True
    description: Whether to read the morphology mip image (available in versions < 2.0.0).
  - name: "--morphology_focus"
    type: boolean
    default: True
    description: Whether to read the morphology focus image.
  - name: "--aligned_images"
    type: boolean
    default: True
    description: Whether to also parse, when available, additional H&E or IF aligned images. For more control over the aligned images being read, in particular, to specify the axes of the aligned images, please set this parameter to False and use the xenium_aligned_image function directly.
  - name: "--cells_table"
    type: boolean
    default: True
    description: Whether to read the cell annotations in the AnnData table.
  - name: "--n_jobs"
    type: integer
    default: 1

resources:
  - type: python_script
    path: script.py
  - path: /src/utils/setup_logger.py
  - path: /src/utils/unzip_archived_folder.py
test_resources:
  - type: python_script
    path: test.py
  - path: /resources_test/xenium/xenium_tiny/
engines:
  - type: docker
    image: python:3.12-slim
    setup:
      - type: apt
        packages: 
          - procps
          - build-essential
          - zlib1g-dev
          - git
      - type: python
        # Windows explorer uses DEFLATE64 compression for large ZIP files,
        # which is not supported by most standard library zipfile module
        git: [ https://codeberg.org/miurahr/zipfile-inflate64.git@v0.2 ]
        __merge__: [ /src/base/requirements/spatialdata-io.yaml, . ]
    test_setup:
      - type: apt
        packages:
          - zip
    __merge__: [ /src/base/requirements/python_test_setup.yaml, .]
runners:
  - type: executable
  - type: nextflow
    directives:
      label: [lowmem, singlecpu]
