2020-11-09 14:58:16 +01:00
|
|
|
|
computeDiffInCounts <- function(rows, max_noalle, nloci, data) {
|
2021-11-10 14:02:35 +01:00
|
|
|
|
# % 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.
|
2020-11-09 14:58:16 +01:00
|
|
|
|
|
2021-11-10 14:02:35 +01:00
|
|
|
|
diffInCounts <- zeros(max_noalle, nloci)
|
2024-04-10 15:06:38 +02:00
|
|
|
|
for (i in rows) { # yep, just one iteration
|
2021-11-10 14:02:35 +01:00
|
|
|
|
row <- data[i, ]
|
2022-02-03 10:43:34 +01:00
|
|
|
|
notEmpty <- as.matrix(matlab2r::find(row >= 0))
|
2020-11-09 14:58:16 +01:00
|
|
|
|
|
2021-11-10 14:02:35 +01:00
|
|
|
|
if (length(notEmpty) > 0) {
|
2024-04-10 15:06:38 +02:00
|
|
|
|
element <- row[notEmpty] + (notEmpty - 1) * max_noalle
|
|
|
|
|
|
diffInCounts[element] <- diffInCounts[element] + 1
|
2021-11-10 14:02:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-26 06:09:27 +02:00
|
|
|
|
return(as.matrix(diffInCounts))
|
2020-11-09 14:58:16 +01:00
|
|
|
|
}
|