I was just wondering why this code doesn't produce an error?
IRanges(start=1,end=0)
Best regards,
Vedran
I'm using IRanges_2.2.9
I was just wondering why this code doesn't produce an error?
IRanges(start=1,end=0)
Best regards,
Vedran
I'm using IRanges_2.2.9
I think you mean why can the start be larger than the end? If the start is 1 less than the end, it indicates an empty range.
Hi,
Zero-width ranges are used to represent insertion points. It might be a little bit shocking at first to see a start that is equal to end + 1 but that's because we use a representation where the interval is closed on both sides:
IRanges(11, width=3:0) # IRanges of length 4 # start end width # [1] 11 13 3 # [2] 11 12 2 # [3] 11 11 1 # [4] 11 10 0
The last range is a zero-width range. It represents an insertion between positions 10 and 11. Yes it might be a little bit shocking to see that it ends before it even started but... what else could the start and end be for this range?
For example such zero-width range can be used to perform an insertion in a DNA sequence:
library(Biostrings) ## Insert 3 nucleotides between positions 10 and 11: replaceAt(DNAString("AAAAATTTTTGG"), IRanges(11, 10), "ACA") ## 15-letter "DNAString" instance ## seq: AAAAATTTTTACAGG
Hope this helps,
H.
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Why do you think it should produce an error? The starting position of a range has nothing to do with the width.