Description Usage Arguments Value Note See Also Examples
Given a query object, the function retrieves the two nearest feature upstream and downstream along with their properties from a subject and then appends them as new columns within the query object. When used in genomic context, the function can be used to retrieve two nearest gene upstream and downstream of the genomic position of interest.
1 2 | get2NearestFeature(sites.rd, features.rd, colnam = NULL,
side = "either", feature.colnam = NULL, relativeTo = "subject")
|
sites.rd |
GRanges object to be used as the query. |
features.rd |
GRanges object to be used as the subject or the annotation table. |
colnam |
column name to be added to sites.rd for the newly calculated annotation...serves a core! |
side |
boundary of annotation to use to calculate the nearest distance. Options are '5p','3p', 'either'(default), or 'midpoint'. |
feature.colnam |
column name from features.rd to be used for retrieving the nearest feature name. By default this is NULL assuming that features.rd has a column that includes the word 'name' somewhere in it. |
relativeTo |
calculate distance relative to query or subject.
Default is 'subject'. See documentation of |
a GRanges object with new annotation columns appended at the end of sites.rd.
When side='midpoint', the distance to nearest feature is calculated by (start+stop)/2.
For cases where a position is at the edge and there are no feature up/down stream since it would fall off the chromosome, the function simply returns 'NA'.
If there are multiple locations where a query falls into, the function arbitrarily chooses one to serve as the nearest feature, then reports 2 upstream & downstream feature. That may occasionally yield features which are the same upstream and downstream, which is commonly encountered when studying spliced genes or phenomena related to it.
If strand information doesn't exist, then everything is defaults to '+' orientation (5' -> 3')
If parallel=TRUE, then be sure to have a parallel backend registered
before running the function. One can use any of the following libraries
compatible with foreach
: doMC, doSMP, doSNOW, doMPI,
doParallel. For example: library(doMC); registerDoMC(2)
getNearestFeature
, makeGRanges
,
getFeatureCounts
, getSitesInFeature
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # Convert a dataframe to GRanges object
data(sites)
alldata.rd <- makeGRanges(sites, soloStart = TRUE)
data(genes)
genes.rd <- makeGRanges(genes)
nearestGenes <- get2NearestFeature(alldata.rd, genes.rd, "NearestGene")
nearestGenes
## Not run:
nearestGenes <- get2NearestFeature(alldata.rd, genes.rd, "NearestGene",
side = "5p")
nearestGenes
nearestGenes <- get2NearestFeature(alldata.rd, genes.rd, "NearestGene",
side = "3p")
nearestGenes
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.