boundingIndices: Find indices of features bounding a set of chromosome...

Description Usage Arguments Details Value See Also Examples

View source: R/bounds.R


This function is similar to findOverlaps but it guarantees at least two features will be covered. This is useful in the case of finding features corresponding to a set of genes. Some genes will fall entirely between two features and thus would not return any ranges with findOverlaps. Specifically, this function will find the indices of the features (first and last) bounding the ends of a range/gene (start and stop) such that first <= start < stop <= last. Equality is necessary so that multiple conversions between indices and genomic positions will not expand with each conversion. Ranges/genes that are outside the range of feature positions will be given the indices of the corresponding first or last index rather than 0 or n + 1 so that genes can always be connected to some data.


boundingIndices(starts, stops, positions, all.indices = FALSE)



integer vector of first base position of each query range


integer vector of last base position of each query range


Base positions in which to search


logical, return a list containing full sequence of indices for each query


This function uses some tricks from findIntervals, where is for k queries and n features it is O(k * log(n)) generally and ~O(k) for sorted queries. Therefore will be dramatically faster for sets of query genes that are sorted by start position within each chromosome. The index of the stop position for each gene is found using the left bound from the start of the gene reducing the search space for the stop position somewhat. boundingIndices does not check for NAs or unsorted data in the subject positions. These assumptions are safe for position info coming from a GenoSet or GRanges.


integer matrix of 2 columms for start and stop index of range in data or a list of full sequences of indices for each query (see all.indices argument)

See Also

Other "range summaries": boundingIndicesByChr, rangeSampleMeans


  starts = seq(10,100,10)
  boundingIndices( starts=starts, stops=starts+5, positions = 1:100 )

genoset documentation built on Nov. 1, 2018, 2:55 a.m.