From 0e7f17f2203a342a0a1a66c00fe70715e6edfeac Mon Sep 17 00:00:00 2001 From: Chen Yang Date: Fri, 8 Nov 2024 10:54:08 -0600 Subject: [PATCH] fix: Handle zero-sum samples in generate_taxa_test_single - Add check for samples with zero total counts after filtering - Remove samples with zero counts before running linda analysis - Prevent NA values during TSS normalization - Fix Issue #69 Co-Authored-By: jrotzetter <131970223+jrotzetter@users.noreply.github.com> --- R/generate_taxa_test_single.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/generate_taxa_test_single.R b/R/generate_taxa_test_single.R index 5e6886c..d9bed11 100644 --- a/R/generate_taxa_test_single.R +++ b/R/generate_taxa_test_single.R @@ -150,6 +150,13 @@ generate_taxa_test_single <- function(data.obj, mStat_filter(prev.filter = prev.filter, abund.filter = abund.filter) + # Add this check before linda analysis + if (any(colSums(otu_tax_agg_filter) == 0)) { + keep_samples <- colSums(otu_tax_agg_filter) > 0 + otu_tax_agg_filter <- otu_tax_agg_filter[, keep_samples] + meta_tab <- meta_tab[keep_samples, ] + } + # Perform LinDA (Linear models for Differential Abundance) analysis linda.obj <- linda( feature.dat = otu_tax_agg_filter,