From 55a36e81ae70906f1beaebdd430e2aab707e21ed Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Wed, 10 Apr 2024 15:06:38 +0200 Subject: [PATCH] Retranslated `computeDiffInCounts()` (#24) --- R/computeDiffInCounts.R | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/R/computeDiffInCounts.R b/R/computeDiffInCounts.R index c8abbfa..10a3beb 100644 --- a/R/computeDiffInCounts.R +++ b/R/computeDiffInCounts.R @@ -4,20 +4,14 @@ computeDiffInCounts <- function(rows, max_noalle, nloci, data) { # % riveill� rows. rows pit�� olla vaakavektori. diffInCounts <- zeros(max_noalle, nloci) - for (i in seq_len(nrow(data))) { + for (i in rows) { # yep, just one iteration row <- data[i, ] notEmpty <- as.matrix(matlab2r::find(row >= 0)) if (length(notEmpty) > 0) { - diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] <- - diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] + 1 + element <- row[notEmpty] + (notEmpty - 1) * max_noalle + diffInCounts[element] <- diffInCounts[element] + 1 } } - diffInCounts <- matrix( - data = diffInCounts[!is.na(diffInCounts)], - nrow = max_noalle, - ncol = nloci, - byrow = TRUE - ) return(diffInCounts) }