BioF3 FigCode · SCI 绘图代码集
Peak 注释(Peak Annotation Pie)
分类:基因组 | 依赖包:ggplot2
解决的生物学问题
实验富集的 peak 主要分布在基因组的哪些功能区域?是否偏好启动子区?
应用场景
- ChIP-seq peak 基因组分布概览
- ATAC-seq 开放染色质区域注释
- 不同组蛋白修饰的分布对比
- TF 结合位点区域偏好分析
输入数据格式
narrowPeak 文件 + TxDb 注释
关键参数
- tssRegion TSS 上下游范围(c(-3000, 3000))
- TxDb 基因组注释版本
- level 注释层级(gene / transcript)
- 输出图形类型(pie / bar)
快速开始
1. 直接在线运行
打开 FigCode 在线绘图,点击本工具卡片的"在线绘图"按钮即可用内置示例数据出图,零环境配置。
2. 本地复现
下载脚本和示例数据,本地 RStudio 运行:
# 下载
curl -O https://<your-site>/figcode/scripts/peak-anno.R
curl -O https://<your-site>/figcode/data/peak-anno.csv
3. 安装依赖
# CRAN 包
install.packages(c("ggplot2"))
# Bioconductor 包(如需)
# BiocManager::install(c())
完整代码
library(ggplot2)
# --- Demo: simulate peak annotation proportions ---
anno_df <- data.frame(
Feature = c("Promoter (<=1kb)", "Promoter (1-2kb)", "Promoter (2-3kb)",
"5' UTR", "3' UTR", "1st Exon", "Other Exon",
"1st Intron", "Other Intron", "Distal Intergenic"),
Percentage = c(28, 8, 5, 2, 4, 3, 5, 12, 18, 15)
)
anno_df$Feature <- factor(anno_df$Feature, levels = rev(anno_df$Feature))
# --- Plot ---
ggplot(anno_df, aes(x = "", y = Percentage, fill = Feature)) +
geom_bar(stat = "identity", width = 1) +
coord_polar("y") +
labs(title = "Peak Genomic Annotation", fill = "Feature") +
theme_void() +
theme(legend.text = element_text(size = 8))
替换为自己的数据
脚本中以 # --- Demo data --- 标注的段落是示例数据生成代码。替换为自己的数据时,保持列名一致即可:
- 输入格式:narrowPeak 文件 + TxDb 注释
- 使用
read.csv()/readRDS()读取本地文件
延伸阅读
- 相关教程:Peak 注释 完整流程
- 出现 bug?欢迎在 FigCode 页面 点击对应卡片,在评论区留言。