process SCRY_DEVIANCE {
    tag "${meta.id}"
    label 'process_medium'

    conda "${moduleDir}/environment.yml"
    container "${ workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container
        ? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/c4/c430d984a431d374c285a7a577f0496d8a514c1ad484feaaa86655259b594eb8/data'
        : 'community.wave.seqera.io/library/scry_deviance:42e91d77e88fcfe6' }"

    input:
    tuple val(meta), path(h5ad)
    val n_genes
    path excluded_genes
    val batch_col

    output:
    tuple val(meta), path("${prefix}.h5ad"), emit: h5ad
    path "${prefix}_features.csv"          , emit: var
    path "versions.yml"                    , emit: versions, topic: versions

    when:
    task.ext.when == null || task.ext.when

    script:
    prefix = task.ext.prefix ?: "${meta.id}"
    template 'deviance.R'

    stub:
    prefix = task.ext.prefix ?: "${meta.id}"
    """
    touch ${prefix}.h5ad
    touch ${prefix}_features.csv
    touch versions.yml
    """
}
