About the VariantAnnotation package, the document filterVcf compiled on October 13, 2015 shows the following function on page 4:
isSnp <- function(x) { refSnp <- nchar(ref(x)) == 1L a <- alt(x) altSnp <- elementLengths(a) == 1L ai <- unlist(a[altSnp]) # all length 1, so unlisting is 1:1 map altSnp[altSnp] <- nchar(ai) == 1L & (ai %in% c("A", "C", "G", "T")) refSnp & altSnp }
On line 6, I don't understand why it's not:
altSnp <- nchar(ai) == 1L & (ai %in% c("A", "C", "G", "T"))
That is, why is it necessary to write altSnp[altSnp]
?
Moreover, if I understand well the code above, it returns TRUE only if x corresponds to a biallelic SNP for which the alternate allele is A, C, G or T. Just in case, it may be relevant to check that the ref allele also is A, C, G or T.
I didn't see the
isSNV
function, thanks for mentioning it, it's much simpler. Can you edit the "filterVcf.pdf" document?