Closed kgori closed 5 years ago
When idx only pulls out a single row, then variants[idx, ] is interpreted as a character vector, and it breaks the apply.
idx
variants[idx, ]
apply
Arguably not a big issue as we don't expect anyone to use samples with a single mutation, it's more of an annoyance.
# Example of the bug variants <- data.frame(sample = c("sample1", "sample1", "sample1", "sample2"), ref = c("T", "G", "A", "G"), alt = c("G", "T", "C", "C"), trinuc = c("TTG", "TGC", "TAT", "AGA")) build_catalogues(variants) # breaks # Error in apply(variants[idx, ], 1, function(var) { : # dim(X) must have a positive length variants <- data.frame(sample = c("sample1", "sample1", "sample2", "sample2"), ref = c("T", "G", "A", "G"), alt = c("G", "T", "C", "C"), trinuc = c("TTG", "TGC", "TAT", "AGA")) build_catalogues(variants) # works
Fixed in dev using this nice trick: https://www.r-bloggers.com/design-flaws-in-r-2-%e2%80%94-dropped%c2%a0dimensions/
When
idx
only pulls out a single row, thenvariants[idx, ]
is interpreted as a character vector, and it breaks theapply
.Arguably not a big issue as we don't expect anyone to use samples with a single mutation, it's more of an annoyance.