Entering edit mode
                    Zach Roe
        
    
        ▴
    
    10
        @zach-roe-11189
        Last seen 5.5 years ago
        
    I have bed files that are 0-based. Before I do a mergeOverlaps with another granges object that is 1-based, I need to convert the first to 1-base. The shift command moves the whole range by a specific number of base pairs, but I only want to add 1 to the start.
Is there an one line command in GenomicRanges to do this?
library(GenomicRanges)
library(rtracklayer)
# 0-based
bed <- import(file.path(bed.dir, bed.filename), format="bed")
# shift
bed1 <- shift(bed, 1)
bed
> GRanges object with 454075 ranges and 1 metadata column:
>            seqnames            ranges strand |        name
>               <Rle>         <IRanges>  <Rle> | <character>
>        [1]    chr10           1-94200      * |    15_Quies
>        [2]    chr10       94201-96600      * |       9_Het
>        [3]    chr10      96601-119800      * |    15_Quies
>        [4]    chr10     119801-120400      * |      1_TssA
>        [5]    chr10     120401-122000      * |      5_TxWk
>        ...      ...               ...    ... .         ...   [454071]     chrY 58993401-58997200      * |  8_ZNF/Rpts   [454072]     chrY
> 58997201-59001800      * |       9_Het   [454073]     chrY
> 59001801-59002400      * |  8_ZNF/Rpts   [454074]     chrY
> 59002401-59033400      * |       9_Het   [454075]     chrY
> 59033401-59373400      * |    15_Quies   -------   seqinfo: 25
> sequences from an unspecified genome; no seqlengths
bed1
> GRanges object with 454075 ranges and 1 metadata column:
>            seqnames            ranges strand |        name
>               <Rle>         <IRanges>  <Rle> | <character>
>        [1]    chr10           2-94201      * |    15_Quies
>        [2]    chr10       94202-96601      * |       9_Het
>        [3]    chr10      96602-119801      * |    15_Quies
>        [4]    chr10     119802-120401      * |      1_TssA
>        [5]    chr10     120402-122001      * |      5_TxWk
>        ...      ...               ...    ... .         ...   [454071]     chrY 58993402-58997201      * |  8_ZNF/Rpts   [454072]     chrY
> 58997202-59001801      * |       9_Het   [454073]     chrY
> 59001802-59002401      * |  8_ZNF/Rpts   [454074]     chrY
> 59002402-59033401      * |       9_Het   [454075]     chrY
> 59033402-59373401      * |    15_Quies
                    
                
                
Thanks! I missed that, I only checked that my bed files started at 0 and assumed rtracklayer imports as is.