build.bed: Bed generator

View source: R/build.bed.R

build.bedR Documentation

Bed generator

Description

Function that helps the building of a bed file providing the columns. It enables also the specification of the track line for software such as IGV in order to pre-define colors, track name, etc.

Usage

build.bed(
  chr,
  start,
  end,
  name = NULL,
  score = 0,
  strand = ".",
  thickStart = NULL,
  thickEnd = NULL,
  itemRgb = NULL,
  blockCount = NULL,
  blockSizes = NULL,
  blockStarts = NULL,
  track.name = NULL,
  display.mode = NULL,
  itemRgb.ON = T,
  useScore = F,
  colorByStrand = NULL,
  track.base.color = NULL,
  sort = T,
  bed.file.name = NULL,
  export.track.line = TRUE,
  return.data.frame = F,
  force.generation = F
)

Arguments

chr

String vector containing the name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671).

start

Numeric vector indicating the starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0.

end

Numeric vector indicating the ending position of the feature in the chromosome or scaffold.

name

String vector defining the name of the BED line. This label is displayed to the left of the BED line in the Genome Browser window when the track is open to full display mode or directly to the left of the item in pack mode. If set as NULL (default) and the column is required, the names will correspond to the mid-point of the region.

score

A single value or a numeric vector with a score between 0 and 1000. If the track line useScore attribute is set as TRUE for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). By default 0.

strand

A single character or a string vector defining the strand: either "." (=no strand) or "+" or "-". By default ".".

thickStart

A numeric vector indicating the starting position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part (default value, thickStart = NULL) it will be used the start value.

thickEnd

A numeric vector indicating the ending position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part (default value, thickStart = NULL) it will be used the end value.

itemRgb

A single value or a string vector containing the colors for each feature. It can be expressed as an RGB value of the form R,G,B (e.g. "255,0,0") or as any other R-supported color name (it will be converted automatically to RGB version). By default NULL. If the track line itemRgb.ON attribute is set as TRUE, this color value will determine the display color of the data contained in this BED line. NOTE: It is recommended that a simple color scheme (eight colors or less) be used with this attribute to avoid overwhelming the color resources of the Genome Browser and your Internet browser.

blockCount

A single number or a numeric vector indicating the number of blocks (exons) in the BED line. By default NULL.

blockSizes

A vector containing a comma-separated list of the block sizes. The number of items in this list should correspond to blockCount. By default NULL.

blockStarts

A vector containing a comma-separated list of block starts. All of the blockStart positions should be calculated relative to start. The number of items in this list should correspond to blockCount. By default NULL.

track.name

A string defining the track label that will be displayed to the left of the track in the Genome Browser window, and also the label of the track control at the bottom of the screen. The name can consist of up to 15 characters. It is recommended that the track_label be restricted to alpha-numeric characters and spaces to avoid potential parsing problems. By default NULL.

display.mode

A string that defines the initial display mode of the annotation track. Values for display.mode include: "hide", "dense", "full", "pack", "squish". By default NULL.

itemRgb.ON

Logic value to define whether this attribute should be set to "On", the Genome Browser will use the RGB value shown in the itemRgb field in each data line of the associated BED track to determine the display color of the data on that line. If the itemRgb values are not provided, this parameter will be ignored. By default TRUE.

useScore

Logic value to define if the score field in each of the track's data lines should be used to determine the level of shading in which the data is displayed. By default FALSE.

colorByStrand

A vector composed by two strings for two colors, either in RGB comma separated format (eg. "0,250,30") or any R-supported color string (they will be converted automatically to RGB format). The order of color sets is c("strand +", "strand -"). Parameter ignored when itemRgb is active/provided. By default NULL.

track.base.color

A single string defining the main color for the annotation track. The track color consists of three comma-separated RGB values from 0-255 (eg. "0,250,30") or any R-supported color string (it will be converted automatically to RGB format). Parameter ignored when itemRgb or colorByStrand are active/provided. By default NULL.

sort

Logic value to define whether to sort the bed using the function sort.bed. By default TRUE.

bed.file.name

If a string with a full path to a bed_file is provided, the function will export the bed as a txt file. By default NULL.

export.track.line

Logic value to define if the track line should be exported. When bed.file.name = NULL this parameter is ignored. By default TRUE.

return.data.frame

Logic value to define if the to return the data.frame corresponding to the bed (it will show the columns names). By default FALSE.

force.generation

Force the generation of bed even when certain errors occur (eg. score > 1000, start > end). By default FALSE.

Value

If required the function can export a bed file with or without the track line, return a data.frame (with column names) corresponding to the bed generated, or both. The bed file could be automatically sorted settin the parameter sort = TRUE.

References


sebastian-gregoricchio/Rseb documentation built on May 15, 2024, 5:45 a.m.