uniqueGRanges: Unique genomic ranges from a list of GRanges objects

uniqueGRangesR Documentation

Unique genomic ranges from a list of GRanges objects

Description

Build an unique GRanges object from a list of Granges objects.

Usage

uniqueGRanges(
  ListOfGranges,
  ncolns = NULL,
  columns = NULL,
  chromosomes = NULL,
  maxgap = -1L,
  minoverlap = 1L,
  missing = 0,
  type = c("any", "start", "end", "within", "equal"),
  select = c("all", "first", "last", "arbitrary"),
  ignore.strand = FALSE,
  num.cores = 1L,
  tasks = 0L,
  verbose = TRUE
)

Arguments

ListOfGranges

Objects to combine. A list of GRanges-class object or a GRangesList-class object.

ncolns

integer. Number of columns to use from the meta-column of each GRanges object. Default value: NULL. If NULL, all the columns (from column 1 to ncolns) from each GRanges will be present in the uniqueGRanges output. If ncolns = NULL and columns != NULL, then the function will set ncolns = length(columns).

columns

integer number(s) corresponding to the specific column(s) to use from the meta-column of each GRanges. Default value: NULL. if provided, the metacolumn from the uniqueGRanges output will contain the specified columns.

chromosomes

Chromosomes used Default value: NULL

maxgap, minoverlap, ignore.strand, select, type

The same as in findOverlaps-methods.

missing

A numerical value (default 0) or NA to write in ranges with missing values. For example, suppose that we want to build a uniqueGRanges object from the GRanges objects X and Y. If a given range k from the GRanges object X with metacolumn value x is missing in the GRanges object Y, then the metacolumn of range k from uniqueGRanges(list(X,Y)) object will be the row vector (x,0) or (x,NA) if missing = NA.

num.cores, tasks

Parameters for parallel computation using package BiocParallel-package: the number of cores to use, i.e. at most how many child processes will be run simultaneously (see bplapply and the number of tasks per job (only for Linux OS).

verbose

if TRUE, prints the function log to stdout

Details

The metadata of each one of these GRanges must have one or more columns to yield a unique GRanges object with metadata columns from the original GRanges objects. Otherwise, a unique GRanges object will be created without metadata columns. Additionally, all metadata must be the same class, e.g. all numeric or all characters, or all factor

Value

a GRanges object

Author(s)

Robersy Sanchez (https://genomaths.com).

Examples

## 'GRanges' object construction
dfChr1 <- data.frame(chr = 'chr1', start = 11:15, end = 11:15,
                     strand = c('+','-','+','*','.'), score = 1:5)
dfChr2 <- data.frame(chr = 'chr1', start = 11:15, end = 11:15,
                     strand = c('+','-','+','*','.'), score = 1:5)
dfChr3 <- data.frame(chr = 'chr1', start = 11:15, end = 11:15,
                     strand = c('+','-','+','*','+'), score = 1:5)

gr1 <- makeGRangesFromDataFrame(dfChr1, keep.extra.columns = TRUE)
gr2 <- makeGRangesFromDataFrame(dfChr2, keep.extra.columns = TRUE)
gr3 <- makeGRangesFromDataFrame(dfChr3, keep.extra.columns = TRUE)

## A 'GRangesList' object:
grList <- GRangesList('gr1' = gr1, 'gr2' = gr2, 'gr3' = gr3)
grList

## The default setting does not ignore strands value (ignore.strand = FALSE).
## In object 'gr1' and 'gr2', the strand at the 5th range is unknown.
## However, in object 'gr3' the 5th range has "+" strand. The defaul setting
## preserve this information. Two ranges with start = 15 are yielded: 1) the
## first range the first range with strand = '*' carries the value 5 in the
## columns derived from 'gr1' and 'gr2', and 0 (missing = 0) in the column
## derived from 'gr3'.
uniqueGRanges(grList)

## A new GRanges object is included with values in different strands
dfChr4 <- data.frame(chr = 'chr1', start = 11:15, end = 11:15,
                     strand = c('-','-','+','*','-'), score = 1:5)
gr4 <- makeGRangesFromDataFrame(dfChr4, keep.extra.columns = TRUE)
grList <- GRangesList('gr1' = gr1, 'gr2' = gr2, 'gr3' = gr3, gr4 = gr4)
grList

## The default setting preserve the information adding new ranges.
uniqueGRanges(grList)

## The setting: 'ignore.strand = TRUE' ignores the strand information
## and only the information on the base position is preserved.
uniqueGRanges(grList, ignore.strand = TRUE)


genomaths/MethylIT documentation built on Feb. 3, 2024, 1:24 a.m.