From 0ccb6052220a9221350fb6116aaa15ffd25c9381 Mon Sep 17 00:00:00 2001 From: Chen Yang Date: Fri, 8 Nov 2024 11:06:53 -0600 Subject: [PATCH] fix: Handle zero-sum samples in generate_taxa_trend_test_long - Add check for samples with zero total counts after filtering - Remove zero-sum samples before running linda analysis - Prevent NA values during TSS normalization - Related to Issue #69 --- R/generate_taxa_trend_test_long.R | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/generate_taxa_trend_test_long.R b/R/generate_taxa_trend_test_long.R index 675bd2c..73dcf93 100644 --- a/R/generate_taxa_trend_test_long.R +++ b/R/generate_taxa_trend_test_long.R @@ -239,6 +239,13 @@ generate_taxa_trend_test_long <- feature.dat.type = "proportion" } + # 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,