本篇数据完全来源公众号“老俊俊的生信笔记”
数据来自参考文档:https://github.com/junjunlab/tackPlotR/wiki
下载参考基因组
下载地址:
wget http://ftp.ensembl.org/pub/release-102/fasta/mus_musculus/dna/Mus_musculus.GRCm38.dna.primary_assembly.fa.gz
wget http://ftp.ensembl.org/pub/release-102/gtf/mus_musculus/Mus_musculus.GRCm38.102.gtf.gz
#不能使用压缩格式的基因组和注释,先解压
gunzip Mus_musculus.GRCm38.102.gtf.gz Mus_musculus.GRCm38.dna.primary_assembly.fa.gz
参考链接:https://www.jianshu.com/p/ca6aada5cbf1
分组
install.packages("devtools")
devtools::install_github("dzhang32/ggtranscript")
library("ggtranscript")
devtools::install_github('junjunlab/tackPlotR')
library(tackPlotR)
library(ggsci)
library(rtracklayer)
# 1.load gtf读取 bigwig 文件
gtf <- import.gff('Mus_musculus.GRCm38.102.gtf') %>%
data.frame()
# help
?loadBWfile
file <- c(
"control.input.bw", "control.ip.bw",
"t1.input.bw", "t1.ip.bw",
"t2.input.bw", "t2.ip.bw"
)
samp <- c(
"control.input", "control.ip",
"t1.input", "t1.ip",
"t2.input", "t2.ip"
)
group1 <- c(rep(c("Input", "IP"), 3))
group2 <- c(rep("Control", 2), rep("T1", 2), rep("T2", 2))
# 2.load bw files
allBw <- loadBWfile(file = file, sample = samp, group1 = group1, group2 = group2)
# check
head(allBw,3)
# seqnames start end score sample group1 group2
# 1 1 1 3001485 0.0000 control.input Input Control
# 2 1 3001486 3001490 12.5599 control.input Input Control
# 3 1 3001491 3001510 25.1199 control.input Input Control
#基本绘图:。
plotTrack(
gtfFile = gtf,
gene = "Actb",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "group1",
facetVars = "sample"
)
image
修改映射变量:
plotTrack(
gtfFile = gtf,
gene = "Actb",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "sample",
facetVars = "sample"
)
image.png
修改 track 颜色:
plotTrack(
gtfFile = gtf,
gene = "Actb",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "sample",
facetVars = "sample",
trackCol = pal_lancet()(6)
)
image.png
绘制多个转录本结构, 默认绘制 CDS 和 exon 最长的转录本:
plotTrack(
gtfFile = gtf,
gene = "Tnf",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "group1",
facetVars = "sample",
multiple = TRUE,
myTransId = c("ENSMUST00000025263", "ENSMUST00000167924")
)
image.png
修改分面填充颜色:
plotTrack(
gtfFile = gtf,
gene = "Actb",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "group1",
addfacetCol = TRUE,
facetVars = "sample",
facetFill = pal_d3()(6),
borderCol = rep("white", 6)
)
image.png
添加分面:
plotTrack(
gtfFile = gtf,
gene = "Actb",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "group1",
facetVars = c("group2", "group1"),
addfacetCol = TRUE,
facetFill = c(pal_d3()(3), pal_npg()(6)),
borderCol = rep("white", 9)
)
image.png
添加多层封面:
# add more one facet
plotTrack(
gtfFile = gtf,
gene = "Actb",
arrowCol = "black",
bigwigFile = allBw,
sampleAes = "group1",
facetVars = c("group2", "group1", "sample"),
addfacetCol = TRUE,
facetFill = c(pal_d3()(3), pal_npg()(6), pal_locuszoom()(6)),
borderCol = rep("white", 15)
)
image.png
网友评论