Question: merging multiple sorted.bam.tmp.0000.bam into a single sorted.bam file.
0
gravatar for jaqx008
3 months ago by
jaqx00810
jaqx00810 wrote:

I have been trying to generate sorted.bam files. but haven't been successful. each time I get numerous sorted.bam files individually and I want to merge them into one big sorted.bam. The following command was what is used to obtain this multiple bamfiles.

-S dustMapping.sam && samtools view -S -b dustMapping.sam -o dustMapping.bam && samtools sort dustMapping.bam -odustMapping.sorted.bam && samtools index dustMapping.sorted.bam -o dustMapping.sorted.bam.bai && rm dustMapping.sam && dustMapping.bam

I don't know if the sorting was completed and why and the program terminates after outputting the sorted bam files. I have tried to merge with the following command.

bamtools merge -list folder.bam -out sorted.bam and I got a 64byte sorted.bam output file. what could be wrong please? (Im a Beginner) Thanks

ADD COMMENTlink modified 3 months ago • written 3 months ago by jaqx00810
1

One likely can't merge the tmp files produced during sort manually. Sorting process, when it completes normally, will automatically delete the tmp files. You may need to assign more RAM to the sort process and/or make sure that you are not running out of disk space during the sorting.

samtools index command does not need a -o directive.

ADD REPLYlink modified 3 months ago • written 3 months ago by genomax46k

Oh OK. But How do I do that? Im working in a 500Gb external hard drive and has about 250GB of space.

ADD REPLYlink written 3 months ago by jaqx00810

Okay, first step to debugging this...I'd do things one at a time instead of stringing them all together. Confirm whether or not dustMapping.sorted.bam is being made (is "-odustMapping.sorted.bam" in your commandline, or just a typo here?)

Worst case scenario, you can cut your fastq into smaller pieces that are sortable, and maybe you can merge them all after.

ADD REPLYlink modified 3 months ago • written 3 months ago by swbarnes23.4k

Ok let me try doing the commands one after the other. The -o is a typo. thanks. Will let you know how it goes

ADD REPLYlink written 3 months ago by jaqx00810
0
gravatar for jaqx008
3 months ago by
jaqx00810
jaqx00810 wrote:

Thanks everyone, I was able to obtain my sorted.bam file. But when I tried to generate the .bai file, the output i get renamed to "-o". the command I ran was

samtools index dustMapping.sorted.bam -o dustMapping.sorted.bam.bai

is this normal? or I have the right .bai file

ADD COMMENTlink written 3 months ago by jaqx00810

You don't need to specify -o when you index the sorted file. Just samtools index dustMapping.sorted.bam will produce dustMapping.sorted.bam.bai

ADD REPLYlink written 3 months ago by genomax46k

Oh. Thanks a lot. I will do that

ADD REPLYlink written 3 months ago by jaqx00810
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1921 users visited in the last hour