When I tried to use samtools to split a bam file based on different chromosomes, I used this command:
samtools view input.bam -b chr21 | chr21.bam
However, I get error messages like this:
-bash: chr21.bam: command not found
[W::hts_idx_load3] The index file is older than the data file: input.bam.bai
How could I solve this problem? Thanks in advance~~~
The version I am using is:
Program: samtools (Tools for alignments in the SAM format)
Version: 1.10 (using htslib 1.10.2)