ourMELONS/R/computeDiffInCounts.R

18 lines
587 B
R
Raw Normal View History

2020-11-09 14:58:16 +01:00
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)
2021-06-29 10:37:42 +02:00
for (i in seq_len(nrow(data))) {
2020-11-09 14:58:16 +01:00
row <- data[i, ]
2021-02-01 09:22:58 +01:00
notEmpty <- as.matrix(find(row>=0))
2020-11-09 14:58:16 +01:00
if (length(notEmpty) > 0) {
2020-11-19 07:53:36 +01:00
diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] <-
diffInCounts[row(notEmpty) + (notEmpty - 1) * max_noalle] + 1
2020-11-09 14:58:16 +01:00
}
}
return(diffInCounts)
}