name: filter_with_counts
namespace: "filter"
scope: "public"
description: |
  Filter scRNA-seq data based on the primary QC metrics. 
  This is based on both the UMI counts, the gene counts 
  and the mitochondrial genes (genes starting with mt/MT).
authors:
  - __merge__: /src/authors/dries_de_maeyer.yaml
    roles: [ author ]
  - __merge__: /src/authors/robrecht_cannoodt.yaml
    roles: [ maintainer, author ]

argument_groups:
  - name: Inputs
    arguments:
      - name: "--input"
        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"
        description: |
          Location of the count matrix. If specified, will be used to select a key from .layers,
          otherwise .X is used.
        type: string
        example: "raw_counts"
        required: false
  - name: Outputs
    arguments:
      - name: "--output"
        type: file
        description: Output h5mu file.
        direction: output
        example: output.h5mu
      - name: "--do_subset"
        type: boolean_true
        description: Whether to subset before storing the output.
      - name: "--obs_name_filter"
        type: string
        default: "filter_with_counts"
        description: In which .obs slot to store a boolean array corresponding to which observations should be removed.

      - name: "--var_name_filter"
        type: string
        default: "filter_with_counts"
        description: In which .var slot to store a boolean array corresponding to which variables should be removed.
    __merge__: [., /src/base/h5_compression_argument.yaml]

  - name: Arguments
    arguments:
      - name: "--min_counts"
        example: 200
        type: integer
        description: Minimum number of counts captured per cell.

      - name: "--max_counts"
        example: 5000000
        type: integer
        description: Maximum number of counts captured per cell.

      - name: "--min_genes_per_cell"
        example: 200
        type: integer
        description: Minimum of non-zero values per cell.

      - name: "--max_genes_per_cell"
        example: 1500000
        type: integer
        description: Maximum of non-zero values per cell.

      - name: "--min_cells_per_gene"
        example: 3
        type: integer
        description: Minimum of non-zero values per gene.

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.12-slim
  setup:
    - type: apt
      packages: 
        - procps
    - type: python
      __merge__: /src/base/requirements/anndata_mudata.yaml
  __merge__: [ /src/base/requirements/python_test_setup.yaml, .]

runners:
- type: executable
- type: nextflow
  directives:
    label: [singlecpu, lowmem]