Change the start of GenomicRanges list
1
1
Entering edit mode
Jake ▴ 90
@jake-7236
Last seen 20 months ago
United States

Hi,

I have a list of genes in a genomicRanges object. I'd like to resize the genes so that the range starts 500bp downstream from the current TSS without changing the end location. I've been looking at the resize and related functions, but can't figure out how to only change the start and not change the end. Is this possible?

Thanks

genomicranges • 2.0k views
ADD COMMENT
1
Entering edit mode
@herve-pages-1542
Last seen 52 minutes ago
Seattle, WA, United States

Hi Jake,

Here is one way to do this, using resize() (the genes are resized so that the range starts 5bp downstream from the current TSS):

## 2 fake genes
gr <- GRanges("chr1", IRanges(11:12, 30), c("+", "-"))
gr
# GRanges object with 2 ranges and 0 metadata columns:
#       seqnames    ranges strand
#          <Rle> <IRanges>  <Rle>
#   [1]     chr1  [11, 30]      +
#   [2]     chr1  [12, 30]      -
#   -------
#   seqinfo: 1 sequence from an unspecified genome; no seqlengths

resize(gr, width(gr) - 5, fix="end")
# GRanges object with 2 ranges and 0 metadata columns:
#       seqnames    ranges strand
#          <Rle> <IRanges>  <Rle>
#   [1]     chr1  [16, 30]      +
#   [2]     chr1  [12, 25]      -
#   -------
#   seqinfo: 1 sequence from an unspecified genome; no seqlengths

Maybe not as straightforward as one might hope though...

H.

 

ADD COMMENT

Login before adding your answer.

Traffic: 776 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6