1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
vcf0 <- VCF(rowData=GRanges("chr1", IRanges(1:8, width=c(rep(1, 6), 2, 2))),
fixed=DataFrame(
REF=DNAStringSet(c("A", "G", "C", "T", "T", "G", "GG", "TCT")),
ALT=DNAStringSetList("G", "A", "T", "C", c("C", "TT"), "GG",
"G", "GCG")))
str <- system.file("extdata", "structural.vcf", package="VariantAnnotation")
vcf <- readVcf(str, "")
test_isSNV_CollapsedVCF <- function() {
checkException(isSNV(vcf), silent=TRUE)
checkException(isInsertion(vcf), silent=TRUE)
checkException(isDeletion(vcf), silent=TRUE)
checkException(isIndel(vcf), silent=TRUE)
checkException(isTransition(vcf), silent=TRUE)
checkException(isSubstitution(vcf), silent=TRUE)
res1 <- isSNV(vcf0, singleAltOnly=TRUE)
checkIdentical(res1, c(rep(TRUE, 4), rep(FALSE, 4)))
res2 <- isSNV(vcf0, singleAltOnly=FALSE)
checkIdentical(res2, c(rep(TRUE, 5), rep(FALSE, 3)))
res1 <- isInsertion(vcf0)
checkIdentical(res1, c(rep(FALSE, 5), TRUE, FALSE, FALSE))
res2 <- isDeletion(vcf0)
checkIdentical(res2, c(rep(FALSE, 6), TRUE, FALSE))
res3 <- isIndel(vcf0)
checkIdentical(res3, res1 | res2)
res1 <- isSubstitution(vcf0, singleAltOnly=TRUE)
checkIdentical(res1, c(rep(TRUE, 4), rep(FALSE, 3), TRUE))
res2 <- isSubstitution(vcf0, singleAltOnly=FALSE)
checkIdentical(res2, c(rep(TRUE, 5), rep(FALSE, 2), TRUE))
res1 <- isTransition(vcf0, singleAltOnly=TRUE)
checkIdentical(res1, c(rep(TRUE, 4), rep(FALSE, 4)))
res2 <- isTransition(vcf0, singleAltOnly=FALSE)
checkIdentical(res2, c(rep(TRUE, 5), rep(FALSE, 3)))
}
expand <- VariantAnnotation::expand
test_isSNV_ExpandedVCF <- function() {
evcf <- expand(vcf)
checkException(isSNV(evcf), silent=TRUE)
checkException(isInsertion(evcf), silent=TRUE)
checkException(isDeletion(evcf), silent=TRUE)
checkException(isIndel(evcf), silent=TRUE)
checkException(isTransition(evcf), silent=TRUE)
checkException(isSubstitution(evcf), silent=TRUE)
evcf0 <- expand(vcf0)
res <- isSNV(evcf0)
checkIdentical(sum(res), 5L)
res1 <- isInsertion(evcf0)
checkIdentical(sum(res1), 2L)
res2 <- isDeletion(evcf0)
checkIdentical(sum(res2), 1L)
res3 <- isIndel(evcf0)
checkIdentical(sum(res3), sum(res1 + res2))
res <- isSubstitution(evcf0)
checkIdentical(sum(res), 6L)
res <- isTransition(evcf0)
checkIdentical(sum(res), 5L)
}
test_isSNV_VRanges <- function() {
vr <- as(vcf0, "VRanges")
res <- isSNV(vr)
checkIdentical(sum(res), 5L)
res1 <- isInsertion(vr)
checkIdentical(sum(res1), 2L)
res2 <- isDeletion(vr)
checkIdentical(sum(res2), 1L)
res3 <- isIndel(vr)
checkIdentical(sum(res3), sum(res1 + res2))
res <- isSubstitution(vr)
checkIdentical(sum(res), 6L)
res <- isTransition(vr)
checkIdentical(sum(res), 5L)
}
|