dna_seg class and methods
dna_seg.Rd
dna_seg
objects are collections of genes or other elements along a genome,
to be represented on a map. These functions are class functions to create,
convert, and test dna_seg
objects.
Usage
dna_seg(x, ...)
as.dna_seg(
df,
col = "grey20",
fill = "grey80",
lty = 1,
lwd = 1,
pch = 8,
cex = 1,
gene_type = "arrows",
region_plot = "NA",
ordered = TRUE
)
is.dna_seg(dna_seg)
Arguments
- x
An object to be coerced. Can be a
data.frame
,data.table
, orlist
object. See details for necessary columns.- ...
Arguments to pass to dna_seg, see arguments below.
- df
Same as
x
.- col
A character vector of colors, of either length one or the same length as
x
. Determines the outline of features, or their overall color for shapes (see gene_types) that have no fill color (e.g. text, points).- fill
Same as
col
, but determines the fill color of features.- lty
A vector of either length 1 or the same length as
x
. Determines the line type (see par) of the features.- lwd
A numeric vector of either length 1 or the same length as
x
. Determines the line width (see par) of the features.- pch
A vector of either length 1 or the same length as
x
. Determines the shape (see points) of the features when they are represented by points.- cex
A numeric vector of either length 1 or same the length as
x
. Determines the size multiplier of features when they are represented by text or points.- gene_type
A character vector of either length 1 or same the length as
x
. Determines the gene type (i.e. shape) of the features. See gene_types.- region_plot
A character vector of either length 1 or the same length as
x
. Determines if features are going to be plotted when going for regional plotting. See plot_gene_map for more details.- ordered
Logical. If
TRUE
, orders thedna_seg
on thestart
andend
columns.- dna_seg
An object to test.
Details
A dna_seg
object is a data.table
that must start with the columns name
,
start
, end
, and strand
. The arguments listed above add more
columns, but only if those were not already present in the data provided by
x
. Any number of additional columns can be added to dna_seg
objects, to
act as metadata or as ways to group or identify features.
dna_seg
and as.dna_seg
can both be used to create dna_seg
objects from
list, data.frame
, or data.table
objects. Alternatively,
read_dna_seg_from_file can be used to create them from a file.
These objects inherit from data.table
, and
can therefore be manipulated using data.table
syntax.
is.dna_seg
returns TRUE
if the object tested is a dna_seg
object.
Examples
## Generate data
names1 <- c("feat1", "feat2", "feat3")
starts1 <- c(2, 1000, 1050)
ends1 <- c(600, 800, 1345)
strands1 <- c("-", -1, 1)
cols1 <- c("blue", "grey", "red")
## Create data.frame
df1 <- data.frame(name = names1, start = starts1, end = ends1,
strand = strands1, col = cols1)
## Create dna_seg
dna_seg1 <- dna_seg(df1)
dna_seg1
#> name start end strand col gene_type region_plot fill lty lwd
#> <char> <num> <num> <num> <char> <char> <char> <char> <num> <num>
#> 1: feat1 2 600 -1 blue arrows NA grey80 1 1
#> 2: feat2 1000 800 -1 grey arrows NA grey80 1 1
#> 3: feat3 1050 1345 1 red arrows NA grey80 1 1
#> pch cex
#> <num> <num>
#> 1: 8 1
#> 2: 8 1
#> 3: 8 1
as.dna_seg(df1)
#> name start end strand col gene_type region_plot fill lty lwd
#> <char> <num> <num> <num> <char> <char> <char> <char> <num> <num>
#> 1: feat1 2 600 -1 blue arrows NA grey80 1 1
#> 2: feat2 1000 800 -1 grey arrows NA grey80 1 1
#> 3: feat3 1050 1345 1 red arrows NA grey80 1 1
#> pch cex
#> <num> <num>
#> 1: 8 1
#> 2: 8 1
#> 3: 8 1
## Test dna_seg
is.dna_seg(dna_seg1)
#> [1] TRUE