0.16.6 文档
全站目录 · 按任务查找
安装与学习路线
首页安装与环境准备选择合适的学习模块模块一『弦图』部分
1.1 输入表与字段含义1.2 生成与导入比对数据1.3 从骨架逐层添加1.4 方向、曲率与避障1.5 筛选与整理连接1.6 原始文件完整流程1.7 弦图综合展示模块二『共线性图』部分
2.1 复用弦图的数据2.2 只替换坐标系,再逐层添加2.3 跨行连接、避障与比例尺2.4 比较基因邻域2.5 局部、锚定与分段2.6 共线性综合展示模块三『质粒图』部分
3.1 DNA、注释与13个参考序列3.2 从圆圈到多层注释3.3 识别特征、引物与酶切3.4 13个质粒参考案例3.5 质粒综合实战按需查阅:数据与图层
数据与坐标导入和转换数据导入核酸和蛋白比对将蛋白区间转换为基因组坐标绘制注释与处理重叠放置和调整标签添加数据轨道设置配色、图例和主题按序列和链设置参数调整图形预览和保存图形学习地图与函数查阅
使用教程函数文档示例图集常见问题迁移到候选 API术语说明更新日志3.2 从圆圈到多层注释
这一页只关注每次新增的视觉信息。准备时计算输入,绘图仍由独立图层完成。
本页准备
准备代码 · 在本页运行一次
代码
library(ggchord)
feature_palette <- c(
CDS = "#993366", promoter = "#31849B", rep_origin = "#F1E51D",
primer_bind = "#A020F0", misc_feature = "#A6ACB3", protein_bind = "#31849B"
)
library(ggchord)
doc_background <- "#FFFCF5"
identity_palette <- c("#303B71", "#36537D", "#269B82", "#A5D52C", "#ECEB31")
identity_values <- c(0, 0.5, 0.8, 0.9, 1)
identity_breaks <- c(0, 50, 80, 90, 100)
doc_legend_theme <- theme(
legend.title = element_text(size = 13, face = "bold"),
legend.text = element_text(size = 11),
legend.key.width = unit(9, "mm"), legend.key.height = unit(5, "mm"),
legend.spacing.x = unit(9, "mm"), legend.spacing.y = unit(7, "mm"),
legend.margin = margin(l = 4, r = 4, unit = "mm")
)
sequence_guide <- guide_ggchord_legend(nrow = 1, theme = doc_legend_theme)
strand_guide <- guide_ggchord_legend(
nrow = 1, override.aes = list(strand = c("+", "-")), theme = doc_legend_theme
)
identity_guide <- guide_ggchord_colourbar(
position = "left", direction = "vertical",
theme = theme(
legend.key.height = unit(75, "mm"), legend.key.width = unit(5, "mm"),
legend.title = element_text(size = 13, face = "bold"),
legend.text = element_text(size = 11), legend.margin = margin(r = 7, unit = "mm")
)
)
doc_theme <- theme_ggchord_publication(
axis.text = element_text(size = 11),
axis.text.check.overlap = TRUE
) +
theme(
legend.position = "bottom",
legend.title = element_text(size = 13, face = "bold"),
legend.text = element_text(size = 11),
legend.key.width = unit(9, "mm"), legend.key.height = unit(5, "mm"),
legend.spacing.x = unit(9, "mm"), legend.spacing.y = unit(7, "mm"),
legend.box.spacing = unit(6, "mm"),
plot.background = element_rect(fill = doc_background, colour = NA),
panel.background = element_blank(),
plot.title = element_text(face = "bold", size = 18),
plot.subtitle = element_text(size = 10, colour = "#5C625A"),
plot.margin = margin(14, 18, 14, 18)
)
doc_axis <- function(coordinates = "relative") {
scale_seq_position_continuous(
coordinates = coordinates, n.breaks = 3, minor_breaks = NULL,
labels = function(x) format(x, scientific = FALSE, big.mark = ",", trim = TRUE)
)
}
library(dplyr)
data(plasmid_example_pUC19)
plasmid_seq <- plasmid_example_pUC19 |>
select(accver, length)
plasmid_feature_source <- find_common_features(plasmid_example_pUC19)
# Dedicated primer layers already show bindings; avoid duplicate primer annotations.
plasmid_features <- plasmid_feature_source |>
filter(type != "primer_bind") |>
select(accver, start, end, strand, type, anno)
plasmid_primers <- find_primer_bindings(plasmid_example_pUC19, set = "universal")
plasmid_sites <- find_restriction_sites(plasmid_example_pUC19)
display_sites <- filter_restriction_sites(plasmid_sites, enzymes = c("EcoRI", "BamHI", "HindIII"))
primer_names <- primer_catalog(set = "universal")代码
plasmid_position <- position_feature_stack(spacing = 0.085, base_position = position_plasmid())
p_plasmid_backbone <- ggchord(seq_data = plasmid_seq) +
geom_seq(seq_style = "double", colour = "#252525") +
geom_seq_center_label() +
coord_circular(rotation = 90) +
theme_ggchord_plasmid() +
theme(
panel.background = element_blank(),
plot.background = element_rect(fill = doc_background, colour = NA)
)
p_plasmid_features <- p_plasmid_backbone +
geom_feature_plasmid(data = plasmid_features, position = plasmid_position)
p_plasmid_text <- p_plasmid_features +
geom_feature_label_repel(
data = plasmid_features, position = plasmid_position,
external = TRUE, label_fit = "shrink", label_min_size = 2.5
)
p_plasmid_text第一步:双线骨架与中心名称
先检查长度和名称。coord_circular() 仅接受一条序列;双线样式由geom控制。
第二步:加入特征形状
position_feature_stack() 为重叠注释分层,geom_feature_plasmid() 按实际类别选择形状和配色。短特征可能使用紧凑形状,不等于缺失。
第三步:为特征适配标签
箭头层与标签层使用同一Position。允许文字在明确字号下限内缩小,必要时外置;尺寸变化后重新检查。
第四步:引物与选定酶切位点
代码
plasmid_position <- position_feature_stack(spacing = .10, base_position = position_plasmid())
p_plasmid <- ggchord(seq_data = plasmid_seq) +
geom_seq(seq_style = "double") +
geom_feature_plasmid(aes(feature_fill = type), data = plasmid_features, position = plasmid_position) +
geom_feature_label_repel(
data = plasmid_features, position = plasmid_position,
size = 4
) +
geom_primer(data = plasmid_primers, colour = "#A020F0") +
geom_primer_label_repel(data = plasmid_primers, colour = "#A020F0", max_overlaps = 0, size = 3) +
geom_restriction_site(data = display_sites, colour = "#29364B", label_size = 3, leader = "radial") +
geom_seq_center_label() +
scale_feature_fill_manual(values = feature_palette) +
scale_seq_position_continuous() +
coord_circular(rotation = 90) +
theme_ggchord_plasmid() +
theme(
legend.title = element_text(size = 13, face = "bold"),
legend.text = element_text(size = 11),
legend.spacing.x = unit(9, "mm"), legend.spacing.y = unit(7, "mm"),
plot.background = element_rect(fill = doc_background, colour = NA),
panel.background = element_blank()
)
p_plasmid
只展示选定的三个酶切位点,完整搜索表仍保留。完整的识别方法、来源与假设见3.3。然后使用13个参考案例比较注释密度,最后完成pETDuet-1综合图。