Skip to content

Commit

Permalink
Merge pull request #382 from nf-core/issue_370
Browse files Browse the repository at this point in the history
POC contrasts csv -> yaml
  • Loading branch information
nschcolnicov authored Dec 20, 2024
2 parents ade0216 + 34ca6ec commit ec554b2
Show file tree
Hide file tree
Showing 12 changed files with 1,174 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches:
- dev
- master
- dev_tmp
release:
types: [published]
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [[#343](https://github.com/nf-core/differentialabundance/pull/343)] - Add pipeline-level nf-tests ([@atrigila](https://github.com/atrigila), review by [@pinin4fjords](https://github.com/pinin4fjords) and [@nschcolnicov](https://github.com/nschcolnicov))
- [[#286](https://github.com/nf-core/differentialabundance/pull/286)] - Integration of limma voom for rnaseq data ([@KamilMaliszArdigen](https://github.com/KamilMaliszArdigen), review by [@pinin4fjords](https://github.com/pinin4fjords))
- [[#380](https://github.com/nf-core/differentialabundance/pull/380)] - Replace local filter_diff_table module with nf-core one, and create nf-tests for tabular_to_gsea_chip. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@pinin4fjords](https://github.com/pinin4fjords))
- [[#382](https://github.com/nf-core/differentialabundance/pull/382)] - Add YAML formatted contrasts file handling. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@TODO](https://github.com/TODO))

### Fixed

Expand Down
568 changes: 568 additions & 0 deletions bin/validate_fom_components_yaml.R

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions modules/local/shinyngs/validatefomcomponents/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::r-shinyngs=2.0.0
45 changes: 45 additions & 0 deletions modules/local/shinyngs/validatefomcomponents/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
process SHINYNGS_VALIDATEFOMCOMPONENTS { //TODO this module and whole folder should be deleted once https://github.com/nf-core/differentialabundance/issues/362 is closed, is replaced by the nf-core version of it.
tag "$sample"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "community.wave.seqera.io/library/r-shinyngs_r-yaml:aa63537f6db6190c"

input:
tuple val(meta), path(sample), path(assay_files)
tuple val(meta2), path(feature_meta)
tuple val(meta3), path(contrasts)

output:
tuple val(meta), path("*/*.sample_metadata.tsv") , emit: sample_meta
tuple val(meta), path("*/*.feature_metadata.tsv") , emit: feature_meta, optional: true
tuple val(meta), path("*/*.assay.tsv") , emit: assays
tuple val(meta), path("*/*.contrasts_file.tsv") , emit: contrasts
path "versions.yml" , emit: versions

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

script:
// For full list of available args see
// https://github.com/pinin4fjords/shinyngs/blob/develop/exec/validate_fom_components.R
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: meta.id
def feature = feature_meta ? "--feature_metadata '$feature_meta'" : ''

"""
validate_fom_components_yaml.R \\
--sample_metadata "$sample" \\
$feature \\
--assay_files "${assay_files.join(',')}" \\
--contrasts_file "$contrasts" \\
--output_directory "$prefix" \\
$args
cat <<-END_VERSIONS > versions.yml
"${task.process}":
r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//')
r-shinyngs: \$(Rscript -e "library(shinyngs); cat(as.character(packageVersion('shinyngs')))")
END_VERSIONS
"""
}
100 changes: 100 additions & 0 deletions modules/local/shinyngs/validatefomcomponents/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: "shinyngs_validatefomcomponents"
description: validate consistency of feature and sample annotations with matrices
and contrasts
keywords:
- expression
- features
- observations
- validation
tools:
- "shinyngs":
description: "Provides Shiny applications for various array and NGS applications.
Currently very RNA-seq centric, with plans for expansion."
homepage: "https://github.com/pinin4fjords/shinyngs"
documentation: "https://rawgit.com/pinin4fjords/shinyngs/master/vignettes/shinyngs.html"
tool_dev_url: "https://github.com/pinin4fjords/shinyngs"
licence: ["AGPL v3"]
identifier: ""
input:
- - meta:
type: map
description: |
Groovy Map containing information on experiment, at a minimum an id.
e.g. [ id:'test' ]
- sample:
type: file
description: |
CSV-format sample sheet with sample metadata
- assay_files:
type: file
description: |
List of TSV-format matrix files representing different measures for the same samples (e.g. raw and normalised).
- - meta2:
type: map
description: |
Groovy Map containing information on features.
e.g. [ id:'test' ]
- feature_meta:
type: file
description: |
TSV-format feature (e.g. gene) metadata
- - meta3:
type: map
description: |
Groovy Map containing information on contrasts.
e.g. [ id:'test' ]
- contrasts:
type: file
description: |
CSV-format file with four columns identifying the sample sheet variable, reference level, treatment level, and optionally a comma-separated list of covariates used as blocking factors.
output:
- sample_meta:
- meta:
type: map
description: |
Groovy Map containing information on experiment.
e.g. [ id:'test' ]
- "*/*.sample_metadata.tsv":
type: file
description: File containing validated sample metadata
pattern: "/*.sample_metadata.tsv"
- feature_meta:
- meta:
type: map
description: |
Groovy Map containing information on experiment.
e.g. [ id:'test' ]
- "*/*.feature_metadata.tsv":
type: file
description: File containing validated feature metadata
pattern: "/*.feature_metadata.tsv"
optional: true
- assays:
- meta:
type: map
description: |
Groovy Map containing information on experiment.
e.g. [ id:'test' ]
- "*/*.assay.tsv":
type: file
description: Files containing validated matrices
pattern: "/*.assay.tsv"
- contrasts:
- meta:
type: map
description: |
Groovy Map containing information on experiment.
e.g. [ id:'test' ]
- "*/*.contrasts_file.tsv":
type: file
description: Files containing validated matrices
pattern: "/*.contrasts_file.tsv"
- versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@pinin4fjords"
maintainers:
- "@pinin4fjords"
2 changes: 1 addition & 1 deletion nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"type": "string",
"description": "A CSV file describing sample contrasts",
"help_text": "This file is used to define groups of samples from 'input' to compare. It must contain at least the columns 'variable', 'reference', 'target' and 'blocking', where 'variable' is a column in the input sample sheet, 'reference' and 'target' are values in that column, and blocking is a colon-separated list of additional 'blocking' variables (can be an empty string)",
"pattern": "^\\S+\\.(csv|tsv)$",
"pattern": "^\\S+\\.(yaml|yml|csv)$",
"format": "file-path",
"mimetype": "text/csv",
"fa_icon": "fas fa-adjust"
Expand Down
30 changes: 30 additions & 0 deletions tests/test.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,34 @@ nextflow_pipeline {
)
}
}

test("Test profile with yaml contrasts") {

when {
params {
outdir = "$outputDir"
contrasts = "https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/testdata/SRP254919.contrasts.yaml"
}
}

then {
// stable_name: All files + folders in ${params.outdir}/ with a stable name
def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}'])
// stable_path: All files in ${params.outdir}/ with stable content
def stable_path = getAllFilesFromDir(params.outdir, ignoreFile: 'tests/.nftignore')
assertAll(
{ assert workflow.success},
{ assert snapshot(
// Number of successful tasks
workflow.trace.succeeded().size(),
// pipeline versions.yml file for multiqc from which Nextflow version is removed because we tests pipelines on multiple Nextflow versions
removeNextflowVersion("$outputDir/pipeline_info/collated_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}
}
Loading

0 comments on commit ec554b2

Please sign in to comment.