% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/GetNearbyGenes.R
\name{calcDistNearestTSS}
\alias{calcDistNearestTSS}
\title{Calculate distance from region to nearest TSS}
\usage{
calcDistNearestTSS(links, TRange, tssAnnot)
}
\arguments{
\item{links}{Links to calculate the distance}

\item{TRange}{Genomic coordinates for Tartget region}

\item{tssAnnot}{TSS annotation}
}
\description{
Idea 
For a given region R linked to X genes G
merge R with nearest TSS for G (multiple)
this will increse nb of lines 
i.e R1 - G1 - TSS1 - DIST1
   R1 - G1 - TSS2 - DIST2
   To vectorize the code:
make a granges from left and onde from right 
and find distance
collapse the results keeping min distance for equals values
}
\examples{
\dontrun{
 data <- ELMER:::getdata("elmer.data.example")
  NearbyGenes <- GetNearGenes(data = data, 
                              probes = c("cg15924102", "cg24741609"),  
                              numFlankingGenes = 20)
  NearbyGenes <- ELMER:::calcDistNearestTSS(
       links = NearbyGenes,
       tssAnnot =  getTSS(genome = "hg38"),
       TRange = rowRanges(getMet(data))
       )
}
}
\author{
Tiago C. Silva
}
