Split a sam file by chromosome
1
0
Entering edit mode
2.9 years ago
ICfc97 ▴ 20

Hi! I'm trying to use PRISM program to detect CNVs and the input files have to be .SAM files for each chromosome, I have the .BAM file of each sample but I don't know it it is convenient to convert it to .SAM and the n split it or the contrary.

for file in *_chr.bam; do 
filename=`echo $file | cut -d “.” -f 1`; 
for chrom in `seq 1 22` X Y; do 
samtools view -bh $file chr${chrom} > ${filename}_${chrom}.bam; 
done; 
done
CNVs NGS PRISM • 615 views
ADD COMMENT
1
Entering edit mode

If you want SAM files the use:

samtools view -h $file chr${chrom} > ${filename}_${chrom}.sam; 
ADD REPLY
0
Entering edit mode
2.9 years ago
GenoMax 141k

While some commands have changed over years this should still be useful: How Can I Split Bam Into Chromosome (In A Loop) Using Samtools?

Sounds like you know what you want and how to get there.

ADD COMMENT

Login before adding your answer.

Traffic: 2517 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6