writing BAM files from within R
1
0
Entering edit mode
@margherita-mutarelli-5063
Last seen 7.1 years ago
Dear all, I have searched Rsamtools help pages and the mailing lists archives, but I couldn't find an answer to my question: is there any function to write a BAM file from within R? I use the scanBam function to read in R an input file and, after some merging and filtering within R, I would like to write the output a BAM file. Have you any suggestion? My first option at the moment is to create a SAM text file by writing the fields in the corresponding order and then use samtools to convert the SAM in BAM, but maybe there is a better solution that I have missed. Thank you all in advance. Best, Margherita [[alternative HTML version deleted]]
convert Rsamtools convert Rsamtools • 2.1k views
ADD COMMENT
0
Entering edit mode
@valerie-obenchain-4275
Last seen 23 months ago
United States
Hi Margherita, See ?filterBam. This function parses records in a BAM file according to the filters specified in the 'param' argument and writes them out to a new BAM file. If you can accomplish your filtering with the 'param' argument (?ScanBamParam) this should work for you. If merging is necessary after filtering you can use mergeBam(). As far as I know, there is no general function for writing data to a BAM file from an R object (i.e., once the data have been read into R). Valerie On 01/22/12 14:35, margherita mutarelli wrote: > Dear all, > I have searched Rsamtools help pages and the mailing lists archives, but I > couldn't find an answer to my question: is there any function to write a > BAM file from within R? > I use the scanBam function to read in R an input file and, after some > merging and filtering within R, I would like to write the output a BAM file. > > Have you any suggestion? My first option at the moment is to create a SAM > text file by writing the fields in the corresponding order and then use > samtools to convert the SAM in BAM, but maybe there is a better solution > that I have missed. > > Thank you all in advance. > > Best, > > Margherita > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
ADD COMMENT

Login before adding your answer.

Traffic: 215 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