SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with quality in fastq file ThePresident Bioinformatics 11 08-10-2012 05:54 AM
Problem using HTSeq count with SAM file without quality score flashton Bioinformatics 2 04-11-2012 04:29 AM
Detecting FASTQ Quality Score Format bhan Bioinformatics 2 01-02-2012 04:40 PM
mapping quality score in tophat sam file jjpurwar Bioinformatics 5 06-22-2011 12:55 PM
Fastq quliaty score and MAQ output quality score baohua100 Bioinformatics 1 02-19-2009 10:21 AM

Reply
 
Thread Tools
Old 03-25-2013, 06:32 AM   #1
jgibbons1
Senior Member
 
Location: Worcester, MA

Join Date: Oct 2009
Posts: 133
Default average quality score for fastq file

Hello,
Simple question here, but I've had a problem finding a program to do it.

Given a fastq file, is there software that will calculate the average quality score for the entire file?

Thanks
jgibbons1 is offline   Reply With Quote
Old 03-25-2013, 07:21 AM   #2
JackieBadger
Senior Member
 
Location: Halifax, Nova Scotia

Join Date: Mar 2009
Posts: 381
Default

The "Compute quality statistics" function in Galaxy (https://main.g2.bx.psu.edu)
JackieBadger is offline   Reply With Quote
Old 03-25-2013, 08:28 AM   #3
jgibbons1
Senior Member
 
Location: Worcester, MA

Join Date: Oct 2009
Posts: 133
Default

Thanks @JackieBadger

Do you know of any unix/linux based tools to do this? I'm trying to stay away from galaxy for this tidbit.
jgibbons1 is offline   Reply With Quote
Old 03-25-2013, 09:07 AM   #4
JackieBadger
Senior Member
 
Location: Halifax, Nova Scotia

Join Date: Mar 2009
Posts: 381
Default

Quote:
Originally Posted by jgibbons1 View Post
Thanks @JackieBadger

Do you know of any unix/linux based tools to do this? I'm trying to stay away from galaxy for this tidbit.
Why do you need to avoid Galaxy?
JackieBadger is offline   Reply With Quote
Old 03-25-2013, 09:14 AM   #5
jgibbons1
Senior Member
 
Location: Worcester, MA

Join Date: Oct 2009
Posts: 133
Default

I'm trying to integrate this value into a larger analysis pipeline. Automating it would be more efficient.
jgibbons1 is offline   Reply With Quote
Old 03-25-2013, 09:28 AM   #6
GenoMax
Senior Member
 
Location: East Coast USA

Join Date: Feb 2008
Posts: 7,081
Default

Quote:
Originally Posted by jgibbons1 View Post
Hello,

Given a fastq file, is there software that will calculate the average quality score for the entire file?

Thanks
One should be careful about "average quality score" for an entire file since you could still have a subset of sequences that may be hidden outliers ("bad") in an otherwise "good" file.

Both Fastx toolkit (http://hannonlab.cshl.edu/fastx_toolkit/) and FastQC (http://www.bioinformatics.babraham.a...ojects/fastqc/) will generate statistics you could use.

If this is illumina data and you have access to CASAVA pipeline output then the summary file has a "mean" quality score for each sample that you could parse.
GenoMax is offline   Reply With Quote
Old 03-25-2013, 10:38 AM   #7
JackieBadger
Senior Member
 
Location: Halifax, Nova Scotia

Join Date: Mar 2009
Posts: 381
Default

You can also get the source code for any Galaxy function
JackieBadger is offline   Reply With Quote
Old 03-25-2013, 11:18 AM   #8
maasha
Senior Member
 
Location: Denmark

Join Date: Apr 2009
Posts: 153
Default

With Biopieces (www.biopieces.org) you can do it in two steps where you first find the mean score per sequence entry and then the overall mean score:

Code:
read_fastq -i test.fq | mean_scores | mean_vals -k SCORES_MEAN -x
maasha is offline   Reply With Quote
Old 03-25-2013, 11:55 AM   #9
jgibbons1
Senior Member
 
Location: Worcester, MA

Join Date: Oct 2009
Posts: 133
Default

Thanks to everyone's suggestions!

I will try a few of these and let you know what I ended up doing.
jgibbons1 is offline   Reply With Quote
Old 04-03-2013, 10:10 AM   #10
jgibbons1
Senior Member
 
Location: Worcester, MA

Join Date: Oct 2009
Posts: 133
Default

For anyone still interested...

For simplicity, I ended up using Bioawk (https://github.com/lh3/bioawk):

Get the mean Phred quality score from FASTQ:
awk -c fastx '{ print ">"$name; print meanqual($qual) }' seq.fq.gz
jgibbons1 is offline   Reply With Quote
Old 07-12-2013, 08:25 AM   #11
xApple
Member
 
Location: Behind you.

Join Date: Feb 2012
Posts: 12
Default

That bioawk command doesn't compute the quality score for the entire file as per the question you originally asked. It computes it for every sequence and floods your standard output.

Here is a program that actually does what you asked.

Code:
#!/usr/bin/env python

"""
Compute the average quality for a given FASTQ file.

Written by Lucas Sinclair.
Kopimi.

You can use this script from the shell like this:
$ fastq_avg_qual < reads.fastq
"""

# Iterative mean #
def imean(numbers):
    count = 0
    total = 0
    for num in numbers:
        count += 1
        total += num
    return float(total)/count

# Do it #
import sys
from Bio import SeqIO
records = (r for r in SeqIO.parse(sys.stdin, "fastq"))
scores = (s for r in records for s in r.letter_annotations["phred_quality"])
print imean(scores)

Last edited by xApple; 07-12-2013 at 08:45 AM.
xApple is offline   Reply With Quote
Old 07-16-2013, 06:42 AM   #12
jgibbons1
Senior Member
 
Location: Worcester, MA

Join Date: Oct 2009
Posts: 133
Default

Thanks xApple. You're right...I ended up taking the average of the quality scores.

I will give your script a shot. Thanks!
jgibbons1 is offline   Reply With Quote
Old 07-16-2013, 02:13 PM   #13
xApple
Member
 
Location: Behind you.

Join Date: Feb 2012
Posts: 12
Default

You're welcome ! It's just a quick hack that has the advantage to not use any memory but suffers from being extremely slow. Probably not suitable for Illumina sized data.
xApple is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 05:04 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO