diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eca851..27a1a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] ### Changed +- Improved handling of different annotation file types (eg. `.gtf/.gff/.gff3`) in `de_analysis` mode. - Improved handling of annotation files that do not contain version numbers in transcript_id (such as gtf's from Ensembl). ### Fixed - Differential expression failing with 10 or more samples. diff --git a/bin/de_analysis.R b/bin/de_analysis.R index cdc8f45..4aae056 100755 --- a/bin/de_analysis.R +++ b/bin/de_analysis.R @@ -9,7 +9,6 @@ min_samps_gene_expr <- as.numeric(args[2]) min_samps_feature_expr <- as.numeric(args[3]) min_gene_expr <- as.numeric(args[4]) min_feature_expr <- as.numeric(args[5]) -annotation_type <- args[6] cat("Loading counts, conditions and parameters.\n") cts <- as.matrix(read.csv("all_counts.tsv", sep="\t", row.names="Reference", stringsAsFactors=FALSE)) @@ -25,6 +24,23 @@ if(!"control" %in% coldata$condition) condition - unable to set reference.") coldata$condition <- relevel(coldata$condition, ref = "control") +# a .gff annotation file extension may be gff2(gtf) or gff3 so check in files for use of = in the attribute field +# if '=' present it is gff3 if not it is gtf. +# see https://www.ensembl.org/info/website/upload/gff.html +# and http://gmod.org/wiki/GFF2#Converting_GFF2_to_GFF3 +cat("Checking annotation file type.\n") +lines <- readLines(file(ref_annotation), n=10000) +# If transcript_id containing '=' (format eg. transcript_id=xxx) +# annotation type is gff3 +check_file_type <- sum(grepl("transcript_id=", lines)) +if (check_file_type != 0){ + cat("Annotation file type is gff3.\n") + annotation_type <- "gff3" +} else { + # otherwise gtf + cat("Annotation file type is gtf.\n") + annotation_type <- "gtf" +} # Transcript_id versions (eg. ENTXXX.1, eg. ENTXXX.2) represent how many times that transcript reference has been changed # during its time in the database. diff --git a/subworkflows/differential_expression.nf b/subworkflows/differential_expression.nf index a6e835e..7f85667 100644 --- a/subworkflows/differential_expression.nf +++ b/subworkflows/differential_expression.nf @@ -60,10 +60,6 @@ process mergeTPM { process deAnalysis { label "isoforms" - errorStrategy "retry" - // Retry if it fails to make makeTxDbFromGFF - // Because a file with .gff extension may be gff2(gtf) or gff3 - maxRetries 1 cpus 4 memory "16 GB" input: @@ -79,17 +75,10 @@ process deAnalysis { path "de_analysis/results_dexseq.tsv", emit: dexseq path "de_analysis", emit: de_analysis path "de_analysis/cpm_gene_counts.tsv", emit: cpm - script: - // Just try both annotation file type because a .gff extension may be gff2(gtf) or gff3 - String annotation_type = "gtf" - if (task.attempt == 2){ - annotation_type = "gff3" - log.info("Retry deAnalysis with gff format setting.") - } """ mkdir merged mkdir de_analysis - de_analysis.R annotation.gtf $params.min_samps_gene_expr $params.min_samps_feature_expr $params.min_gene_expr $params.min_feature_expr $annotation_type + de_analysis.R annotation.gtf $params.min_samps_gene_expr $params.min_samps_feature_expr $params.min_gene_expr $params.min_feature_expr """ }