name: bpcells_regress_out
namespace: "transform"
scope: "public"
description: |
  Regress out the effects of confounding variables using a linear least squares regression model with BPCells.
authors:
  - __merge__: /src/authors/dorien_roosen.yaml
    roles: [ maintainer, author ]
  - __merge__: /src/authors/robrecht_cannoodt.yaml
    roles: [ contributor, author ]
  - __merge__: /src/authors/weiwei_schultz.yaml
    roles: [ contributor ]
arguments:
  - name: "--input"
    type: file
    description: Input h5mu file
    direction: input
    required: true
    example: input.h5mu
  - name: "--output"
    alternatives: ["-o"]
    type: file
    description: Output h5mu file.
    direction: output
    required: true
    default: output.h5mu
  - name: "--modality"
    type: string
    description: "The modality to run this component on."
    default: "rna"
  - name: "--obs_keys"
    type: string
    multiple: true
    description: The .obs keys to regress on.
  - name: "--input_layer"
    type: string
    required: false
    example: X_normalized
    description: |
      The layer of the adata object to regress on.
      If not provided, the X attribute of the adata object will be used.
  - name: "--output_layer"
    type: string
    example: X_regressed
    required: false
    description: |
      The layer of the adata object containing the regressed count data.
      If not provided, the X attribute of the adata object will be used.
__merge__: [., /src/base/h5_compression_argument.yaml]
resources:
  - type: r_script
    path: script.R
test_resources:
  - type: python_script
    path: test.py
  - path: /resources_test/pbmc_1k_protein_v3
engines:
  - type: docker
    image: rocker/r2u:24.04
    setup:
      - type: docker
        env: 
          - PIP_BREAK_SYSTEM_PACKAGES=1
          - RETICULATE_PYTHON=/usr/bin/python
      - type: apt
        packages: [ libhdf5-dev, python3, python3-pip, python3-dev, python-is-python3 ]
      - type: r
        cran: [ anndata, reticulate ]
        # Until viash r requirements supports passing secrets
        # --mount only applies to ONE single docker RUN instruction  
        # github: bnprks/BPCells/r
      - type: docker
        run:
          - --mount=type=secret,id=GITHUB_TOKEN,env=GTIHUB_TOKEN
          - Rscript -e 'options(warn = 2); remotes::install_github(c("bnprks/BPCells/r"), repos = "https://cran.rstudio.com")'
      - type: python
        user: true
        __merge__: [ /src/base/requirements/anndata_mudata.yaml ]
    __merge__: [ /src/base/requirements/python_test_setup.yaml, .]
runners:
  - type: executable
  - type: nextflow
    directives:
      label: [lowmem, lowcpu]
