bamread
Read data from BAM file
Syntax
BAMStruct = bamread(File,RefSeq,Range)
BAMStruct = bamread(File,nomap)
[BAMStruct,HeaderStruct]
= bamread(File,RefSeq,Range)
... = bamread(File,RefSeq,Range,Name,Value)
Description
reads
the alignment records in BAMStruct
= bamread(File
,RefSeq
,Range
)File
, a BAM-formatted
file, that align to RefSeq
, a reference sequence,
in the range specified by Range
. It returns the
alignment data in BAMStruct
, a MATLAB® array
of structures.
returns reads that are not mapped to any reference. BAMStruct
= bamread(File
,nomap
)
[
also
returns the header information in BAMStruct
,HeaderStruct
]
= bamread(File
,RefSeq
,Range
)HeaderStruct
,
a MATLAB structure.
reads
the alignment records with additional options specified by one or
more ...
= bamread(File
,RefSeq
,Range
,Name,Value
)Name,Value
pair arguments.
Input Arguments
|
Character vector or string specifying a file name or path and file name of a BAM-formatted file. If you specify only a file name, that file must be on the MATLAB search path or in the Current Folder. Note The function requires the BAM file to be ordered, except when returning reads that are not mapped to any reference. |
|
Either of the following:
|
|
Two-element vector specifying the begin and end range positions
on the reference sequence, |
|
Either of the following: |
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
|
Controls the return of only alignment records that are fully
contained within the range specified by Default: |
|
Controls the reading of the optional tags in addition to the
first 11 fields for each alignment in the BAM-formatted file. Choices
are Default: |
|
Character vector or string specifying a nonexisting file name or a path and file name for
saving the alignment records in the specified range of a specific
reference sequence. The The SAM-formatted file is always one-based, even if you set
the |
|
Logical specifying whether This name-value pair argument affects the Caution If you plan to use the Default: |
Output Arguments
|
An N-by-1 array of structures containing sequence alignment and mapping information from a BAM-formatted file, where N is the number of alignment records stored in the specified range. Each structure contains the following fields.
| ||||||||||||||||||||||||||
|
MATLAB structure containing header information for the BAM-formatted file in the following fields.
* These structures and their fields appear in the output structure only if they are present in the BAM file. The information in these structures depends on the information present in the BAM file. |
Examples
Tips
The
bamread
function requires a BAM file.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
pair arguments to create a SAM-formatted file. You can then usesamread
with theBlockRead
Name,Value
pair arguments 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 thatbamread
returns 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
See Also
baminfo
| samread
| saminfo
| soapread
| fastqwrite
| fastqinfo
| fastainfo
| fastaread
| fastawrite
| sffinfo
| sffread
| fastqread
| BioIndexedFile
| BioMap