bioinfoer

找回密码
立即注册
搜索
热搜: 活动 交友 discuz
发新帖

0

收听

12

听众

409

主题
发表于 前天 11:35 | 查看: 8| 回复: 1

背景

用R画文章里的这种肿瘤克隆进化的图。

出自PMID: 25252869文章

应用场景

Create timecourse "fish plots" that show changes in the clonal architecture of tumors, https://github.com/chrisamiller/fishplot

展示肿瘤细胞克隆进化的时间、比例等信息。

像例文那样,在三维时间节点上共鉴定到4个克隆群,我们可以看到其中founding clone 在三个时间点上占比都非常高,70%左右,除去这个主克隆外,还有三个亚克隆,在三个时间点上变化比较大,其中主要是subclone 1 的逐渐消失,subclone2 的逐渐扩增以及subclone 3的从无到有。

**题外话:**还有一个R包timescape,画clonal evolution这种鱼图也很美,https://bioconductor.org/packages/release/bioc/vignettes/timescape/inst/doc/timescape_vignette.html。

克隆进化图有点像sankey。

环境设置

使用国内镜像安装包

options("repos"= c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="http://mirrors.ustc.edu.cn/bioc/")

install.packages("devtools")
library(devtools)
install_github("chrisamiller/fishplot")

加载包

library(fishplot)

Sys.setenv(LANGUAGE = "en") #显示英文报错信息
options(stringsAsFactors = FALSE) #禁止chr转成factor

输入数据

需要三种输入:

  • easy_input.txt,每行表示每个克隆群在不同时间节点的VAF/CCF 占比,每列表示每个时间节点中各个克隆簇的情况。
  • timepoints,用来定义easy_input.txt的四列对应的4个时间节点。其中therapyTime列是化疗后休复期推断出的克隆群整体状况。
  • parents,与时间节点相对应的各个克隆群进化关系。例图中,“0”表示主克隆,“1, 1”表示在主克隆之后有两个平行发展的亚克隆簇,“3”表示在这个克隆簇发生时,已经有两次克隆事件。进一步根据各个时间节点,各个克隆簇占比情况,脚本便可实现。为便于理解parents的写法,结尾附上了几个例子。
frac <- read.table("easy_input.txt", header=T, sep='\t',row.names=1)
frac
frac.table <- as.matrix(frac)
timepoints <- c(0,75,110,120) #决定了鱼头、鱼身、鱼尾的长度
parents <- c(0,1,1,3) 

**题外话:**除了用上述方法构建输入以外,还可以用CloneEvol输出的结果作为输入,fisherplot可以跟ClonEvol(擅长画树枝图)无缝对接,详见:https://github.com/chrisamiller/fishplot里的“clonevol integration”

开始画图

fish <- createFishObject(frac.table, parents, timepoints)

#设置每种clone的颜色
fish <- setCol(fish, c("#099D79", "#70C7EC", "#E8262D","#2C3789"))
fish <- layoutClones(fish)

pdf('fish.pdf', width=10, height=6)
par(mar = par()$mar + c(0,0,3,0)) #在底部留出画图例的地方

fishPlot(fish, shape = "spline", #spline,圆滑的;或polygon,直的
         #title.btm = "Clonal architecture of tumors", #左下角可以写字
         cex.title = 1.2, #字号
         pad.left = 0.25, #鱼头的边的倾斜角度
     
         vlines = timepoints[c(1:2,4)], #画三条竖直实线
         col.vline = "white", #线的颜色
         vlab = c("PMF", "sAML", "sAML\nREM"), #竖线对应的文字,在画竖线的前提下才能写字
     
         bg.col = c("#F1F2F2","#F1F2F2","#F1F2F2"), #灰色背景
         border = 0.1 #每个clone的轮廓线的宽度
         )

#如果三条竖线要画成虚线,就运行下面这行
#abline(v=timepoints[c(1:2,4)], col="white", lty=2, lwd=1)

#添加clone的图例
par(xpd = T)
legend("bottomright", 
       inset=c(.7,-.3), #把图例画到图外,根据自己的鱼调整
       pch=16, bty="n", 
       col=fish@col, text.col = fish@col,
       legend = paste0(row.names(frac)," ",frac$PMF,"%"))

legend("bottomright", 
       inset=c(.3,-.3),
       pch=16, bty="n", 
       col=fish@col, text.col = fish@col,
       legend = paste0(frac$sAML,"%"))

legend("bottomright", 
       inset=c(.0,-.3),
       pch=16, bty="n", 
       col=fish@col, text.col = fish@col,
       legend = paste0(frac$Saml_REM,"%"))

dev.off()

后期加工处理

前面输出的fish.pdf文件是矢量图,可以用illustrator等工具编辑,例如添加例文中的点、基因名,移动文字位置等等。

或者用https://bioinfoer.com/forum.php?mod=viewthread&tid=631&extra=导出矢量图,用ppt就能编辑。

如果有更多克隆,要怎样设置parents?

frac.table <- read.table("easy_input2.txt", header=T, sep='\t', row.names=1)
frac.table
frac.table <- as.matrix(frac.table)
timepoints <- c(0,30,75,150) 
parents <- c(0,1,2,0,4,5)

pdf('fish2.pdf', width=8, height=5)
fish <- createFishObject(frac.table, parents, timepoints)
fish <- layoutClones(fish)
fishPlot(fish,shape="spline")
dev.off()


再进一步,互相对比着看fishplot自带的三条鱼https://github.com/chrisamiller/fishplot对应的代码:https://github.com/chrisamiller/fishplot/blob/master/tests/test.R,就能掌握写parents的规律。

收藏回复 显示全部楼层 道具 举报

发表于 前天 11:40

文中所用数据可以关注公众号“生信喵实验柴”

发送关键词“20250514”获取

回复 显示全部楼层 道具 举报

您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|bioinfoer ( 萌ICP备20244422号 )

GMT+8, 2025-12-10 01:04 , Processed in 0.124830 second(s), 33 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表