从bam文件中提取读取位置

时间:2012-03-13 22:42:41

标签: r perl bioinformatics

我有一个包含几个SNP的vcf文件,现在我想看看,这些SNP是否均匀分布在我获得SNP的bam文件的读取上。具体来说,我想绘制SNP在读取位置上的数量。 我想知道是否有一些工具可以做到这一点,或者我是否必须自己编写脚本。如果是这样,R中是否有一个我可以做到的包(我习惯了R但是对perl没有多少经验)?

1 个答案:

答案 0 :(得分:2)

不确定“读取位置上的SNP”是什么意思,但您可以使用R / Bioconductor包和函数VariantAnnotation :: readVcf读取VCF,并使用基因组坐标使用Rsamtools查询bam文件: :countBam,使用ScanBamParam。没有测试,沿着

的路线
## first-time installation
source("http://bioconductor.org/biocLite.R")
biocLite(c("VariantAnnotation", "Rsamtools"))

安装相关的包,然后

library(VariantAnnotation) # also loads Rsamtools
snps = readVcf("/some/file.vcf")
param = ScanBamParam(which=rowData(vcf))
reads = countBam("/some/file.bam", param=param)

实现这一点的最佳方法可能取决于您感兴趣的SNP数量。我建议您使用预发布的R-2.15 alpha,因为您将获得更新的Bioconductor包。这些软件包具有广泛的插图(vignette(package="VariantAnnotation")和Bioconductor mailing list上的知识渊博的人,以及常见的帮助页面?readVcf