From 2501af60a217ade2609221d4ca85caea4a2c3bbe Mon Sep 17 00:00:00 2001
From: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com>
Date: Thu, 7 Mar 2024 11:55:18 +0000
Subject: [PATCH 1/2] Add nf-tests for deseq2_qc local module
---
modules/local/deseq2_qc/tests/main.nf.test | 87 +++++++++++++++++++
.../local/deseq2_qc/tests/main.nf.test.snap | 81 +++++++++++++++++
2 files changed, 168 insertions(+)
create mode 100644 modules/local/deseq2_qc/tests/main.nf.test
create mode 100644 modules/local/deseq2_qc/tests/main.nf.test.snap
diff --git a/modules/local/deseq2_qc/tests/main.nf.test b/modules/local/deseq2_qc/tests/main.nf.test
new file mode 100644
index 000000000..3fa938d26
--- /dev/null
+++ b/modules/local/deseq2_qc/tests/main.nf.test
@@ -0,0 +1,87 @@
+nextflow_process {
+
+ name "Test Process DESEQ2_QC"
+ script "../main.nf"
+ process "DESEQ2_QC"
+
+ test("parse count data correctly") {
+
+ when {
+ process {
+ """
+ // Taken from example salmon merged data from -profile test
+ def fileContents = [
+ 'gene_id gene_name RAP1_IAA_30M_REP1 RAP1_UNINDUCED_REP1 RAP1_UNINDUCED_REP2 WT_REP1 WT_REP2',
+ 'Gfp_transgene_gene Gfp_transgene_gene 0 0 0 0 0',
+ 'HRA1 HRA1 3.01943228500291 9.80701185810843 9.53274413980081 5.72894534769954 5.9648842559222',
+ 'snR18 snR18 2.15518528497702 20.2706605484032 10.1398196728994 5.78313737408605 5.79976683844901',
+ 'YAL001C TFC3 56.5487189493641 70.7846010387686 113.108816589334 60.5178622417112 30.2958040068545',
+ 'YAL002W VPS8 36.3862437592078 32.3965311942571 80.536128672497 63.6031126291227 25.2702744059695',
+ 'YAL003W EFB1 598.396699649099 887.339579289614 1856.66699260635 1049.93553354283 665.403243069765',
+ 'YAL004W YAL004W 388.410667489585 383.296795393227 203.744142706403 202.691892385957 251.440658667147',
+ 'YAL005C SSA1 5647.27979655766 5715.94369645599 12575.108029018 7775.42737695585 3903.66710060582',
+ 'YAL007C ERP2 44.6930487868818 60.9301400694571 143.68466075721 56.9486461946981 41.7805866183878',
+ 'YAL008W FUN14 13.1986081960994 18.7996646072737 26.552459043029 9.4087625308538 2.82245410144267',
+ 'YAL009W SPO7 13.5217762310537 15.8719804576371 20.113413795 8.67724034815225 4.82436501953514',
+ 'YAL010C MDM10 10.9410758413598 12.0839661783069 36.2679562039924 29.7986383847897 9.94377960724503',
+ 'YAL011W SWC3 12.0055027348268 24.9403272396788 35.9299792122994 19.9834911886444 18.0057148106317',
+ 'YAL012W CYS3 242.877787996136 236.466395413312 547.58060621785 378.571834233094 226.984289418222',
+ 'YAL013W DEP1 7.90662508175251 18.3153373366285 35.6289306191157 20.7248252538103 10.8672258295774',
+ 'YAL014C SYN8 15.4361922388434 21.2042068878003 44.5485583043788 26.9652946879967 16.3840947562552',
+ 'YAL015C NTG1 12.841137836752 12.2213888342821 28.5292052419374 7.89073247427083 5.92421903162791',
+ ]
+ def countFile = file("${workDir}/countFile.tsv")
+ countFile.withWriter{ out ->
+ fileContents.each {out.println it}
+ }
+
+ def pcaHeaderFile = file("${workDir}/deseq2_pca_header.txt")
+ def pcaHeaderContents = '''
+ #id: 'deseq2_pca'
+ #section_name: 'DESeq2 PCA plot'
+ #description: "PCA plot between samples in the experiment.
+ # These values are calculated using DESeq2
+ # in the deseq2_qc.r
script."
+ #plot_type: 'scatter'
+ #anchor: 'deseq2_pca'
+ #pconfig:
+ # title: 'DESeq2: Principal component plot'
+ # xlab: PC1
+ # ylab: PC2
+ '''.stripIndent().trim()
+ pcaHeaderFile.write(pcaHeaderContents)
+
+ def clusteringHeaderFile = file("${workDir}/deseq2_clustering_header.txt")
+ def clusteringHeaderContents = '''
+ #id: 'deseq2_clustering'
+ #section_name: 'DESeq2 sample similarity'
+ #description: "is generated from clustering by Euclidean distances between
+ # DESeq2
+ # rlog values for each sample
+ # in the deseq2_qc.r
script."
+ #plot_type: 'heatmap'
+ #anchor: 'deseq2_clustering'
+ #pconfig:
+ # title: 'DESeq2: Heatmap of the sample-to-sample distances'
+ # xlab: True
+ # reverseColors: True
+ '''.stripIndent().trim()
+ clusteringHeaderFile.write(clusteringHeaderContents)
+
+ input[0] = countFile
+ input[1] = pcaHeaderFile
+ input[2] = clusteringHeaderFile
+ """
+ }
+ }
+
+ then {
+ assertAll(
+ { assert process.success },
+ { assert snapshot(process.out).match() }
+ )
+ }
+
+ }
+
+}
diff --git a/modules/local/deseq2_qc/tests/main.nf.test.snap b/modules/local/deseq2_qc/tests/main.nf.test.snap
new file mode 100644
index 000000000..626fb065b
--- /dev/null
+++ b/modules/local/deseq2_qc/tests/main.nf.test.snap
@@ -0,0 +1,81 @@
+{
+ "parse count data correctly": {
+ "content": [
+ {
+ "0": [
+ "deseq2.plots.pdf:md5,066dd6e447a41b6a361b9c9776013b17"
+ ],
+ "1": [
+ "deseq2.dds.RData:md5,c7c1872e7566321d0c3f7ca56c463088"
+ ],
+ "2": [
+ "deseq2.pca.vals.txt:md5,4cda8e32ec39326c1350e77b4b607aad"
+ ],
+ "3": [
+
+ ],
+ "4": [
+ "deseq2.sample.dists.txt:md5,1616ce40eb58ee75640efed219c6bbec"
+ ],
+ "5": [
+
+ ],
+ "6": [
+ "R_sessionInfo.log:md5,fb0da0d7ad6994ed66a8e68348b19676"
+ ],
+ "7": [
+ [
+ "RAP1_IAA_30M_REP1.txt:md5,ce4ff0b74aeedc3dc12a764c3504c9df",
+ "RAP1_UNINDUCED_REP1.txt:md5,51c9b23be5e82670aceb14f7e58dd867",
+ "RAP1_UNINDUCED_REP2.txt:md5,2c56106abcd9d31980f672b6e2862ee8",
+ "WT_REP1.txt:md5,5e3fe5f7e9b7f300be43649a8b496352",
+ "WT_REP2.txt:md5,2ce093f2c2e92c1bde1cd3da91ac884c",
+ "deseq2.size_factors.RData:md5,51c6643a0f8a9edabbff8df0165451f2"
+ ]
+ ],
+ "8": [
+ "versions.yml:md5,60f8e4f473397a4b5d1a3dc490c93ec5"
+ ],
+ "dists_multiqc": [
+
+ ],
+ "dists_txt": [
+ "deseq2.sample.dists.txt:md5,1616ce40eb58ee75640efed219c6bbec"
+ ],
+ "log": [
+ "R_sessionInfo.log:md5,fb0da0d7ad6994ed66a8e68348b19676"
+ ],
+ "pca_multiqc": [
+
+ ],
+ "pca_txt": [
+ "deseq2.pca.vals.txt:md5,4cda8e32ec39326c1350e77b4b607aad"
+ ],
+ "pdf": [
+ "deseq2.plots.pdf:md5,066dd6e447a41b6a361b9c9776013b17"
+ ],
+ "rdata": [
+ "deseq2.dds.RData:md5,c7c1872e7566321d0c3f7ca56c463088"
+ ],
+ "size_factors": [
+ [
+ "RAP1_IAA_30M_REP1.txt:md5,ce4ff0b74aeedc3dc12a764c3504c9df",
+ "RAP1_UNINDUCED_REP1.txt:md5,51c9b23be5e82670aceb14f7e58dd867",
+ "RAP1_UNINDUCED_REP2.txt:md5,2c56106abcd9d31980f672b6e2862ee8",
+ "WT_REP1.txt:md5,5e3fe5f7e9b7f300be43649a8b496352",
+ "WT_REP2.txt:md5,2ce093f2c2e92c1bde1cd3da91ac884c",
+ "deseq2.size_factors.RData:md5,51c6643a0f8a9edabbff8df0165451f2"
+ ]
+ ],
+ "versions": [
+ "versions.yml:md5,60f8e4f473397a4b5d1a3dc490c93ec5"
+ ]
+ }
+ ],
+ "meta": {
+ "nf-test": "0.8.4",
+ "nextflow": "23.10.1"
+ },
+ "timestamp": "2024-03-07T11:47:31.43621"
+ }
+}
\ No newline at end of file
From ff2ddbc860a75d04d8d9ba8a4ea2c9d2fa1cdbd2 Mon Sep 17 00:00:00 2001
From: Adam Talbot <12817534+adamrtalbot@users.noreply.github.com>
Date: Thu, 7 Mar 2024 12:41:13 +0000
Subject: [PATCH 2/2] deseq2_qc: Move test data into separate files
---
.../local/deseq2_qc/tests/data/countFile.tsv | 18 ++++
.../tests/data/deseq2_clustering_header.txt | 12 +++
.../tests/data/deseq2_pca_header.txt | 11 +++
modules/local/deseq2_qc/tests/main.nf.test | 77 +++------------
.../local/deseq2_qc/tests/main.nf.test.snap | 98 ++++++-------------
5 files changed, 82 insertions(+), 134 deletions(-)
create mode 100644 modules/local/deseq2_qc/tests/data/countFile.tsv
create mode 100644 modules/local/deseq2_qc/tests/data/deseq2_clustering_header.txt
create mode 100644 modules/local/deseq2_qc/tests/data/deseq2_pca_header.txt
diff --git a/modules/local/deseq2_qc/tests/data/countFile.tsv b/modules/local/deseq2_qc/tests/data/countFile.tsv
new file mode 100644
index 000000000..d4129d651
--- /dev/null
+++ b/modules/local/deseq2_qc/tests/data/countFile.tsv
@@ -0,0 +1,18 @@
+gene_id gene_name RAP1_IAA_30M_REP1 RAP1_UNINDUCED_REP1 RAP1_UNINDUCED_REP2 WT_REP1 WT_REP2
+Gfp_transgene_gene Gfp_transgene_gene 0 0 0 0 0
+HRA1 HRA1 3.01943228500291 9.80701185810843 9.53274413980081 5.72894534769954 5.9648842559222
+snR18 snR18 2.15518528497702 20.2706605484032 10.1398196728994 5.78313737408605 5.79976683844901
+YAL001C TFC3 56.5487189493641 70.7846010387686 113.108816589334 60.5178622417112 30.2958040068545
+YAL002W VPS8 36.3862437592078 32.3965311942571 80.536128672497 63.6031126291227 25.2702744059695
+YAL003W EFB1 598.396699649099 887.339579289614 1856.66699260635 1049.93553354283 665.403243069765
+YAL004W YAL004W 388.410667489585 383.296795393227 203.744142706403 202.691892385957 251.440658667147
+YAL005C SSA1 5647.27979655766 5715.94369645599 12575.108029018 7775.42737695585 3903.66710060582
+YAL007C ERP2 44.6930487868818 60.9301400694571 143.68466075721 56.9486461946981 41.7805866183878
+YAL008W FUN14 13.1986081960994 18.7996646072737 26.552459043029 9.4087625308538 2.82245410144267
+YAL009W SPO7 13.5217762310537 15.8719804576371 20.113413795 8.67724034815225 4.82436501953514
+YAL010C MDM10 10.9410758413598 12.0839661783069 36.2679562039924 29.7986383847897 9.94377960724503
+YAL011W SWC3 12.0055027348268 24.9403272396788 35.9299792122994 19.9834911886444 18.0057148106317
+YAL012W CYS3 242.877787996136 236.466395413312 547.58060621785 378.571834233094 226.984289418222
+YAL013W DEP1 7.90662508175251 18.3153373366285 35.6289306191157 20.7248252538103 10.8672258295774
+YAL014C SYN8 15.4361922388434 21.2042068878003 44.5485583043788 26.9652946879967 16.3840947562552
+YAL015C NTG1 12.841137836752 12.2213888342821 28.5292052419374 7.89073247427083 5.92421903162791
diff --git a/modules/local/deseq2_qc/tests/data/deseq2_clustering_header.txt b/modules/local/deseq2_qc/tests/data/deseq2_clustering_header.txt
new file mode 100644
index 000000000..04e10efa5
--- /dev/null
+++ b/modules/local/deseq2_qc/tests/data/deseq2_clustering_header.txt
@@ -0,0 +1,12 @@
+#id: 'deseq2_clustering'
+#section_name: 'DESeq2 sample similarity'
+#description: "is generated from clustering by Euclidean distances between
+# DESeq2
+# rlog values for each sample
+# in the deseq2_qc.r
script."
+#plot_type: 'heatmap'
+#anchor: 'deseq2_clustering'
+#pconfig:
+# title: 'DESeq2: Heatmap of the sample-to-sample distances'
+# xlab: True
+# reverseColors: True
diff --git a/modules/local/deseq2_qc/tests/data/deseq2_pca_header.txt b/modules/local/deseq2_qc/tests/data/deseq2_pca_header.txt
new file mode 100644
index 000000000..636f9374d
--- /dev/null
+++ b/modules/local/deseq2_qc/tests/data/deseq2_pca_header.txt
@@ -0,0 +1,11 @@
+#id: 'deseq2_pca'
+#section_name: 'DESeq2 PCA plot'
+#description: "PCA plot between samples in the experiment.
+# These values are calculated using DESeq2
+# in the deseq2_qc.r
script."
+#plot_type: 'scatter'
+#anchor: 'deseq2_pca'
+#pconfig:
+# title: 'DESeq2: Principal component plot'
+# xlab: PC1
+# ylab: PC2
diff --git a/modules/local/deseq2_qc/tests/main.nf.test b/modules/local/deseq2_qc/tests/main.nf.test
index 3fa938d26..bdd9ff3aa 100644
--- a/modules/local/deseq2_qc/tests/main.nf.test
+++ b/modules/local/deseq2_qc/tests/main.nf.test
@@ -9,76 +9,25 @@ nextflow_process {
when {
process {
"""
- // Taken from example salmon merged data from -profile test
- def fileContents = [
- 'gene_id gene_name RAP1_IAA_30M_REP1 RAP1_UNINDUCED_REP1 RAP1_UNINDUCED_REP2 WT_REP1 WT_REP2',
- 'Gfp_transgene_gene Gfp_transgene_gene 0 0 0 0 0',
- 'HRA1 HRA1 3.01943228500291 9.80701185810843 9.53274413980081 5.72894534769954 5.9648842559222',
- 'snR18 snR18 2.15518528497702 20.2706605484032 10.1398196728994 5.78313737408605 5.79976683844901',
- 'YAL001C TFC3 56.5487189493641 70.7846010387686 113.108816589334 60.5178622417112 30.2958040068545',
- 'YAL002W VPS8 36.3862437592078 32.3965311942571 80.536128672497 63.6031126291227 25.2702744059695',
- 'YAL003W EFB1 598.396699649099 887.339579289614 1856.66699260635 1049.93553354283 665.403243069765',
- 'YAL004W YAL004W 388.410667489585 383.296795393227 203.744142706403 202.691892385957 251.440658667147',
- 'YAL005C SSA1 5647.27979655766 5715.94369645599 12575.108029018 7775.42737695585 3903.66710060582',
- 'YAL007C ERP2 44.6930487868818 60.9301400694571 143.68466075721 56.9486461946981 41.7805866183878',
- 'YAL008W FUN14 13.1986081960994 18.7996646072737 26.552459043029 9.4087625308538 2.82245410144267',
- 'YAL009W SPO7 13.5217762310537 15.8719804576371 20.113413795 8.67724034815225 4.82436501953514',
- 'YAL010C MDM10 10.9410758413598 12.0839661783069 36.2679562039924 29.7986383847897 9.94377960724503',
- 'YAL011W SWC3 12.0055027348268 24.9403272396788 35.9299792122994 19.9834911886444 18.0057148106317',
- 'YAL012W CYS3 242.877787996136 236.466395413312 547.58060621785 378.571834233094 226.984289418222',
- 'YAL013W DEP1 7.90662508175251 18.3153373366285 35.6289306191157 20.7248252538103 10.8672258295774',
- 'YAL014C SYN8 15.4361922388434 21.2042068878003 44.5485583043788 26.9652946879967 16.3840947562552',
- 'YAL015C NTG1 12.841137836752 12.2213888342821 28.5292052419374 7.89073247427083 5.92421903162791',
- ]
- def countFile = file("${workDir}/countFile.tsv")
- countFile.withWriter{ out ->
- fileContents.each {out.println it}
- }
-
- def pcaHeaderFile = file("${workDir}/deseq2_pca_header.txt")
- def pcaHeaderContents = '''
- #id: 'deseq2_pca'
- #section_name: 'DESeq2 PCA plot'
- #description: "PCA plot between samples in the experiment.
- # These values are calculated using DESeq2
- # in the deseq2_qc.r
script."
- #plot_type: 'scatter'
- #anchor: 'deseq2_pca'
- #pconfig:
- # title: 'DESeq2: Principal component plot'
- # xlab: PC1
- # ylab: PC2
- '''.stripIndent().trim()
- pcaHeaderFile.write(pcaHeaderContents)
-
- def clusteringHeaderFile = file("${workDir}/deseq2_clustering_header.txt")
- def clusteringHeaderContents = '''
- #id: 'deseq2_clustering'
- #section_name: 'DESeq2 sample similarity'
- #description: "is generated from clustering by Euclidean distances between
- # DESeq2
- # rlog values for each sample
- # in the deseq2_qc.r
script."
- #plot_type: 'heatmap'
- #anchor: 'deseq2_clustering'
- #pconfig:
- # title: 'DESeq2: Heatmap of the sample-to-sample distances'
- # xlab: True
- # reverseColors: True
- '''.stripIndent().trim()
- clusteringHeaderFile.write(clusteringHeaderContents)
-
- input[0] = countFile
- input[1] = pcaHeaderFile
- input[2] = clusteringHeaderFile
- """
+ input[0] = file("${moduleTestDir}/data/countFile.tsv")
+ input[1] = file("${moduleTestDir}/data/deseq2_pca_header.txt")
+ input[2] = file("${moduleTestDir}/data/deseq2_clustering_header.txt")
+ """.stripIndent().trim()
}
}
then {
assertAll(
{ assert process.success },
- { assert snapshot(process.out).match() }
+ { assert snapshot(
+ process.out.dists_multiqc,
+ process.out.dists_txt,
+ process.out.log,
+ process.out.pca_multiqc,
+ process.out.pca_txt,
+ process.out.rdata,
+ process.out.size_factors
+ ).match() }
)
}
diff --git a/modules/local/deseq2_qc/tests/main.nf.test.snap b/modules/local/deseq2_qc/tests/main.nf.test.snap
index 626fb065b..865b8d5b8 100644
--- a/modules/local/deseq2_qc/tests/main.nf.test.snap
+++ b/modules/local/deseq2_qc/tests/main.nf.test.snap
@@ -1,81 +1,39 @@
{
"parse count data correctly": {
"content": [
- {
- "0": [
- "deseq2.plots.pdf:md5,066dd6e447a41b6a361b9c9776013b17"
- ],
- "1": [
- "deseq2.dds.RData:md5,c7c1872e7566321d0c3f7ca56c463088"
- ],
- "2": [
- "deseq2.pca.vals.txt:md5,4cda8e32ec39326c1350e77b4b607aad"
- ],
- "3": [
-
- ],
- "4": [
- "deseq2.sample.dists.txt:md5,1616ce40eb58ee75640efed219c6bbec"
- ],
- "5": [
-
- ],
- "6": [
- "R_sessionInfo.log:md5,fb0da0d7ad6994ed66a8e68348b19676"
- ],
- "7": [
- [
- "RAP1_IAA_30M_REP1.txt:md5,ce4ff0b74aeedc3dc12a764c3504c9df",
- "RAP1_UNINDUCED_REP1.txt:md5,51c9b23be5e82670aceb14f7e58dd867",
- "RAP1_UNINDUCED_REP2.txt:md5,2c56106abcd9d31980f672b6e2862ee8",
- "WT_REP1.txt:md5,5e3fe5f7e9b7f300be43649a8b496352",
- "WT_REP2.txt:md5,2ce093f2c2e92c1bde1cd3da91ac884c",
- "deseq2.size_factors.RData:md5,51c6643a0f8a9edabbff8df0165451f2"
- ]
- ],
- "8": [
- "versions.yml:md5,60f8e4f473397a4b5d1a3dc490c93ec5"
- ],
- "dists_multiqc": [
-
- ],
- "dists_txt": [
- "deseq2.sample.dists.txt:md5,1616ce40eb58ee75640efed219c6bbec"
- ],
- "log": [
- "R_sessionInfo.log:md5,fb0da0d7ad6994ed66a8e68348b19676"
- ],
- "pca_multiqc": [
-
- ],
- "pca_txt": [
- "deseq2.pca.vals.txt:md5,4cda8e32ec39326c1350e77b4b607aad"
- ],
- "pdf": [
- "deseq2.plots.pdf:md5,066dd6e447a41b6a361b9c9776013b17"
- ],
- "rdata": [
- "deseq2.dds.RData:md5,c7c1872e7566321d0c3f7ca56c463088"
- ],
- "size_factors": [
- [
- "RAP1_IAA_30M_REP1.txt:md5,ce4ff0b74aeedc3dc12a764c3504c9df",
- "RAP1_UNINDUCED_REP1.txt:md5,51c9b23be5e82670aceb14f7e58dd867",
- "RAP1_UNINDUCED_REP2.txt:md5,2c56106abcd9d31980f672b6e2862ee8",
- "WT_REP1.txt:md5,5e3fe5f7e9b7f300be43649a8b496352",
- "WT_REP2.txt:md5,2ce093f2c2e92c1bde1cd3da91ac884c",
- "deseq2.size_factors.RData:md5,51c6643a0f8a9edabbff8df0165451f2"
- ]
- ],
- "versions": [
- "versions.yml:md5,60f8e4f473397a4b5d1a3dc490c93ec5"
+ [
+
+ ],
+ [
+ "deseq2.sample.dists.txt:md5,1616ce40eb58ee75640efed219c6bbec"
+ ],
+ [
+ "R_sessionInfo.log:md5,fb0da0d7ad6994ed66a8e68348b19676"
+ ],
+ [
+
+ ],
+ [
+ "deseq2.pca.vals.txt:md5,4cda8e32ec39326c1350e77b4b607aad"
+ ],
+ [
+ "deseq2.dds.RData:md5,c7c1872e7566321d0c3f7ca56c463088"
+ ],
+ [
+ [
+ "RAP1_IAA_30M_REP1.txt:md5,ce4ff0b74aeedc3dc12a764c3504c9df",
+ "RAP1_UNINDUCED_REP1.txt:md5,51c9b23be5e82670aceb14f7e58dd867",
+ "RAP1_UNINDUCED_REP2.txt:md5,2c56106abcd9d31980f672b6e2862ee8",
+ "WT_REP1.txt:md5,5e3fe5f7e9b7f300be43649a8b496352",
+ "WT_REP2.txt:md5,2ce093f2c2e92c1bde1cd3da91ac884c",
+ "deseq2.size_factors.RData:md5,51c6643a0f8a9edabbff8df0165451f2"
]
- }
+ ]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
- "timestamp": "2024-03-07T11:47:31.43621"
+ "timestamp": "2024-03-07T12:34:51.582179"
}
}
\ No newline at end of file