Retranslated computeDiffInCounts() (#24)

This commit is contained in:
Waldir Leoncio 2024-04-10 15:06:38 +02:00
parent c3b8da0012
commit 55a36e81ae

View file

@ -4,20 +4,14 @@ computeDiffInCounts <- function(rows, max_noalle, nloci, data) {
# % riveill<6C> rows. rows pit<69><74> 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)
}