Thanks you helped me a lot. The following script did the job:
samtools view -b -L manifest.bed input.bam > manifest_output.bam
I have one more question. Script above outputs alignments overlapping with the manifest.bed file. Is it possible to get output with non-overlapping alignments?
what is manifest.txt ?
Manifest.txt is the file that specifies a reference genome and targeted reference regions to be used in the alignment step. This definition is from MiSeq System Guide. Manifest.txt is given to MiSeq, but I want this process done on computer. Example for manifest file and I would like to know If I can do same procedure with BWA.
I don't think you can limit alignments to certain regions from genome using an intervals file with
bwa. You will need to filter the alignments afterwards if you are only interested in specific regions.You could create a reduced representation genome by extracting the areas you are interested in and creating a new index. This always carries the risk that reads may be forcibly aligned to regions where they did not come from. So the approach of post-filtering alignment will always be better.
Note: If you are doing this for an amplicon workflow then you can go with creating a reduced representation reference with areas of your interest.
If I can not do this with bwa then which tool can I use to do the alignments for certain region?
MiSeq reporter manual says this for custom amplicon workflow:
PCR amplicon protocol uses
bwa.If you are looking to reproduce either workflows then you will need to take this into consideration. How this is exactly implemented in Illumina software is not stated in the manual.
If you are doing PCR amplicon, use the strategy noted by @Pierre and then use
bwa.