addMetricAndArrangeGRanges: addMetricAndArrangeGRanges()

View source: R/addMetricAndArrangeGRanges.R

addMetricAndArrangeGRangesR Documentation

addMetricAndArrangeGRanges()

Description

Perform an inner join between a GRanges object and a data.frame. Sort the resulting GRanges based on a metric column.

Usage

addMetricAndArrangeGRanges(
  gr,
  order,
  gr_key = "name",
  order_key = "name",
  order_value = "exp",
  shuffle_tie = TRUE
)

Arguments

gr

a GRanges object.

order

a data.frame with at least two columns: keys and values.

gr_key

name of the gr metadata column containing unique names for each genomic region in gr. Usually gene names/id or peak id.

order_key

name of the order column that will be used as key for the inner join.

order_value

name of the order column that contain value used for sorting.

shuffle_tie

a boolean Value (TRUE / FALSE). When TRUE, shuffle the GRanges before sorting, mixing the ties.

Details

This utility function allow the addition of a metric column to genomic regions of interest. One of its common use case is to add gene expression values on a set of transcription start sites. The resulting GRanges object will only contain regions presents in both gr and order.

Value

a GRanges sorted in descending order.

Examples

data("stackepi_gr")
ramdomOrder <- data.frame(gene_id = stackepi_gr$gene_id,
   value = rnorm(length(stackepi_gr)))
addMetricAndArrangeGRanges(stackepi_gr,
   ramdomOrder, gr_key = "gene_id",
   order_key = "gene_id", order_value = "value")



GenEpi-GenPhySE/epistack documentation built on July 27, 2023, 1:09 a.m.