Entering edit mode
4.5 years ago
javanokendo
▴
60
I have a SAM file which I now want to split into different chromosome from chromosome chr1..chr20 as follows.
/home/SpliceGraph/Human/chr1.sam
/home/SpliceGraph/Human/chr2.sam/
/home/SpliceGraph/Human/chr3.sam/
/home/SpliceGraph/Human/chr4.sam/
/home/SpliceGraph/Human/chr5.sam
Which command can I use to do this?
How To Split A Bam File By Chromosome
The following code:
samtools idxstats out.bam | cut -f1 | grep -v '*' > chr.names
is not giving the list of chromosomes. It give something like this:Those are the chromosome (reference) names that are present in your BAM file.
Please use
ADD COMMENT/ADD REPLY
when responding to existing posts to keep threads logically organized.SUBMIT ANSWER
is for new answers to original question.Please use
ADD COMMENT
to reply to answers. It gives you the names that were in the fasta file that you mapped against. The command itself is correct. If you want different names then align against a fasta file that contains the names you would like.