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)
|
|
|
|
|
|
for (i in seq_len(nrow(data))) {
|
|
|
|
|
|
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) {
|
|
|
|
|
|
diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] <-
|
|
|
|
|
|
diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] + 1
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
diffInCounts <- matrix(
|
|
|
|
|
|
data = diffInCounts[!is.na(diffInCounts)],
|
|
|
|
|
|
nrow = max_noalle,
|
|
|
|
|
|
ncol = nloci,
|
|
|
|
|
|
byrow = TRUE
|
|
|
|
|
|
)
|
|
|
|
|
|
return(diffInCounts)
|
2020-11-09 14:58:16 +01:00
|
|
|
|
}
|