Resize exons in transcript to total width
1
0
Entering edit mode
Jake ▴ 90
@jake-7236
Last seen 19 months ago
United States

Hi,

I am trying to get the last 300 bases of each transcript in genomic ranges. However, when I resize with genomic ranges, it resizes each exon to 300 bases rather than resizing the sum of the exons to be 300 bases.

transcripts <- exonsBy(gencode, by = 'tx', use.names = T)

transcripts_neg <- transcripts[strand(transcripts) == '-']
transcripts_neg <- transcripts_neg[elementNROWS(transcripts_neg) > 0]
transcripts_pos <- transcripts[strand(transcripts) == '+']
transcripts_pos <- transcripts_pos[elementNROWS(transcripts_pos) > 0]

transcripts_neg
transcripts_neg_resized <- resize(transcripts_neg, 300, fix = 'start')

transcripts_pos
transcripts_pos_resized <- resize(transcripts_pos, 300, fix = 'end')

export(transcripts_neg_resized, '~/Desktop/transcripts_neg.bed')
genomicranges genomicfeatures • 904 views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 2.3 years ago
United States

Probably the most intuitive thing is to map the transcript range 1-300 to genomic coordinates and then intersect:

Something like:

threeprime <- IRanges(end=sum(width(gencode)), width=300L)
threeprime_genome <- pmapFromTranscripts(threeprime, gencode)
pintersect(gencode, threeprime_genome)
ADD COMMENT
0
Entering edit mode

Not sure the last step (pintersect) will work. Probably better to address the out-of-limit ranges upfront:

transcripts <- exonsBy(gencode, by="tx", use.names=TRUE)
threeprime <- IRanges(end=sum(width(transcripts)), width=300)
start(threeprime) <- pmax(start(threeprime), 1)
threeprime_genome <- pmapFromTranscripts(threeprime, transcripts)

H.

ADD REPLY
0
Entering edit mode

Agreed that is cleaner.

Could also use restrict for fixing the bounds:

restrict(threeprime, start=1L)
ADD REPLY

Login before adding your answer.

Traffic: 837 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