From a111cae8348a0954ac560e700737f00d85e891c3 Mon Sep 17 00:00:00 2001 From: Sarah Griffiths Date: Tue, 15 Nov 2022 14:59:43 +0000 Subject: [PATCH] CW-1167: error if conditionsheet and sample sheet dont match --- CHANGELOG.md | 2 ++ README.md | 4 ++-- bin/de_analysis.R | 3 ++- bin/plot_dtu_results.R | 2 +- docs/quickstart.md | 4 ++-- main.nf | 5 +++++ test_data/condition_sheet.tsv | 3 ++- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00ad43d..c5c9773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Demo differential expression data in repository. - Improved DE explanation in docs +### Fixed +- Error if condition sheet and sample sheet don't match. ## [v0.1.5] ### Added diff --git a/README.md b/README.md index d9d7570..c50354e 100644 --- a/README.md +++ b/README.md @@ -206,14 +206,14 @@ Differential Expression requires at least 2 replicates of each sample to compare #### Condition sheet The condition sheet should be a .tsv with two columns. -- The sample column will need to match the 6 directories in the input fastq directory. +- The sample_id column will need to match the 6 directories in the input fastq directory, if you are additionally using a sample_sheet they will need to correspond to the sample_ids in that. - The condition column will need to contain one of two keys to indicate the two samples being compared. In the default `condition_sheet.tsv` available in the test_data directory we have used the following. eg. condition_sheet.tsv ``` -sample,condition +sample_id,condition barcode01,untreated barcode02,untreated barcode03,untreated diff --git a/bin/de_analysis.R b/bin/de_analysis.R index 902e1a3..2b32c45 100755 --- a/bin/de_analysis.R +++ b/bin/de_analysis.R @@ -7,7 +7,8 @@ cat("Loading counts, conditions and parameters.\n") cts <- as.matrix(read.csv("merged/all_counts.tsv", sep="\t", row.names="Reference", stringsAsFactors=FALSE)) # Set up sample data frame: -coldata <- read.csv("de_analysis/coldata.tsv", row.names="sample", sep=",", stringsAsFactors=TRUE) +#changed this to sample_id +coldata <- read.csv("de_analysis/coldata.tsv", row.names="sample_id", sep=",", stringsAsFactors=TRUE) coldata$sample_id <- rownames(coldata) coldata$condition <- factor(coldata$condition, levels=rev(levels(coldata$condition))) diff --git a/bin/plot_dtu_results.R b/bin/plot_dtu_results.R index d2b73cd..ec90582 100755 --- a/bin/plot_dtu_results.R +++ b/bin/plot_dtu_results.R @@ -5,7 +5,7 @@ suppressMessages(library(ggplot2)) suppressMessages(library(tidyr)) # Set up sample data frame: -coldata <- read.csv("de_analysis/coldata.tsv", row.names="sample", sep=",") +coldata <- read.csv("de_analysis/coldata.tsv", row.names="sample_id", sep=",") coldata$sample_id <- rownames(coldata) coldata$condition <- factor(coldata$condition, levels=rev(levels(coldata$condition))) coldata$type <-NULL diff --git a/docs/quickstart.md b/docs/quickstart.md index 1b4b7ae..1cda486 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -124,14 +124,14 @@ Differential Expression requires at least 2 replicates of each sample to compare #### Condition sheet The condition sheet should be a .tsv with two columns. -- The sample column will need to match the 6 directories in the input fastq directory. +- The sample_id column will need to match the 6 directories in the input fastq directory, if you are additionally using a sample_sheet they will need to correspond to the sample_ids in that. - The condition column will need to contain one of two keys to indicate the two samples being compared. In the default `condition_sheet.tsv` available in the test_data directory we have used the following. eg. condition_sheet.tsv ``` -sample,condition +sample_id,condition barcode01,untreated barcode02,untreated barcode03,untreated diff --git a/main.nf b/main.nf index f9f5da3..a3f07c9 100644 --- a/main.nf +++ b/main.nf @@ -471,6 +471,11 @@ workflow pipeline { transcriptome = ref_transcriptome gtf = Channel.fromPath(ref_annotation) } + check_match = Channel.fromPath(params.condition_sheet) + check_condition_sheet = check_match.splitCsv(header: true).map{ row -> tuple( + row.sample_id) + } + check_condition_sheet.join(summariseConcatReads.out.input_reads, failOnMismatch: true) de = differential_expression(transcriptome, summariseConcatReads.out.input_reads, condition_sheet, gtf) de_report = de.all_de count_transcripts_file = de.count_transcripts diff --git a/test_data/condition_sheet.tsv b/test_data/condition_sheet.tsv index 22b4a0b..0c35da6 100644 --- a/test_data/condition_sheet.tsv +++ b/test_data/condition_sheet.tsv @@ -1,6 +1,7 @@ -sample,condition +sample_id,condition barcode01,untreated barcode02,untreated +barcode03,untreated barcode04,treated barcode05,treated barcode06,treated