-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scientific notation for large numbers of reads #371
Comments
Yep, I will look into it. |
Any update on this issue? I also think writing large numbers as exact integers is needed, at least as an option. |
@map2085 @hd00ljy Hi, I'm having the same problem with you. Did you find any way around? |
@camelest I tried bamCoverage in deepTools. |
@hd00ljy Thank you so much for the information. I will give it a try! |
@arq5x . what precision do we want for default here? 4, so like |
@brentp @arq5x I think we want something like 1,064,643 (instead of 1.06464e+06). By the way in a different situation when I perform |
oh. right. I was thinking this was a float. I will make a PR. Thanks for following up. |
Thank you so much for your response! |
Hi, care to try out this binary to see if it resolves your issue? Just gunzip, chmod +x and then use as |
@brentp Thank you so much for your prompt response. I checked it but somehow still found "e"... Is it because I'm applying -5 options?
|
Thanks for following up. Indeed, I see why the fix doesn't work. (The ternary must have a fixed type and it still chooses float). |
so we can adjust this by messing with the fmtflags. Here is the test code using the number above from @camelest #include <cstdint>
#include <iostream>
int main() {
double f = 12495300.0;
std::cout << f << std::endl; // 1.24953e+07
std::cout.setf(std::ios_base::fixed);
std::cout << f << std::endl; // 12495300.000000
std::cout.precision(0);
std::cout << f << std::endl; // 123000000
} So, we can safely set to @arq5x you ok with this approach? I would use Or, I could apply fixed and restore default in each function as well. |
There are sections like this in // loop through the depths for the entire genome
// and report the number and fraction of bases in
// the entire genome that are at said depth.
for (histMap::iterator genomeDepthIt = genomeHist.begin(); genomeDepthIt != genomeHist.end(); ++genomeDepthIt) {
int depth = genomeDepthIt->first;
CHRPOS numBasesAtDepth = genomeDepthIt->second;
cout << "genome" << "\t" << depth << "\t" << numBasesAtDepth << "\t"
<< genomeSize << "\t" << (float) ((float)numBasesAtDepth / (float)genomeSize) << endl;
} where we want the floating (or scientfic format) retained. For what I proposed above, we'd always get the float (with apparently 6 decimals of precision) but depending on how we do it, we could get a scientific format in some cases. |
I wonder if moving to |
Integers are printed as expected. The problem is the scale parameter which turns ints into floats even with it is 1.0. This program: #include <cstdint>
#include <iostream>
int main() {
double f = 12495300.0;
int64_t i = 880000000000;
std::cout << f << " i:" << i << std::endl; // 1.24953e+07
std::cout.setf(std::ios_base::fixed);
std::cout << f << " i:" << i << std::endl; // 12495300.000000
std::cout.precision(0);
std::cout << f << " i:" << i << std::endl; // 123000000
} produces this output:
|
I will make a PR that sets precision(0) where appropriate and when scale == 0. It will reset precision to the default after each function call. |
@camelest . I added a test this time for the latest fix, but if you could verify that this works on your data, it would be much appreciated. |
@brentp I tested it and it worked perfect! Thank you so much for your quick solution.
|
command:
bedtools genomecov -d -g genome.size -ibam in.bam > out.cov
genome.size consists of a single RNA "myRNA", length = 8 kb nucleotides.
in.bam contains > 15 million reads aligned to "myRNA".
For some positions on the RNA, there is coverage > 1 million. But in the coverage file out.cov, BEDTOOLS uses scientific notation for the coverage at position with > 1million depth.
ex:
Can BEDTOOLS please be corrected to output the full, exact integer, NOT in exponent notation?
Thank you
The text was updated successfully, but these errors were encountered: