• barplot3d|圣诞节送你一个mutation signature搭建的“乐高”


    本文首发于“生信补给站”,https://mp.weixin.qq.com/s/VNLIFzc9OysepGrE3lJrkw

    更多关于R语言,ggplot2绘图,生信分析的内容,敬请关注小号。

     

    上次通过deconstructSigs|探寻cosmic的独特“气质”-mutation signature !学会了如何利用deconstructSigs-R包进行mutation signature分析。

    在文章最后利用每个样本的96种三碱基类型在最后绘制了柱形图,本文利用同样的数据绘制乐高图,下图为文献插图

     

     

     

    一 mutation signature分析

    快速实现mutation signature分析,得到每个样本的三碱基序列结果,详细参数详见deconstructSigs|探寻cosmic的独特“气质”-mutation signature !

    library(deconstructSigs)
    #查看数据
    head(sample.mut.ref)
    # Convert to deconstructSigs input
    sigs.input <- mut.to.sigs.input(mut.ref = sample.mut.ref,
                                  sample.id = "Sample",
                                  chr = "chr",
                                  pos = "pos",
                                  ref = "ref",
                                  alt = "alt")

    # Determine the signatures contributing to the example sample1
    sample_1 = whichSignatures(tumor.ref = sigs.input,
                             signatures.ref = signatures.cosmic,
                             sample.id = 1,
                             contexts.needed = TRUE,
                             tri.counts.method = 'default')

    #输出tumor的三碱基序列百分比
    sample_1$tumor

     

    二 搭“乐高”

    利用上部分得到的三碱基序列比例进行绘制:

    需要注意的自己的数据与COSMIC数据的顺序要相同 !

    library(barplot3d)
    # Read in COSMIC signature probabilities
    x=system.file("extdata", "signature_probabilities.txt", package = "barplot3d")
    sigdata=read.table(x,header=TRUE,stringsAsFactors = FALSE)
    # 输入文件的顺序必须与此一致
    cat(sigdata$Somatic_mutation_type,sep=" ")

    #使用自己的数据绘制乐高图
    legoplot3d(contextdata=sample_1$tumor,labels=FALSE,scalexy=0.03)

    img

    #参数调整
    legoplot3d(contextdata=sample_1$tumor,labels=FALSE,scalexy=0.01,sixcolors="broad",alpha=0.4)

    img

    scalexy:适当调整获得适当缩放的图像;

    alpha:柱子的透明度;

    sixcolors:默认颜色与Sanger的signature一致,可以设置为原始的Broad Institute颜色,也可以其他6种颜色。

     

    对了,图是3D的,可以自己转,,,

     

    参考资料:

    A mutational signature associated with alcohol consumption and prognostically significantly mutated driver genes in esophageal squamous cell carcinoma

    https://cran.r-project.org/web/packages/barplot3d/vignettes/barplot3d.html

     

    ◆ ◆ ◆ ◆ ◆

    精心整理(含图版)|你要的全拿走!有备无患 (R统计,ggplot2绘图,生信图形可视化汇总)

    【觉得不错,右下角点个“在看”,期待您的转发,谢谢!】

     

  • 相关阅读:
    Java中“==”与equals的区别以及equals方法的重写
    Java中的Switch....case语句:
    Java中的基本数据类型
    HTTP与HTTPS的区别
    深入理解HTTP协议、HTTP协议原理分析
    IntelliJ IDEA下的使用git
    Spring RestTemplate详解
    Java 适配器(Adapter)模式
    LINUX的ssh免密码配置
    CDH6.2安装配置第一篇:CDH配置本地http服务
  • 原文地址:https://www.cnblogs.com/Mao1518202/p/12102387.html
Copyright © 2020-2023  润新知