name: "from_spaceranger_to_h5mu"
namespace: "convert"
scope: "public"
description: |
  Converts the output bundle from spaceranger into an h5mu file.
authors:
  - __merge__: /src/authors/dorien_roosen.yaml
    roles: [ maintainer ]
argument_groups:
  - name: Inputs
    arguments:
      - name: "--input"
        alternatives: ["-i"]
        type: file
        description: |
          Convert spatial data resulting from Aviti Teton sequencers that have been processed by the Element Biosciences cells2stats workflow to H5MU format.
          
          This component processes cells2stats count matrices to create a standardized H5MU file for downstream analysis.
          
          The component reads:
          - Parquet file containing the count matrix and metadata
          - Panel.json with target and batch information
          
          And outputs an H5MU file with:
          - Count data as the main .X matrix
          - Spatial coordinates in obsm
          - Cell Paint intensities in obsm (optional)
          - Nuclear count data as a layer (optional)
          - CellProfiler morphology metrics in obsm (optional)
          - Unassigned targets in obsm (optional)
        example: spaceranger_output
        direction: input
        required: true
  - name: Outputs
    arguments:
      - name: "--output"
        type: file
        description: Output h5mu file.
        example: output.h5mu
        direction: output
      - name: "--modality"
        type: string
        description: Name of the modality under which to store the data.
        default: "rna"
      - name: "--uns_metrics"
        type: string
        description: Name of the .uns slot under which to QC metrics (if any).
        default: "metrics_spaceranger"
      - name: "--uns_probe_set"
        type: string
        description: Name of the .uns slot under which to store probe set information (if any).
        default: "probe_set"
      - name: "--obsm_coordinates"
        type: string
        description: Name of the .obsm slot under which to store the cell centroid coordinates.
        default: "spatial"
      - name: "--output_type"
        type: string
        description: "Which Spaceranger output to use for converting to h5mu."
        choices: [ raw, filtered ]
        default: filtered
      - name: "--output_compression"
        type: string
        description: Compression to use when writing the h5mu file.
        choices: [ gzip, lzf ]

resources:
  - type: python_script
    path: script.py
  - path: /src/utils/setup_logger.py
test_resources:
  - type: python_script
    path: test.py
  - path: /resources_test/visium/Visium_FFPE_Human_Ovarian_Cancer_tiny_spaceranger

engines:
- type: docker
  image: python:3.12-slim
  setup:
    - type: apt
      packages:
        - procps
    - type: python
      __merge__: [/src/base/requirements/anndata_mudata.yaml, /src/base/requirements/scanpy.yaml, .]
  __merge__: [ /src/base/requirements/python_test_setup.yaml, .]
runners:
- type: executable
- type: nextflow
  directives:
    label: [lowmem, singlecpu]