I am wondering about to use a BAM file output as a input to make a alignment to others FASTA reference genome. I have been reading how to get a FASTA format from my BAM file but I am not sure if the reads depth could affect my alignment. If that is possible, How could I do that?
2 answers
You can get the mapped/unmapped reads with the flags, check this post.
Then you can convert the bam file to fastq/fasta with bedtools bamToFastq
I have been reading how to get a FASTA format from my BAM file
If you use BBMap suite then it is as simple as
reformat.sh in=your.bam out=your.fa
to get fasta format sequences out. If you have paired end data then you may need to provide out1= out2= to contain the two fasta reads.
You should keep the reads in fastq format where possible so it would be best to do
reformat.sh in=your.bam out=your.fq
(see the note about paired-end reads above) and use them for next alignment.
I am not sure if the reads depth could affect my alignment.
Read depth should not affect the alignment since you are going to be individually aligning each read (or read-pair).
Log in to answer this question.
Command line to remap a position sorted bam: "samtools collate -uOn128 old-pos-srt.bam tmpxyz | samtools fastq - | bwa mem -pt16 ref.fa - | samtools sort --threads=4 -m4G -o new-pos-srt.bam"