TBtools攻略磕盐——从入门到自闭可视化相关收集

『TBtools-circos』谁说TBtools画的图丑!老夫

2020-08-17  本文已影响0人  ShawnMagic

国际惯例,先上图


20200817221534.jpg

目的

Overview最后一部分是circRNA染色体分布展示,这里想到用circos图就是俗称的圈图来展示。

之前一直用circos画圈图,确实出图好看,速度快,也多样化,conf文件相对也比较好写。跟着官网走就可以了。之前用TBtools画过一次圈图,电脑太卡了,这次升级电脑以后,又尝试了下,果然顺滑了不少,这里做下记录。


数据准备

因为需要找到miRNA-circRNA的关系,所以要先找到map,此外还要知道转录本的位置,所以需要知道miRNA,circRNA的位置,最后在R下面用left_join将位置合并,就是我们的link文件。

具体操作

20200817212246.jpg 20200817212814.jpg
#####################################
#     Prj: Heterosis-circ
#     Assignment: circRNA-miRNA-mRNA link
#     Author: Shawn Wang
#     Date: Aug 12 2020
####################################
##=========== 01.load packages ===========
setwd("~/02.Project/03.circRNA/02.Overview/01.DataAnalysis/")
options(stringsAsFactors = F)
library(dplyr)
library(ggplot2)
library(reshape2)
library(stringr)

## function of check the first yxy area of a df
heady = function(x,y){
  x[1:y,1:y]
}
##=========== 02.load data ===========
# position
mRNApos <- read.delim("../../01.Database/01.map/02.clean/01.Gh.pos.xls", 
                      header = F,
                      sep = "\t")
head(mRNApos)
colnames(mRNApos) = c("GeneID","Chr","Start","End")
circ.pos <- read.delim("../../01.Database/01.map/02.clean/03.circ.pos.xls",
                      header = F,
                      sep = "\t")
head(circ.pos)
colnames(circ.pos) = c("circID","Chr","Start","End")
miRpos <- read.delim("../../01.Database/01.map/02.clean/02.miRNA-pos.final.xls",
                     header = F,
                     sep = "\t")

colnames(miRpos) = c("miID","Chr","Start","End")
miRpos$miID = gsub(pattern = "MI",replacement = "mi",miRpos$miID)
head(miRpos)
## map
circ2mi <- read.delim("../../01.Database/01.map/02.clean/06.miRNA2circ.map",
                      header = F,
                      sep = "\t")
head(circ2mi)
colnames(circ2mi) = c("miID","circID")
mi2mRNA <- read.delim("../../01.Database/01.map/02.clean/05.mi2mRNA.map",
                      header = T,
                      sep = "\t")
head(mi2mRNA)
mi2mRNA = mi2mRNA[,-2]
circ2host <- read.delim("../../01.Database/01.map/02.clean/04.circ2host.map",
                        header = T,
                        sep = "\t")
head(circ2host)
##=========== 02.load data ===========
## merge
circ2mi_link = left_join(circ2mi,circ.pos,by = "circID")%>% left_join(.,miRpos,by = "miID")
head(circ2mi_link)
circ2mi_link = circ2mi_link[,c(3,4,5,6,7,8)]
write.table(circ2mi_link,file = "../circ2mi_link.xls",
            col.names = F,
            row.names = F,
            sep = "\t",
            quote = F)
circ2host_link = left_join(circ2host, circ.pos,by = "circID")%>% left_join(.,mRNApos,by = "GeneID")
head(circ2host_link)
write.table(circ2host_link[,-c(1,2)],file = "../circ2host.link.xls",
            col.names = F,
            row.names = F,
            sep = "\t",
            quote = F)
mi2mRNA_link = left_join(mi2mRNA, miRpos, by = "miID")%>% left_join(.,mRNApos,by = "GeneID")
head(mi2mRNA_link)
write.table(mi2mRNA_link[,-c(1,2)],file = "../mi2mRNA.link.xls",
            col.names = F,
            row.names = F,
            sep = "\t",
            quote = F)

额,这里都做了一下。

画图

准备好这几个文件

--- 02.Overview/05.tbtoolscircos » tree 
.
├── 01.TBtoolsNew.svg
├── 01.TBtoolsRaw.300dpi.jpg
├── 01.TBtoolsRaw.600dpi.jpg
├── 01.TBtoolsRaw.svg
├── Gh.chr.len              ## 染色体长度
├── circ2mi_link.xls    ## circ-miRNA
├── circpos.txt             ## circRNA位置
├── mRNApos.txt             ## mRNA位置
├── mRNApos.xlsx            
└── miRNApos.txt            ## miRNA位置
##= 染色体长度文件 =##
head -3 Gh.chr.len       
A01 115949770
A02 105669191
A03 110115461
###################
##= circ-miRNA =##
## 前面三列是circRNA的染色体和起始位置,后面是miRNA的染色体和起始位置,最后是线条的RGB颜色
head -3 circ2mi_link.xls 
A01 33355841    33370716    A01 165803  165927  "255,105,180"   
A01 6737689 6754243 A01 114627734   114627493   "255,105,180"   
A01 3587538 3609685 A01 12372957    12373079    "255,105,180"   
###################
##= mRNA pos =##
## 前3列还是位置,第四列是一列1,TBtools中可以设置bin大小,然后对第四列计算,这里都设置成1就是一会会用这个1求和,那么就是密度值。
A01 45486   49597   1
A01 60648   62498   1
A01 66475   68196   1
###################
20200817220140.jpg

当然这一步只是设置了track的参数,而染色体和link具体的参数还没有设置,show my circos plot之后再在里面详细设置

20200817220412.jpg

现在有点丑,主要原因是没有设置染色体框架的位置和参数,还有link也没有设置。下面美化它

20200817221414.jpg

最后调整

CJ说配色太轻佻了,哈哈 老夫的少女心啊!然后改了比较暗的颜色,自己加了legend。

上一篇下一篇

猜你喜欢

热点阅读