nf-core / scdownstream

A single cell transcriptomics pipeline for QC, integration and making the data presentable
https://nf-co.re/scdownstream
MIT License
43 stars 12 forks source link

AMBIENT_RNA_REMOVAL needs revision - runtime error ch_raw undefined with cellbender #65

Closed smoe closed 4 months ago

smoe commented 4 months ago

Description of the bug

Hello,

I had not spotted this in my initial review for the respective pull request, but better now than ...

workflow AMBIENT_RNA_REMOVAL {
    take:
    ch_pairing

A comment would be nice on what ch_pairing is. I mean, it kind of gets evident from the context but then again ... would be nice. Also, it may be noteworthy that in this subworkflow that pairing is undone - only one stream continues.

    main:
    ch_versions = Channel.empty()

    if (params.ambient_removal == 'none') {
        println "AMBIENT_RNA_REMOVAL: Not performed since 'none' selected."
        ch_h5ad = ch_pairing.map{ meta, filtered, unfiltered -> [meta, filtered] }

I agree that when the filtered channel is not empty then that filtered channel should be forwarded. But if only the unfiltered is available, then that is the one that is forwarded, even though we may be expecting problems. Or an error message should be raised.

    }
    else if (params.ambient_removal == 'decontx') {
        CELDA_DECONTX(ch_pairing)
        ch_h5ad = CELDA_DECONTX.out.h5ad
        ch_versions = ch_versions.mix(CELDA_DECONTX.out.versions)

This seems to work, at least this works for me when only providing unfiltered data.

    }
    else if (params.ambient_removal == 'cellbender') {
        CELLBENDER_REMOVEBACKGROUND(ch_raw)

ch_raw is not defined. In analogy to CELDA_DECONTX, SCVITOOLS_SCAR and SOUPX I think ch_pairing should be forwarded but modules/local/cellbender/removebackground is not prepared for that.

        ch_versions = ch_versions.mix(CELLBENDER_REMOVEBACKGROUND.out.versions)

        CELLBENDER_MERGE(ch_pairing.map{ meta, filtered, raw -> [meta.id, meta, filtered, raw] }
            .join(CELLBENDER_REMOVEBACKGROUND.out.h5.map{ meta, h5 -> [meta.id, h5] }, by: 0, failOnMismatch: true)
            .map{ id, meta, filtered, raw, h5 -> [meta, filtered, raw, h5] })
        ch_h5ad = CELLBENDER_MERGE.out.h5ad
        ch_versions = ch_versions.mix(CELLBENDER_MERGE.out.versions)
    }
    else if (params.ambient_removal == 'soupx') {
        SOUPX(ch_pairing)
        ch_h5ad = SOUPX.out.h5ad
        ch_versions = ch_versions.mix(SOUPX.out.versions)
    }
    else if (params.ambient_removal == 'scar') {
        SCVITOOLS_SCAR(ch_pairing)
        ch_h5ad = SCVITOOLS_SCAR.out.h5ad
        ch_versions = SCVITOOLS_SCAR.out.versions
    }
    else {
        error "AMBIENT_RNA_REMOVAL: Unexpected value of param 'params.ambient_removal': '${params.ambient_removal}'."
    }

    emit:
    h5ad = ch_h5ad

Command used and terminal output

No response

Relevant files

No response

System information

No response