title: Convert Bam File to CSV
body: <p>I have a bam file does anyone know how to convert a bam file to a csv file? I am trying to use R-software to open the bam file but I am not sure how to get the variables from the bam files so far I have used the below mentioned coding:</p>
  
  <pre><code>rm(list=ls())
  
  #install bam packages
  source("http://bioconductor.org/biocLite.R")
  biocLite("Rsamtools",suppressUpdates=TRUE)
  biocLite("RNAseqData.HNRNPC.bam.chr14",suppressUpdates=TRUE)
  biocLite("GenomicAlignments",suppressUpdates=TRUE)
  
  
  #load library
  library(Rsamtools)
  library(RNAseqData.HNRNPC.bam.chr14)
  library(GenomicAlignments)
  bamfile &lt;- file.path("C:","Users","azzop","Desktop","I16-1144-01-esd_m1_CGCTCATT-AGGCGAAG_tophat2","accepted_hits.bam")
  gal&lt;-readGAlignments(bamfile)
  gal
  length(gal)
  names(gal)
  </code></pre>
  
  <p>When I inserted names(gal) it gave me <code>NULL</code> not sure it is the correct.</p>
  
  <p>I would like to convert the bam to csv and it would be easier to read the data</p>