name: pca
namespace: "dimred"
scope: "public"
description: |
  Computes PCA coordinates, loadings and variance decomposition.
authors:
  - __merge__: /src/authors/dries_de_maeyer.yaml
    roles: [ maintainer ]
argument_groups:
  - name: inputs
    arguments:
      - name: "--input"
        alternatives: ["-i"]
        type: file
        description: Input h5mu file
        direction: input
        required: true
        example: input.h5mu

      - name: "--modality"
        description: |
          Which modality from the input MuData file to process.
        type: string
        default: "rna"
        required: false

      - name: "--layer"
        type: string
        description: Use specified layer for expression values instead of the .X object from the modality.
        required: false

      - name: "--var_input"
        type: string
        description: Column name in .var matrix that will be used to select which genes to run the PCA on.
        example: filter_with_hvg

  - name: Options
    arguments:
      - name: "--num_components"
        type: integer
        example: 25
        description: Number of principal components to compute. Defaults to 50, or 1 - minimum dimension size of selected representation.

      - name: "--chunked"
        type: boolean_true
        description: |
          If True, perform an incremental PCA on segments of a predefined size. Setting this flag automatically implies zero centering.
          Must be specified together with --chunk_size.

      - name: "--chunk_size"
        type: integer
        min: 2
        required: false
        description: |
          Number of observations to include in each chunk. Required if chunked=True was passed.

      - name: "--seed"
        type: integer
        min: 0
        required: false
        description: |
          Used to set the initial states for the optimization. 

  - name: Outputs
    arguments:
      - name: "--output"
        alternatives: ["-o"]
        type: file
        description: Output h5mu file.
        direction: output
        required: true
        example: output.h5mu

      - name: "--obsm_output"
        type: string
        default: "X_pca"
        description: "In which .obsm slot to store the resulting embedding."

      - name: "--varm_output"
        type: string
        default: "pca_loadings"
        description: "In which .varm slot to store the resulting loadings matrix."

      - name: "--uns_output"
        type: string
        default: "pca_variance"
        description: "In which .uns slot to store the resulting variance objects."
  
      - name: "--overwrite"
        type: boolean_true
        description: "Allow overwriting .obsm, .varm and .uns slots."

__merge__: [., /src/base/h5_compression_argument.yaml]

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

engines:
- type: docker
  image: python:3.13-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: 
      - highcpu
      - highmem
      - middisk
