Using Precede in GenomicRanges
1
0
Entering edit mode
Tom Oates ▴ 60
@tom-oates-5703
Last seen 7.4 years ago
Dear All I have GRanges objects of transcript information (subject) & for regions of interest (query). Top lines of (subject): seqnames ranges strand | tx_id tx_name <rle> <iranges> <rle> | <integer> <character> [1] 1 [5473, 16844] + | 1 ENSRNOT00000044270 [2] 1 [5526, 16968] + | 2 ENSRNOT00000049921 [3] 1 [5526, 16968] + | 3 ENSRNOT00000051735 [4] 1 [5598, 13520] + | 4 ENSRNOT00000034630 [5] 1 [8268, 16850] + | 5 ENSRNOT00000044505 [6] 1 [8316, 17577] + | 6 ENSRNOT00000042693 [7] 1 [8884, 16850] + | 7 ENSRNOT00000044187 [8] 1 [8956, 9955] + | 8 ENSRNOT00000041082 [9] 1 [9055, 17351] + | 9 ENSRNOT00000050254 Top lines of (query): seqnames ranges strand <rle> <iranges> <rle> [1] 10 [ 37958164, 37958165] + | [2] 7 [ 46598224, 46598225] - | [3] 1 [ 9627018, 9627019] - | [4] 9 [ 10158183, 10158184] + | [5] 2 [185436985, 185436986] + | [6] 8 [ 93638247, 93638248] - | [7] 7 [ 68559015, 68559016] - | [8] 12 [ 10978744, 10978745] + | [9] 17 [ 33460790, 33460791] - | and am using the precede command to find the preceeding transcripts to my regions of interest output<-precede(query, subject, ignore.strand=FALSE) I am aware that the object called "output" is of class integer with the row names of "subject" which represent the preceding hits for "query", but I have so far been unable to use these row names to end up with a granges object with the name of the preceding transcripts as metadata in a granges object containing the ranges from "query" i.e something that would look like: [1] 10 [ 37958164, 37958165] + |ENSRNOT00000044270 [[alternative HTML version deleted]]
• 1.4k views
ADD COMMENT
0
Entering edit mode
@valerie-obenchain-4275
Last seen 2.9 years ago
United States
Hello, query <- GRanges("chr1", IRanges(c(5, 20), width=1)) subject <- GRanges("chr1", IRanges(c(30, 10, 1), width=1, names=c("gene1", "gene2"))) out <- precede(query, subject) > out [1] 3 1 You can add metdata columns to a GRanges with 'mcols<-'. This assignment will replace any existing metadata columns with 'subjectNames'. mcols(query) <- DataFrame(subjectNames=names(subject)[out]) If you want to keep the existing metadata columns, use append() on the right side: mcols(query) <- append(mcols(query), DataFrame(subjectNames=names(subject)[out])) Valerie On 04/19/2013 07:27 AM, Tom Oates wrote: > Dear All > I have GRanges objects of transcript information (subject) & for regions of > interest (query). > Top lines of (subject): > seqnames ranges strand | tx_id tx_name > <rle> <iranges> <rle> | <integer> > <character> > [1] 1 [5473, 16844] + | 1 > ENSRNOT00000044270 > [2] 1 [5526, 16968] + | 2 > ENSRNOT00000049921 > [3] 1 [5526, 16968] + | 3 > ENSRNOT00000051735 > [4] 1 [5598, 13520] + | 4 > ENSRNOT00000034630 > [5] 1 [8268, 16850] + | 5 > ENSRNOT00000044505 > [6] 1 [8316, 17577] + | 6 > ENSRNOT00000042693 > [7] 1 [8884, 16850] + | 7 > ENSRNOT00000044187 > [8] 1 [8956, 9955] + | 8 > ENSRNOT00000041082 > [9] 1 [9055, 17351] + | 9 > ENSRNOT00000050254 > > Top lines of (query): > seqnames ranges strand > <rle> <iranges> <rle> > [1] 10 [ 37958164, 37958165] + | > [2] 7 [ 46598224, 46598225] - | > [3] 1 [ 9627018, 9627019] - | > [4] 9 [ 10158183, 10158184] + | > [5] 2 [185436985, 185436986] + | > [6] 8 [ 93638247, 93638248] - | > [7] 7 [ 68559015, 68559016] - | > [8] 12 [ 10978744, 10978745] + | > [9] 17 [ 33460790, 33460791] - | > > and am using the precede command to find the preceeding transcripts to my > regions of interest > > output<-precede(query, subject, ignore.strand=FALSE) > > I am aware that the object called "output" is of class integer with the row > names of "subject" which represent the preceding hits for "query", but I > have so far been unable to use these row names to end up with a granges > object with the name of the preceding transcripts as metadata in a granges > object containing the ranges from "query" i.e something that would look > like: > [1] 10 [ 37958164, 37958165] + |ENSRNOT00000044270 > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD COMMENT
0
Entering edit mode
On 04/19/2013 08:45 AM, Valerie Obenchain wrote: > Hello, > > query <- GRanges("chr1", IRanges(c(5, 20), width=1)) > subject <- GRanges("chr1", IRanges(c(30, 10, 1), width=1, > names=c("gene1", "gene2"))) > out <- precede(query, subject) > > out > [1] 3 1 > > You can add metdata columns to a GRanges with 'mcols<-'. This assignment will > replace any existing metadata columns with 'subjectNames'. > mcols(query) <- DataFrame(subjectNames=names(subject)[out]) > > If you want to keep the existing metadata columns, use append() on the right side: > mcols(query) <- append(mcols(query), > DataFrame(subjectNames=names(subject)[out])) or just query$subjectNames = names(subject)[out] > > > > Valerie > > > On 04/19/2013 07:27 AM, Tom Oates wrote: >> Dear All >> I have GRanges objects of transcript information (subject) & for regions of >> interest (query). >> Top lines of (subject): >> seqnames ranges strand | tx_id tx_name >> <rle> <iranges> <rle> | <integer> >> <character> >> [1] 1 [5473, 16844] + | 1 >> ENSRNOT00000044270 >> [2] 1 [5526, 16968] + | 2 >> ENSRNOT00000049921 >> [3] 1 [5526, 16968] + | 3 >> ENSRNOT00000051735 >> [4] 1 [5598, 13520] + | 4 >> ENSRNOT00000034630 >> [5] 1 [8268, 16850] + | 5 >> ENSRNOT00000044505 >> [6] 1 [8316, 17577] + | 6 >> ENSRNOT00000042693 >> [7] 1 [8884, 16850] + | 7 >> ENSRNOT00000044187 >> [8] 1 [8956, 9955] + | 8 >> ENSRNOT00000041082 >> [9] 1 [9055, 17351] + | 9 >> ENSRNOT00000050254 >> >> Top lines of (query): >> seqnames ranges strand >> <rle> <iranges> <rle> >> [1] 10 [ 37958164, 37958165] + | >> [2] 7 [ 46598224, 46598225] - | >> [3] 1 [ 9627018, 9627019] - | >> [4] 9 [ 10158183, 10158184] + | >> [5] 2 [185436985, 185436986] + | >> [6] 8 [ 93638247, 93638248] - | >> [7] 7 [ 68559015, 68559016] - | >> [8] 12 [ 10978744, 10978745] + | >> [9] 17 [ 33460790, 33460791] - | >> >> and am using the precede command to find the preceeding transcripts to my >> regions of interest >> >> output<-precede(query, subject, ignore.strand=FALSE) >> >> I am aware that the object called "output" is of class integer with the row >> names of "subject" which represent the preceding hits for "query", but I >> have so far been unable to use these row names to end up with a granges >> object with the name of the preceding transcripts as metadata in a granges >> object containing the ranges from "query" i.e something that would look >> like: >> [1] 10 [ 37958164, 37958165] + |ENSRNOT00000044270 >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at r-project.org >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: >> http://news.gmane.org/gmane.science.biology.informatics.conductor >> > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793
ADD REPLY

Login before adding your answer.

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