读取BAM文件-rsamtools

时间:2018-09-04 17:20:18

标签: bioconductor samtools

我正在尝试对MeDIP测序进行一些分析,并且在尝试读取BAM文件的过程中,无论使用哪个库运行代码,我都遇到类似的错误。

以下是samtools的示例:

library(Rsamtools)
bamFile <- "TI_meDIP_2x.bam"
readBAM <- function(bamFile){
    bam <- scanBam(bamFile)
    .unlist <- function (x){
         x1 <- x[[1L]]
        if (is.factor(x1)){
            structure(unlist(x), class = "factor", levels = levels(x1))
        } else {
            do.call(c, x)
        }
     }

     bam_field <- names(bam[[1]])

     list <- lapply(bam_field, function(y) .unlist(lapply(bam, "[[", y)))

    bam_df <- do.call("DataFrame", list)
     names(bam_df) <- bam_field

     #return a list that can be called as a data frame
     return(bam_df)
 }

bam1 <- readBAM(bamFile)

我收到以下错误:

Error in value[[3L]](cond) : 
failed to open BamFile: SAM/BAM header missing or empty
file: 'TI_meDIP_2x.bam'
In addition: Warning message:
In doTryCatch(return(expr), name, parentenv, handler) :

我试图与我的协作者联系,后者向我发送了BAM文件,并且标题似乎没有错误。我不确定这是由于代码引起的错误还是由于内存不足而导致的错误。谢谢

0 个答案:

没有答案