df2granges: df2granges

View source: R/genomicRegions.R

df2grangesR Documentation

df2granges

Description

Converts a data.frame that defines genomic regions to object of type GRanges.

Usage

df2granges(
  df,
  ids = rownames(df),
  chrom.col = 1L,
  start.col = 2L,
  end.col = 3L,
  strand.col = NULL,
  coord.format = "B1RI",
  assembly = NULL,
  doSort = FALSE,
  adjNumChromNames = FALSE
)

Arguments

df

Table defining genomic regions.

ids

Region names (identifiers) as a character vector, or NULL if no names are present.

chrom.col

Column name or index that lists the chromosome names.

start.col

Column name or index that lists the start positions of the regions.

end.col

Column name or index that lists the end positions of the regions.

strand.col

Column name or index that lists the strands on which the regions are located. Set this to NULL if this region set is not strand-specific.

coord.format

Coordinate format "B1RI" for 1-based right-inclusive (default), "B0RE" for 0-based right-exclusive.

assembly

Genome assembly of interest. See rnb.get.assemblies for the list of supported genomes.

doSort

Should the resulting table be sorted

adjNumChromNames

Should numeric chromosome names be adjusted for by adding the prefix "chr". Additionally chrMT becomes chrM. useful for converting GRC identifiers to NCBI identifiers

Value

GRanges object encapsulating of regions included in df. As GRanges, the coordinates will be 1-based right-inclusive. Columns other that the ones listed as parameters in this function are included as elementMetadata.

Examples

df <- data.frame(chrom=c(rep("chr5", 7), rep("chr21", 3)), start=1:10, end=seq(20, by=10, length.out=10), strand=rep(c("+","+", "-", "*"), length.out=10), letter=letters[1:10], score=rnorm(10))
df
df2granges(df, assembly="GRCh38_chr")

demuellae/muRtools documentation built on Nov. 6, 2024, 9:44 a.m.