Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module custom_tabulargseatochip #7218

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Next Next commit
[tabulartogseachip] Add the TABULAR_TO_GSEA_CHIP
module used in nf-core/differentialabundance.

This module was originally written by:
Co-authored-by: Jonathan Manning <[email protected]>
  • Loading branch information
suzannejin committed Dec 13, 2024
commit fe0271d2d924a68efb645435ec2ec3e4b9b48aa9
5 changes: 5 additions & 0 deletions modules/nf-core/custom/tabulartogseachip/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- bioconda
dependencies:
- "bioconda::gawk=5.1.0"
44 changes: 44 additions & 0 deletions modules/nf-core/custom/tabulartogseachip/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
process TABULAR_TO_GSEA_CHIP {

label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/gawk:5.1.0' :
'biocontainers/gawk:5.1.0' }"

input:
path tabular
tuple val(id), val(symbol)

output:
path "*.chip" , emit: chip
path "versions.yml" , emit: versions

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

script:
def VERSION = '9.1' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
"""
function find_column_number {
file=\$1
column=\$2

head -n 1 \$file | tr '\\t' '\\n' | grep -n "^\${column}\$" | awk -F':' '{print \$1}'
}

id_col=\$(find_column_number $tabular $id)
symbol_col=\$(find_column_number $tabular $symbol)
outfile=\$(echo $tabular | sed 's/\\(.*\\)\\..*/\\1/').chip

echo -e "Probe Set ID\\tGene Symbol\\tGene Title" > \${outfile}.tmp
tail -n +2 $tabular | awk -F'\\t' -v id=\$id_col -v symbol=\$symbol_col '{print \$id"\\t"\$symbol"\\tNA"}' >> \${outfile}.tmp
mv \${outfile}.tmp \${outfile}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
bash: \$(echo \$(bash --version | grep -Eo 'version [[:alnum:].]+' | sed 's/version //'))
END_VERSIONS
"""
}
48 changes: 48 additions & 0 deletions modules/nf-core/custom/tabulartogseachip/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "custom_tabulartogseacls"
description: Make a GSEA class file (.chip) from tabular inputs
keywords:
- gsea
- chip
- convert
- tabular
tools:
- custom:
description: "Make a GSEA class file (.chip) from tabular inputs"
tool_dev_url: "https://github.com/nf-core/modules/blob/master/modules/nf-core/custom/tabulartogseachip/main.nf"
identifier: ""
input:
- - meta:
type: map
description: |
Groovy Map containing input metadata information
e.g. [ id:'test' ]
- tabular:
type: file
description: Tabular (NOTE that for the moment it only works for TSV file) containing a column with the
features ids, and another column with the features symbols.
pattern: "*.{tsv}"
- - id:
type: str
description: The name of the column containing feature ids
- symbol:
type: str
description: The name of the column containing feature symbols
output:
- chip:
- chip:
type: file
description: |
A categorical class format file (.chip) as defined by the Broad
documentation at
https://software.broadinstitute.org/cancer/software/gsea/wiki/index.php/Data_formats
pattern: "*.chip"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@pinin4fjords"
- "@suzannejin"
maintainers:
- "@pinin4fjords"
74 changes: 74 additions & 0 deletions modules/nf-core/custom/tabulartogseachip/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// TODO nf-core: Once you have added the required tests, please run the following command to build this file:
// nf-core modules test custom/tabulartogseachip
nextflow_process {

name "Test Process CUSTOM_TABULARTOGSEACHIP"
script "../main.nf"
process "CUSTOM_TABULARTOGSEACHIP"

tag "modules"
tag "modules_nfcore"
tag "custom"
tag "custom/tabulartogseachip"

// TODO nf-core: Change the test name preferably indicating the test-data and file-format used
test("sarscov2 - bam") {

// TODO nf-core: If you are created a test for a chained module
// (the module requires running more than one process to generate the required output)
// add the 'setup' method here.
// You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules).

when {
process {
"""
// TODO nf-core: define inputs of the process here. Example:

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
//TODO nf-core: Add all required assertions to verify the test output.
// See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples.
)
}

}

// TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix.
test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
// TODO nf-core: define inputs of the process here. Example:

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
//TODO nf-core: Add all required assertions to verify the test output.
)
}

}

}