wdecoster / nanomath Goto Github PK
View Code? Open in Web Editor NEWA few simple math function for other Oxford Nanopore processing scripts
License: GNU General Public License v3.0
A few simple math function for other Oxford Nanopore processing scripts
License: GNU General Public License v3.0
Guppy generates FastQ mass values that are one less than those calculated by NanoMath
If the input DataFrame has aligned_reads, also calculate the percentage aligned and the average genome coverage (by dividing aligned bases with the genome size, so somehow this has to get transferred from the BAM to the df).
Hi Wouter,
Thank you for your blog posts on how the average qscores are calculated for nanopore data, I have found them very useful.
When I tried out your aveQual function, I realised that I wasn't getting the correct outcome until I converted q to float, that is :
-10*math.log(sum([10**(float(q)/-10) for q in quals]) / len(quals), 10)
It seems that if q is integer, then the exponent will be rounded up to an integer value.
Best regards,
Laura
The alignment of the general summary isn't very nice.
Instead of
General summary:
Number of reads: 3995
Total bases: 11418359
Median read length: 1221.0
Mean read length: 2858.2
Read length N50: 8676
Active channels: 933
Mean read quality: 10.2
Median read quality: 10.6
I would prefer
General summary:
Number of reads: 3,995
Total bases: 11,418,359
Median read length: 1,221.0
Mean read length: 2,858.2
Read length N50: 8,676
Active channels: 933
Mean read quality: 10.2
Median read quality: 10.6
Or even
General summary:
Number of reads: 3,995
Total bases: 11,418,359
Median read length: 1,221.0
Mean read length: 2,858.2
Read length N50: 8,676
Active channels: 933
Mean read quality: 10.2
Median read quality: 10.6
Hi,
I intend to package nanomath for Debian. Usually I prefer to package tagged releases from github since I frequently observed that downloads on pipy are incomplete. Unfortunately here on Github you do not have any tags while pipy has at least 0.23.1. I'd consider it good style to tag your releases here as well.
The problem becomes obvious when checking the pipy tarball where the LICENSE file is missing. This would be hard to accept for Debian since every software needs a license.
Could you please make sure that the pipy download is complete - or even more preferably could you tag your releases here.
BTW, besides a LICENSE a copyright is missing and I just have to wild guess that the owner of this Github project - Wouter De Coster - is the only copyright holder. Please also specify this.
Thanks a lot, Andreas.
I was trying to rewrite your python function to a julia function. Having exactly the same code, I found out that the outputs were different. After calculating some scores by hand, I came to the conclusion that the python script does some rounding in between because the input quality scores are integers. This can be overcome by replacing:
return -10 * log(sum([10**(q / -10) for q in quals]) / len(quals), 10)
by:
return -10 * log(sum([10**(float(q) / -10) for q in quals]) / len(quals), 10)
Thanks for a nice set of tools. (But the 'off-by-order-of-magnitude' error is annoying)
Hi- based on the reasoning that base quality cannot be directly averaged because they are in log space (here), shouldn't the overall average read quality be converted to probabilities, averaged and converted back to phred score?
I mean, in nanomath.py#L43 there is
self.mean_qual = np.mean(df["quals"])
shouldn't it be:
self.mean_qual = -10 * log(sum(10**(q/-10) for q in df["quals"]]) / len(df["quals"]), 10)
Thanks - Dario
Hi Wouter,
The subject line kind of summarises it already. You may be interested to know about the Debian package we prepared for nanomath as part of the bimonthly Debian Med Covid-19 sprint - I was just about to update the package when the autotests made this noise.
I have no idea if your reverse dependencies are using ave_qual. With version 1.0 you are of course completely free to change your API, but admittedly I wish you'd just formally deprecate it and remove it in, say, 1.1 or so. Would you allow me to comment these lines back in? Or shall I remove the test?
Cheers,
Steffen
I: pybuild base:217: cd /home/moeller/git/med-team/python-nanomath/.pybuild/cpython3_3.8_nanomath/build; python3.8 -m unittest discover -v
test_ave_qual (nanomath.test_nanomath.NanomathTest)
Test average quality calculation. ... ERROR
======================================================================
ERROR: test_ave_qual (nanomath.test_nanomath.NanomathTest)
Test average quality calculation.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/moeller/git/med-team/python-nanomath/.pybuild/cpython3_3.8_nanomath/build/nanomath/test_nanomath.py", line 9, in test_ave_qual
mq = nm.ave_qual(quals, qround=True)
AttributeError: module 'nanomath' has no attribute 'ave_qual'
Hey, can you sync the function name changes with pypi so that I can update package dependencies?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.