跳到正文
0.16.6 文档

本页完整说明已译为现代汉语;函数、参数、代码和原始数据标识保留原样。 使用教程

全站目录 · 按任务查找

用于 CDS、tRNA、rRNA、重复序列、CRISPR、启动子或自定义注释的通用图层。支持有方向的箭头、矩形、凹口人字形和棒棒糖形,均沿序列的实际局部曲线生成。注释填色与几何形状使用独立的角色标度。

用法

代码
geom_feature(
  mapping = NULL,
  data = NULL,
  shape = "arrow",
  width = NULL,
  arrow_head_length = 0.04,
  arrow_head_width = 1,
  arrow_head_style = c("shouldered", "flush", "triangle"),
  short_feature = c("auto", "wedge", "block"),
  segment_boundaries = TRUE,
  boundary_colour = "#666666",
  boundary_linewidth = 0.25,
  boundary_linetype = "22",
  position = "identity",
  show.legend = TRUE,
  inherit.aes = FALSE,
  ...
)

参数

mapping

可选映射。accver、start、end、strand 等角色 aesthetic 可重命名输入列;普通视觉映射在生成几何后计算。

data

含 accver、start、end、strand 的数据框,可选 type、category、label。因子列 start/end 使用数值标签而非内部级别编码;坐标必须为有限数值。可提供 display_priority 或逻辑列 prioritized_display。也可用 directionality 或 direction 代替 strand,取值为 "forward"、"reverse"、"bidirectional"、"none"。

shape

固定注释形状。显式 shape 优先于 aes(feature_shape = ...):支持 "arrow"、"compact_arrow"、"promoter_arrow"、"primer_arrow"、"marker"、"block"、"capped_line"、"primer_arc"、"chevron"、"lollipop",默认 "arrow"。使用 aes(feature_shape = type) 与 scale_feature_shape_manual() 将类别映射为形状。

width

可选数值、向量或列表,控制共享注释几何引擎的宽度。圆图中与标签组合时,基础宽度会在限定范围内响应最终字号。

arrow_head_length, arrow_head_width

序列局部坐标中的箭头尺寸,与 geom_gene() 共用。arrow_head_width 大于 1 时形成凸出的块状箭头。

arrow_head_style

箭头构造方式:"shouldered" 保留凸出箭头,"flush" 使箭头与主体齐平,"triangle" 绘制完整三角楔形。

short_feature

注释太短、容不下指定箭头时的处理:自动压缩为方向符号,或改用楔形、矩形。

segment_boundaries

绘制分段注释携带的内部标记。连续源分段的连接处使用点线;分段级非实线 line_style 可覆盖该样式,cleavage_arrows 坐标可添加或合并生物学切割标记。这些标记不会产生额外箭头。

boundary_colour, boundary_linewidth, boundary_linetype

内部分段连接处的外观。

position

注释位置,使用 "identity"、"strand"、"plasmid"、position_strand()、position_plasmid() 或 position_feature_stack()。

show.legend, inherit.aes

标准 ggplot2 图层参数。

...

其他固定多边形 aesthetic。

返回值

一个 ggplot2 图层。

示例

代码
library(dplyr)
data(plasmid_example_pUC19)
seqs <- plasmid_example_pUC19 |>
  select(accver, length)
feature_source <- find_common_features(plasmid_example_pUC19)
features <- feature_source |>
  select(accver, start, end, strand, type, anno)
# ASCII display copy for the default PDF help-example device.
features <- features |>
  mutate(anno = gsub("\u03b1", "alpha", anno, fixed = TRUE))
ggchord(seq_data = seqs) +
  geom_seq() +
  geom_feature(
    data = features,
    shape = "block"
  ) +
  coord_circular()