From d0e7fc4b26c8d30189eacc9699810c8633fbf1b4 Mon Sep 17 00:00:00 2001 From: Sarah Griffiths Date: Wed, 28 Jun 2023 17:37:49 +0000 Subject: [PATCH] CW-2308 remove real path use --- bin/de_analysis.R | 16 ++++++++++------ main.nf | 2 ++ subworkflows/differential_expression.nf | 11 +++-------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bin/de_analysis.R b/bin/de_analysis.R index f1a46a1..83059b0 100755 --- a/bin/de_analysis.R +++ b/bin/de_analysis.R @@ -2,6 +2,13 @@ suppressMessages(library("DRIMSeq")) suppressMessages(library("GenomicFeatures")) +args <- commandArgs(trailingOnly=TRUE) +ref_annotation <- args[1] +min_samps_gene_expr <- args[2] +min_samps_feature_expr <- args[3] +min_gene_expr <- args[4] +min_feature_expr <- args[5] +annotation_type <- args[6] cat("Loading counts, conditions and parameters.\n") cts <- as.matrix(read.csv("merged/all_counts.tsv", sep="\t", row.names="Reference", stringsAsFactors=FALSE)) @@ -13,12 +20,9 @@ coldata <- read.csv("de_analysis/coldata.tsv", row.names="sample_id", sep=",", s coldata$sample_id <- rownames(coldata) coldata$condition <- factor(coldata$condition, levels=rev(levels(coldata$condition))) -de_params <- read.csv("de_analysis/de_params.tsv", sep="\t", stringsAsFactors=FALSE) - cat("Loading annotation database.\n") -annotationtype <- de_params$annotation_type[[1]] -txdb <- makeTxDbFromGFF("annotation.gtf", format = annotationtype) +txdb <- makeTxDbFromGFF(ref_annotation, format = annotation_type) txdf <- select(txdb, keys(txdb,"GENEID"), "TXNAME", "GENEID") tab <- table(txdf$GENEID) txdf$ntx<- tab[match(txdf$GENEID, names(tab))] @@ -47,8 +51,8 @@ cat("Filtering counts using DRIMSeq.\n") d <- dmDSdata(counts=counts, samples=coldata) trs_cts_unfiltered <- counts(d) -d <- dmFilter(d, min_samps_gene_expr = de_params$min_samps_gene_expr[[1]], min_samps_feature_expr = de_params$min_samps_feature_expr[[1]], - min_gene_expr = de_params$min_gene_expr[[1]], min_feature_expr = de_params$min_feature_expr[[1]]) +d <- dmFilter(d, min_samps_gene_expr = min_samps_gene_expr, min_samps_feature_expr = min_samps_feature_expr, + min_gene_expr = min_gene_expr, min_feature_expr = min_feature_expr) cat("Building model matrix.\n") design <- model.matrix(~condition, data=DRIMSeq::samples(d)) diff --git a/main.nf b/main.nf index 706b87e..3cf0d15 100644 --- a/main.nf +++ b/main.nf @@ -505,6 +505,8 @@ workflow pipeline { stats = reads.map { it[2] ? it[2].resolve('per-read-stats.tsv') : null } + | collectFile ( keepHeader: true ) + | ifEmpty ( OPTIONAL_FILE ) if (!params.direct_rna){ preprocess_reads(input_reads) diff --git a/subworkflows/differential_expression.nf b/subworkflows/differential_expression.nf index a3fda47..f421a86 100644 --- a/subworkflows/differential_expression.nf +++ b/subworkflows/differential_expression.nf @@ -46,7 +46,7 @@ process deAnalysis { input: path condition_sheet path merged_tsv - path annotation + path "annotation.gtf" output: path "de_analysis/results_dtu_stageR.tsv", emit: stageR path "merged/all_counts_filtered.tsv", emit: flt_counts @@ -61,17 +61,12 @@ process deAnalysis { annotation_type = "gff3" } """ - cp $annotation annotation.gtf - echo \$(realpath annotation.gtf) - echo Annotation\$'\t'min_samps_gene_expr\$'\t'min_samps_feature_expr\$'\t'min_gene_expr\$'\t'min_feature_expr\$'\t'annotation_type > params.tsv - echo \$(realpath $params.ref_annotation)\$'\t'$params.min_samps_gene_expr\$'\t'\ - $params.min_samps_feature_expr\$'\t'$params.min_gene_expr\$'\t'$params.min_feature_expr\$'\t'$annotation_type >> params.tsv mkdir merged mkdir de_analysis mv $merged_tsv merged/all_counts.tsv - mv params.tsv de_analysis/de_params.tsv mv $condition_sheet de_analysis/coldata.tsv - de_analysis.R + 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 + """ }