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,