Hi, I noticed that the VRanges class doesn’t allow to set the strand to minus in some cases. For example when creating an object or when changing the start/end. (examples below)
I saw this from 5 years ago that seems to suggest that a mutation in the negative strand canot be used in VRanges. Is there a reason to restrict variants to only ’*’?
suppressPackageStartupMessages(library(VariantAnnotation))
vr = VRanges(seqnames = "chr1",
ranges = IRanges::IRanges(start = c(186716278,186716284),
width = c(1)),
ref = c("A","G"),
alt = c("T","T"),
strand = "-")
#> Error in GRanges(seqnames, ranges, strand = .rleRecycleVector("*", length(ranges)), : el argumento formal "strand" concuerda con múltiples argumentos especificados
We can workaround the creation of the object like this:
vr = VRanges(seqnames = "chr1",
ranges = IRanges::IRanges(start = c(186716278,186716284),
width = c(1)),
ref = c("A","G"),
alt = c("T","T"))
strand(vr) = "-"
vr
#> VRanges object with 2 ranges and 0 metadata columns:
#> seqnames ranges strand ref alt
#> <Rle> <IRanges> <Rle> <character> <characterOrRle>
#> [1] chr1 186716278 - A T
#> [2] chr1 186716284 - G T
#> totalDepth refDepth altDepth sampleNames
#> <integerOrRle> <integerOrRle> <integerOrRle> <factorOrRle>
#> [1] <NA> <NA> <NA> <NA>
#> [2] <NA> <NA> <NA> <NA>
#> softFilterMatrix
#> <matrix>
#> [1]
#> [2]
#> -------
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
#> hardFilters: NULL
However, when we try to work with it, we got the error back.
start(vr) = start(vr) - 10
#> Error in validObject(object): invalid class "VRanges" object: 'strand' must always be '+' or '*'
Created on 2020-01-13 by the reprex package (v0.3.0)