From bd3a824e1065579de27f933d4e94fc5e7448c426 Mon Sep 17 00:00:00 2001 From: laurencekuhl Date: Wed, 10 Jul 2024 15:10:16 +0200 Subject: [PATCH] Fix MAGeCKFlute error --- CHANGELOG.md | 1 + templates/template_fluteMLE.R | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa6ea58..f96079c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix singularity image pull tag for MAGeCKFlute ([#160](https://github.com/nf-core/crisprseq/pull/160)) - Skip dolar signs on containerOptions ([#163](https://github.com/nf-core/crisprseq/pull/163)) - Fix error in R script when adding patterns ([#170](https://github.com/nf-core/crisprseq/pull/170)) +- Skip MAGeCKFlute when the function produces an error within the R package ### Deprecated diff --git a/templates/template_fluteMLE.R b/templates/template_fluteMLE.R index 1a9c10fd..015e4457 100644 --- a/templates/template_fluteMLE.R +++ b/templates/template_fluteMLE.R @@ -17,14 +17,28 @@ before_beta <- sub("\\\\.beta.*", "", beta_strings) unique_strings <- unique(before_beta) for(i in unique_strings) { - FluteMLE(mle, treatname= i, proj=i, pathview.top=5) - } + tryCatch( + { + FluteMLE(mle, treatname= i, proj=i, pathview.top=5) + }, + error=function(e) { + print(paste0("Could not run FluteMLE with project ",i)) + } + ) + } } else { beta_strings <- grep("\\\\.beta", colnames(mle), value = TRUE) before_beta <- sub("\\\\.beta.*", "", beta_strings) unique_strings <- unique(before_beta) for(i in unique_strings) { - FluteMLE(mle, treatname= i, proj=i, ${args}, pathview.top=5) + tryCatch( + { + FluteMLE(mle, treatname= i, proj=i, ${args}, pathview.top=5) + }, + error=function(e) { + print(paste0("Could not run FluteMLE with project ",i)) + } + ) } }