samtools merge not working
1
0
Entering edit mode
4.2 years ago
Ric ▴ 430

Hi, I am using the below script to merge around 1000 BAM files. However, the merged file is tiny compare to each separately BAM files.

> sh split_bam2sam-fasta_pbs.sh bams-1/*.q40.FixMate.clean.bam
bams-1/t_correction.0.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.100.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.101.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.102.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.103.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.104.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.105.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.106.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.107.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.108.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.109.fq.sorted.bam.dedup.q40.FixMate.clean.bam bams-1/t_correction.10.fq.sorted.bam.dedup.q40.FixMate.clean.bam 
...
bams-1/t_correction.9.fq.sorted.bam.dedup.q40.FixMate.clean.bam

.

#!/bin/bash
#usage: sh split_bam2sam-fasta__pbs.sh /path/to/input/*.sorted.dedup.bam

output="split-data"
mkdir $output
input=$(dirname $1)
samlist=$(printf '%s ' $@)

echo ${samlist}

cat << EOF  |qsub
#!/bin/bash -l

#PBS -N split_sam
#PBS -l walltime=150:00:00
#PBS -j oe
#PBS -l mem=70G
#PBS -l ncpus=8
#PBS -M m.lorenc@qut.edu.au
##PBS -m bea

cd \$PBS_O_WORKDIR

conda activate bowtie2
samtools merge ${input}/merged.sorted.dedup.bam ${samlist}
samtools index ${input}/merged.sorted.dedup.bam

EOF

How to merge all BAM files into one?

Thank you in advance,

samtools alignment next-gen sequencing • 1.1k views
ADD COMMENT
0
Entering edit mode
4.2 years ago

you're using a relative path

bams-1/*.q40.FixMate.clean.bam

while there is a cd in your script.

cd \$PBS_O_WORKDIR

try to use a full path for your input bam.

PS: you're script looks quite complicated for a simple 'merge'

ADD COMMENT

Login before adding your answer.

Traffic: 1571 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