From c07170d6a14010e16d374f041ed7d8c9e3fe4714 Mon Sep 17 00:00:00 2001 From: Yancong Zhang Date: Fri, 28 Apr 2023 12:34:19 -0400 Subject: [PATCH] Fixed issue for cases where there are no features retained after filtering --- NEWS | 3 +++ R/MTXmodel.R | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/NEWS b/NEWS index 42ae3df..6b4b3ca 100755 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ # MTXmodel History # +## Changes in v1.2.3 (2023-04-28) ## +* Fixed issue if no features left after filtering + ## Changes in v1.2.2 (2022-11-14) ## * Fixed warning on if conditions * Fixed issue for sample matching diff --git a/R/MTXmodel.R b/R/MTXmodel.R index f3d3584..5b75d08 100755 --- a/R/MTXmodel.R +++ b/R/MTXmodel.R @@ -1006,6 +1006,31 @@ MTXmodel <- } } + if (ncol(filtered_data_norm) < 1) { + all_outfile <- file.path(output, "all_results.tsv") + mycolnames = c( + "feature", + "metadata", + "value", + "coef", + "stderr", + "N", + "N.not.0", + "pval", + "qval") + write.table( + t(mycolnames), + file = all_outfile, + sep = "\t", + quote = FALSE, + col.names = FALSE, + row.names = FALSE) + + residuals_file = file.path(output, "residuals.rds") + file.create(residuals_file) + return(NULL) + } + # apply the method to the data with the correction logging::loginfo( "Running selected analysis method: %s", analysis_method)