This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Other then picard better way to calculate insertmetrics from a bam file ?

Hi,

I tried with picard, I got the distributions is their any tool or AWK command I can directly extract from a sam/bam file ?

thanks!

alignment next-gen assembly genome

Not sure what kind of metrics you are looking for but reformat.sh from BBMap suite has a bunch of options for metrics.

Histogram output parameters:

bhist=<file>            Base composition histogram by position.
qhist=<file>            Quality histogram by position.
qchist=<file>           Count of bases with each quality value.
aqhist=<file>           Histogram of average read quality.
bqhist=<file>           Quality histogram designed for box plots.
lhist=<file>            Read length histogram.
gchist=<file>           Read GC content histogram.
gcbins=100              Number gchist bins.  Set to 'auto' to use read length.
gcplot=f                Add a graphical representation to the gchist.
maxhistlen=6000         Set an upper bound for histogram lengths; higher uses more memory.
                        The default is 6000 for some histograms and 80000 for others.

Histograms for sam files only (requires sam format 1.4 or higher):

ehist=<file>            Errors-per-read histogram.
qahist=<file>           Quality accuracy histogram of error rates versus quality score.
indelhist=<file>        Indel length histogram.
mhist=<file>            Histogram of match, sub, del, and ins rates by read location.
ihist=<file>            Insert size histograms.  Requires paired reads interleaved in sam file.
idhist=<file>           Histogram of read count versus percent identity.
idbins=100              Number idhist bins.  Set to 'auto' to use read length.

I'm not able to generate any histogram for insertsizes ?

**##CMD##**
./reformat.sh -Xmx10g in1=/data/SRR_1.fastq in2=/data/SRR_2.fastq  ihist=/data/SRR.sam  out=SRR.hist  
Set insert size histogram output to /data/SRR.sam

Set INTERLEAVED to false
Unspecified format for output SRR.hist; defaulting to fastq.
Input is being processed as paired
Writing interleaved.
Input:                      119852838 reads             17738220024 bases
Output:                     119852838 reads (100.00%)   17738220024 bases (100.00%)

Time:                           136.518 seconds.
Reads Processed:        119m    877.93k reads/sec
Bases Processed:      17738m    129.93m bases/sec

That options requires input to be in interleaved SAM format (it does not work with raw reads).

If you are interested in getting insert sizes then you can do that by a couple of different ways using BBMap. Those options are noted in this post.

I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

I able to retrieve the insert-metrics while comparison with other tools like picard its showing less insert-size. Picard shows very good distribution with read pairs information.

I don't know about other tools but since BBMap is using actual alignments (or read overlap) the stats generated should be accurate.

2 answers

You can check insert size distribution using qualimap which is very easy to use and takes sorted bam/sam as input. It gives you complete mapping statistics along with insert size and its standard deviation. Alternatively, you can use bamstats which also gives detailed mapping stats.

using bamstats I'm getting Mapping quality, readlength, editdistances, coverage depth, start positions I'm not able find insert metrics.

Suggest you to use Qualimap, it gives graphical representation for insert size calculated.

Another option is Alfred. We provide example quality control files for different sequencing assays (DNA-Seq whole-exome, ATAC-Seq, ...) and different sequencing technologies (Illumina, ONT, PacBio) at the companion web application so you can have a look if that's what you are looking for (QC files include the insert size).

I tried with bamstats and alfred.

Thanks, did alfred work?

Yes, I'm getting good distribution only with picard.

Log in to answer this question.