[BioC] Using Precede in GenomicRanges
Valerie Obenchain
vobencha at fhcrc.org
Fri Apr 19 17:45:28 CEST 2013
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
>
More information about the Bioconductor
mailing list