From 0b6a899de8174d94bfbb8c4dc5384f65b162a34b Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Mon, 9 Nov 2020 14:58:16 +0100 Subject: [PATCH] Translated computeDiffInCounts --- R/computeDiffInCounts.R | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 R/computeDiffInCounts.R diff --git a/R/computeDiffInCounts.R b/R/computeDiffInCounts.R new file mode 100644 index 0000000..de19e30 --- /dev/null +++ b/R/computeDiffInCounts.R @@ -0,0 +1,17 @@ +computeDiffInCounts <- function(rows, max_noalle, nloci, data) { + # % Muodostaa max_noalle*nloci taulukon, jossa on niiden alleelien + # % lukum��r�t (vastaavasti kuin COUNTS:issa), jotka ovat data:n + # % riveill� rows. rows pit�� olla vaakavektori. + + diffInCounts <- zeros(max_noalle, nloci) + for (i in rows) { + row <- data[i, ] + notEmpty <- find(row>=0) + + if (length(notEmpty) > 0) { + diffInCounts(row(notEmpty) + (notEmpty - 1) * max_noalle) <- + diffInCounts(row(notEmpty) + (notEmpty - 1) * max_noalle) + 1 + } + } + return(diffInCounts) +}