Skip to contents

This function parses a file containing offset values for plotting in plot_gene_map. The offset values determine the amount of space before each subsegment of each plotted dna_seg.

Usage

read_offsets_file(offsets)

Arguments

offsets

A character string containing a file path, or a file connection. See details for file format.

Value

A list of offset values that can be passed directly to the offsets argument of plot_gene_map. Each element of the list is a numeric vector that corresponds to the offset values of one dna_seg.

Details

The file provided by offsets must contain 1 or more offset values for each dna_seg. Each line must contain offset values for 1 dna_seg, in plotting order, with their subsegments separated by spaces. For each dna_seg, if a single value is provided, then that value will become the offset for its first subsegment. If more values are provided for a dna_seg, then there must be as many values as there are subsegments for that dna_seg.

Author

Mike Puijk

Examples

## Parse offset values for 2 dna_segs from a file
offsets_file <- system.file('extdata/offsets.txt', package = 'genoPlotR')

## When this file is parsed:
## dna_seg 1: its 2 subsegments will be offset by 150 and 1300, respectively
## dna_seg 2: only its first subsegment  will be offset by 300

## Example of an offsets file:
cat(readLines(offsets_file), sep = "\n")
#> 150 1300
#> 300

## Parse offsets file
read_offsets_file(offsets_file)
#> [[1]]
#> [1]  150 1300
#> 
#> [[2]]
#> [1] 300
#> 

## This is equivalent to:
read_offsets("150 1300,300")
#> [[1]]
#> [1]  150 1300
#> 
#> [[2]]
#> [1] 300
#>