Split a sam file by chromosome
1
0
Entering edit mode
10 days ago
ICfc97 • 0

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 • 113 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
10 days ago
GenoMax 102k

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: 2553 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