getReadCountsFromBAM including bed information
1
0
Entering edit mode
@pau-marc-munoz-torres-6731
Last seen 6.8 years ago
Barcelona

Good morning

 I am traying to analize some bam files using cn.mops. The scipt I am using until I try to introduce Graneges object to the getReadCountsFromBAM function. To read the bed file and convert it to Granges object i use a funtion (the code is in this post). Nevetheless i am getting the following error:

 

Error in exomeCopy::countBamInGRanges(bam.file = BAMFiles[i], granges = GR,  :
  unused argument (GR = <S4 object of class "GRanges">)

 

Can anyone tell me what is wrong?

 

Thanks


> BAMFiles <- list.files(pattern="_RG.bam$")

bed<-bed_to_granges("Genes_part.bed")

 

> bamDataRanges <- getReadCountsFromBAM(BAMFiles,sampleNames, refSeqNames,GR=bed)
Identified the following reference sequences:  1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,X,Y
Using 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, X, Y as reference.

 PLEASE BE PATIENT... this might take a while. Consider using the parallel version of this function

Error in exomeCopy::countBamInGRanges(bam.file = BAMFiles[i], granges = GR,  :
  unused argument (GR = <S4 object of class "GRanges">)

> typeof(bed)
[1] "S4"


bed_to_granges <- function(file){
   df <- read.table(file,
                    header=F,
                    stringsAsFactors=F)
 
   if(length(df) > 6){
      df <- df[,-c(7:length(df))]
   }
 
   if(length(df)<3){
      stop("File has less than 3 columns")
   }
 
   header <- c('chr','start','end','id','score','strand')
   names(df) <- header[1:length(names(df))]
 
   if('strand' %in% colnames(df)){
      df$strand <- gsub(pattern="[^+-]+", replacement = '*', x = df$strand)
   }
 
   if(length(df)==3){
      gr <- with(df, GRanges(chr, IRanges(start, end)))
   } else if (length(df)==4){
      gr <- with(df, GRanges(chr, IRanges(start, end), id=id))
   } else if (length(df)==5){
      gr <- with(df, GRanges(chr, IRanges(start, end), id=id, score=score))
   } else if (length(df)==6){
      gr <- with(df, GRanges(chr, IRanges(start, end), id=id, score=score, strand=strand))
   }
   return(gr)
}

 

 sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.1

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] C

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets
[8] methods   base     

other attached packages:
[1] Biobase_2.36.2       cn.mops_1.22.0       GenomicRanges_1.28.3
[4] GenomeInfoDb_1.12.2  IRanges_2.10.2       S4Vectors_0.14.3    
[7] BiocGenerics_0.22.0

loaded via a namespace (and not attached):
 [1] Rsamtools_1.28.0        Biostrings_2.44.1      
 [3] bitops_1.0-6            exomeCopy_1.22.0       
 [5] zlibbioc_1.22.0         XVector_0.16.0         
 [7] BiocParallel_1.10.1     RCurl_1.95-4.7         
 [9] compiler_3.4.1          GenomeInfoDbData_0.99.0
>

 

cn.mops bed files getReadCountsFromBAM • 1.0k views
ADD COMMENT
0
Entering edit mode
@pau-marc-munoz-torres-6731
Last seen 6.8 years ago
Barcelona

solved using  X <- getSegmentReadCountsFromBAM(BAMFiles,GR=gr)

ADD COMMENT

Login before adding your answer.

Traffic: 528 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6