From 7e2f4987e559aa906f600de3a92cf0ffd5525a89 Mon Sep 17 00:00:00 2001 From: James Ashmore Date: Fri, 16 Feb 2024 09:56:37 +0000 Subject: [PATCH] Move read.table out of loop --- assets/multiqc_config.yml | 4 ++-- bin/suppa_split_file.R | 19 +++++++++++-------- nextflow.config | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/assets/multiqc_config.yml b/assets/multiqc_config.yml index 474b860..059da2f 100644 --- a/assets/multiqc_config.yml +++ b/assets/multiqc_config.yml @@ -1,7 +1,7 @@ report_comment: > - This report has been generated by the nf-core/rnasplice + This report has been generated by the nf-core/rnasplice analysis pipeline. For information about how to interpret these results, please see the - documentation. + documentation. report_section_order: "nf-core-rnasplice-methods-description": diff --git a/bin/suppa_split_file.R b/bin/suppa_split_file.R index 1fec398..1971ffb 100755 --- a/bin/suppa_split_file.R +++ b/bin/suppa_split_file.R @@ -35,6 +35,12 @@ if (length(args) == 5){ } +###################################### +######### Read in input file ######### +###################################### + +input_data <- read.csv(input_file, sep="\t", header=TRUE) + ###################################### ####### Process samplesheet ########## ###################################### @@ -63,7 +69,7 @@ conditions <- unique(samplesheet[,"condition"]) ######################################################### # Function for taking all sample names associated with a given condition -split_files <- function(condition, samplesheet, input_file, output_file_suffix, prefix, calculate_ranges){ +split_files <- function(condition, samplesheet, input_data, output_file_suffix, prefix, calculate_ranges){ # Get indices of rows which cover given condition for ranges indices <- which(samplesheet$condition == condition) @@ -71,11 +77,8 @@ split_files <- function(condition, samplesheet, input_file, output_file_suffix, # Get sample names for given condition sample_names <- samplesheet[samplesheet$condition == condition,]$sample - # Read in input file - input_file <- read.csv(input_file, sep="\t", header=TRUE) - - # Check header of input_file contains all samples from processed samplesheet - if (!all(samplesheet$sample %in% colnames(input_file))) { + # Check header of input_data contains all samples from processed samplesheet + if (!all(samplesheet$sample %in% colnames(input_data))) { stop("suppa_split_file.R Input_file must contain samplesheet samples.", call.=FALSE) @@ -92,7 +95,7 @@ split_files <- function(condition, samplesheet, input_file, output_file_suffix, } # Subset input files and save out as new file - write.table(input_file[,sample_names, drop=F], file = output_file, quote = FALSE, sep = "\t") + write.table(input_data[,sample_names, drop=F], file = output_file, quote = FALSE, sep = "\t") # Get Cluster ranges which match the tpm and psi files above (1-3 4-6) # Column numbers have to be continuous, with no overlapping or missing columns between them. Ex:1-3,4-6 @@ -118,7 +121,7 @@ split_files <- function(condition, samplesheet, input_file, output_file_suffix, for (cond in conditions) { # Split files - split_files(cond, samplesheet, input_file, output_file_suffix, prefix, calculate_ranges) + split_files(cond, samplesheet, input_data, output_file_suffix, prefix, calculate_ranges) } diff --git a/nextflow.config b/nextflow.config index 3ac0090..2f63b75 100644 --- a/nextflow.config +++ b/nextflow.config @@ -356,7 +356,7 @@ manifest { description = """Alternative splicing analysis using RNA-seq.""" mainScript = 'main.nf' nextflowVersion = '!>=23.04.0' - version = '1.0.2' + version = '1.0.3' doi = '10.5281/zenodo.8424632' }