bamread
Read data from BAM file
Syntax
Description
[
also returns the header information in BAMStruct
,HeaderStruct
]
= bamread(File
,RefSeq
,Range
)HeaderStruct
___ = bamread(
,
for any output arguments, specifies additional options using one or more name-value
arguments. For example, to save the alignment records to a file named
File
,RefSeq
,Range
,Name,Value
)'alignmentrecords.sam'
in the current folder,
BAMStruct =
bamread(File,RefSeq,Range,ToFile="alignmentrecords.sam")
.
Examples
Input Arguments
Output Arguments
Tips
Use the
baminfo
function to investigate the size and content, including reference sequence names, of a BAM-formatted file before using thebamread
function to read the file contents into a MATLAB array of structures.If your BAM-formatted file is too large to read using available memory, try either of the following:
Use a smaller range.
Use
bamread
without specifying outputs, but using theToFile
Name,Value argument to create a SAM-formatted file. You can then usesamread
with theBlockRead
Name,Value argument to read the SAM-formatted file. Or you can pass the SAM-formatted file to theBioIndexedFile
constructor function to construct aBioIndexedFile
object, which you can use to create aBioMap
object.
Use the
BAMStruct
output argument to construct aBioMap
object, which lets you explore, access, filter, and manipulate all or a subset of the data, before doing subsequent analyses or viewing the data.
References
[1] Li, H., Handsaker, B., Wysoker, A., Fennell, T., Ruan, J., Homer, N., Marth, G., Goncalo, A., and Durbin, R. (2009). The Sequence Alignment/Map format and SAMtools. Bioinformatics 25, 16, 2078–2079.
Version History
Introduced in R2010b
See Also
baminfo
| samread
| saminfo
| soapread
| fastqwrite
| fastqinfo
| fastainfo
| fastaread
| fastawrite
| sffinfo
| sffread
| fastqread
| BioIndexedFile
| BioMap