Learn R Programming

hiAnnotator (version 1.6.2)

get2NearestFeature: Get two nearest upstream and downstream annotation boundary for a position range.

Description

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.

Usage

get2NearestFeature(sites.rd, features.rd, colnam = NULL, side = "either",
  feature.colnam = NULL, relativeTo = "subject")

Arguments

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 getNearestFeature for more information.

Value

  • a GRanges object with new annotation columns appended at the end of sites.rd.

See Also

getNearestFeature, makeGRanges, getFeatureCounts, getSitesInFeature.

Examples

Run this code
# 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
nearestGenes <- get2NearestFeature(alldata.rd,genes.rd,"NearestGene",
side="5p")
nearestGenes
nearestGenes <- get2NearestFeature(alldata.rd,genes.rd,"NearestGene",
side="3p")
nearestGenes

Run the code above in your browser using DataLab