ourMELONS/R/computeDiffInCounts.R
2024-08-26 06:09:27 +02:00

17 lines
624 B
R
Raw Permalink Blame History

computeDiffInCounts <- function(rows, max_noalle, nloci, data) {
# % Muodostaa max_noalle*nloci taulukon, jossa on niiden alleelien
# % lukum<75><6D>r<EFBFBD>t (vastaavasti kuin COUNTS:issa), jotka ovat data:n
# % riveill<6C> rows. rows pit<69><74> olla vaakavektori.
diffInCounts <- zeros(max_noalle, nloci)
for (i in rows) { # yep, just one iteration
row <- data[i, ]
notEmpty <- as.matrix(matlab2r::find(row >= 0))
if (length(notEmpty) > 0) {
element <- row[notEmpty] + (notEmpty - 1) * max_noalle
diffInCounts[element] <- diffInCounts[element] + 1
}
}
return(as.matrix(diffInCounts))
}