panel.geneplot | R Documentation |
This panel function allows to draw genes with start and end coordinates as main input. Optional vectors for 'gene_name' or 'gene_strand' must have same length as 'x', 'y'. This function supports paneling and grouping (e.g. by gene functional category) just as regular panel functions.
panel.geneplot(
x,
y,
groups = NULL,
subscripts = NULL,
gene_name = NULL,
gene_strand = NULL,
draw_labels = TRUE,
arrows = TRUE,
origin = 0,
height = 1,
offset = 0,
tip = NULL,
col = NULL,
col_labels = grey(0.3),
rot_labels = 35,
dist_labels = 1.5,
group.number = NULL,
...
)
x, y |
(numeric) start and end positions e.g. in bp, respectively |
groups |
grouping variable passed down from xyplot (does not need to be specified) |
subscripts |
subscripts passed down from xyplot (does not need to be specified) |
gene_name |
(character) optional names of the genes to be plotted. |
gene_strand |
(character) optional strand information for each gene ('+' or '-'). |
draw_labels |
(logical) if gene name labels are drawn |
arrows |
(logical) draw arrow like boxes (default) or plain or boxes |
origin |
(numeric) the horizontal line that serves as origin for drawing genes |
height |
(numeric) height of the boxes/arrows |
offset |
(numeric) distance of boxes/arrows from origin (default: 0) |
tip |
(numeric) pointedness of the arrow head (in native X units. Defaults to a 30th of x scale) |
col |
(character) color (vector) to be used for boxes/arrows. The default, NULL, uses colors supplied by the top level function. |
col_labels |
(character) color used for text labels and lines |
rot_labels |
(numeric) degree of rotation for text labels (0 for no rotation at all) |
dist_labels |
(numeric) relative distance of labels to origin, defaults to 1.5 times box height |
group.number |
internal parameter only used when function is called as panel.groups argument from within panel.superpose. Does not need to be specified manually. |
... |
other arguments passed to the function |
library(lattice)
# table with dummdy genetic loci
genes <- data.frame(
gene_name = c("abc", "def", "ghi", "jkl"),
gene_strand = c("+", "+", "+", "-"),
gene_start = c(123, 178, 245, 310),
gene_end = c(167, 233, 297, 354)
)
# plot genes on a linear map
xyplot(gene_end ~ gene_start, genes,
groups = gene_strand,
scales = list(y = list(draw = FALSE)),
xlim = c(80, 380), ylim = c(-3,2),
xlab = "", ylab = "",
gene_strand = genes[["gene_strand"]],
gene_name = genes[["gene_name"]],
panel = function(x, y, ...) {
panel.grid(h = -1, v = -1, col = grey(0.9))
panel.geneplot(x, y, arrows = TRUE, ...)
}
)
# same example with customized arrows
xyplot(gene_end ~ gene_start, genes,
groups = gene_strand,
scales = list(y = list(draw = FALSE)),
xlim = c(80, 380), ylim = c(-3,2),
xlab = "", ylab = "",
gene_strand = genes[["gene_strand"]],
gene_name = genes[["gene_name"]],
panel = function(x, y, ...) {
panel.grid(h = -1, v = -1, col = grey(0.9))
panel.geneplot(x, y, arrows = TRUE, offset = 0.5,
height = 0.6, rot_labels = 0, tip = 3, col_labels = 1, ...)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.