how many files are generated after sorting of .bam file ?
1
0
Entering edit mode
6.0 years ago
iqra • 0

I used the following command for the sorting of bam file (samtools sort eg2.bam -o eg2.sorted.bam) size of my sam file was 44.6GB and after conversion into bam it is 35GB. sorting of bam file is producing a large no. of temporary files in MB.

RNA-Seq alignment • 3.3k views
ADD COMMENT
1
Entering edit mode

either you can furnish a temporary directory for storing temporary files or wait till the process is over. Only one sorted bam file be output as per OP function. iqraishtiaq411

ADD REPLY
0
Entering edit mode

indexing of .bam file is giving this error . how it would be handle ?

samtools index my_sorted.bam
[E::hts_idx_push] Region 536938519..536938598 cannot be stored in a bai index. Try using a csi index with min_shift = 14, n_lvls >= 6
samtools index: failed to create index for "my_sorted.bam": Numerical result out of range
ADD REPLY
0
Entering edit mode

Check this

ADD REPLY
0
Entering edit mode

Are you using the latest version of samtools?

ADD REPLY
0
Entering edit mode

samtools 1.7 Using htslib 1.7-2 Copyright (C) 2018 Genome Research Ltd.

ADD REPLY
1
Entering edit mode
6.0 years ago
h.mon 35k

SAMtools by default uses 768Mb memory per thread, so when sorting larger bams it will have to write a large amount of temporary files to disk. If you have RAM memory available, you can reduce disk writing (and execution time) by giving samtools more memory per thread:

-m INT     Set maximum memory per thread; suffix K/M/G recognized [768M]

As cpad0112 stated, when the sorting is finished, all temporary files are deleted and only the final sorted file should remain. If this is not the case, samtools sort did not finish successfully.

ADD COMMENT
0
Entering edit mode

If memory is a problem, but CPUs aren't, consider sambamba sort because the memory specified with -m is the total memory (so not per thread), so you can get many CPUs working without worrying about memory.

ADD REPLY

Login before adding your answer.

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