查看原文
其他

Bigwig 可视化用 tackPlotR 试试看?

JunJunLab 老俊俊的生信笔记 2023-06-15


你在鼓楼的夜色中

1引言

写了一个小 R 包 tackPlotR, 用来可视化 bigwig 的,感觉大家需求还挺大的。

地址:

https://github.com/junjunlab/tackPlotR

参考文档:

https://github.com/junjunlab/tackPlotR/wiki

2安装

devtools::install_github('junjunlab/tackPlotR')

# help
?loadBWfile
?plotTrack

3使用介绍

主要分为两步, 读取 bigwig 文件绘图

读取文件

具体怎么分组看你自己:

library(tackPlotR)
library(ggsci)
library(rtracklayer)

# 1.load gtf
gtf <- import.gff('Mus_musculus.GRCm38.102.gtf',format = '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

绘图

基本绘图:

# examples
plotTrack(
  gtfFile = gtf,
  gene = "Actb",
  arrowCol = "black",
  bigwigFile = allBw,
  sampleAes = "group1",
  facetVars = "sample"
)

修改映射变量:

# change aes variable
plotTrack(
  gtfFile = gtf,
  gene = "Actb",
  arrowCol = "black",
  bigwigFile = allBw,
  sampleAes = "sample",
  facetVars = "sample"
)

修改 track 颜色:

# change track colors
plotTrack(
  gtfFile = gtf,
  gene = "Actb",
  arrowCol = "black",
  bigwigFile = allBw,
  sampleAes = "sample",
  facetVars = "sample",
  trackCol = pal_lancet()(6)
)

绘制多个转录本结构, 默认绘制 CDS 和 exon 最长的转录本:

# draw multiple genes
plotTrack(
  gtfFile = gtf,
  gene = "Tnf",
  arrowCol = "black",
  bigwigFile = allBw,
  sampleAes = "group1",
  facetVars = "sample",
  multiple = TRUE,
  myTransId = c("ENSMUST00000025263""ENSMUST00000167924")
)

修改分面填充颜色:

# change facet fill colors
plotTrack(
  gtfFile = gtf,
  gene = "Actb",
  arrowCol = "black",
  bigwigFile = allBw,
  sampleAes = "group1",
  addfacetCol = TRUE,
  facetVars = "sample",
  facetFill = pal_d3()(6),
  borderCol = rep("white"6)
)

添加分面:

# add one facet
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)
)

添加多层封面:

# 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)
)

4结尾

大家可以用自己的数据试试看。

有问题最好在我的 github 上面提问




  老俊俊生信交流群 (微信交流群需收取20元入群费用(防止骗子和便于管理))


老俊俊微信:


知识星球:



今天的分享就到这里了,敬请期待下一篇!

最后欢迎大家分享转发,您的点赞是对我的鼓励肯定

如果觉得对您帮助很大,赏杯快乐水喝喝吧!



  





gggsea 个性化绘制 GSEA 图

scRNAtoolVis 绘制单细胞 Marker 基因均值表达热图

给你 UMAP 坐标重复文章一模一样的图?

genesorteR 快速准确鉴定亚群 Marker 基因

scRNAtoolVis 尝试一下?

Seurat 官网单细胞教程四 (细胞周期矫正)

跟着 Nature medicine 学单细胞数据分析

单细胞亚群分面可视化

跟着 Nature medicine 学画图-tSNE

单细胞亚群 Marker 基因热图重绘及均值展示

◀...

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存