You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seem to be NaN as value when choose to dump in JSON format i.e. --data-format json. This is of course invalid as JSON value. Please see attached screenshot. And error condition for use case such as when trying to insert MultiQC data straight into MySQL table as JSON data type. Report itself render no issue. I can also report that this happen on SnpEff toolbox / plot data.
I also note that, in Python json.dumpsallowed NaN by default. For better, it should allow_nan=False to conform with JSON format, I suppose.
We have post-processing step for MultiQC data ingestion. Do you recommend setting NaN to null if we handle during processing?
I wonder if we could somehow lure @pcingola (main dev of snpEff AFAICT) to drop the use of NaN in snpEff and instead use a very large number to stay within the designated schema type:
That'd solve the issue(s) we are seeing here with Python's JSON serialization where the data type for several fields flips from Double to something that JSON parsers do not accept as Double (because NaN isn't Double anymore).
Please note that turning NaN into a string is not a good solution either for the aforementioned reasons... also two different NaNs are not even equal between each other, which is semantically even worse ;)
Do you recommend setting NaN to null if we handle during processing?
I guess that this is the best solution.. The Stack Overflow post you linked to has a comment saying that the simplejson package can do this conversion, instead of just falling over with a ValueError.
If it's only a limited number of modules doing this (just SnpEff?) then the easiest solution would probably be to get the module code to replace NaN with None, which will then be serialised to null in the JSON.
I'd like to +1 the suggestion of changing these to null. I think there's always going to be a risk that modules output NaN (intentionally or otherwise), but we never want invalid JSON to be output.
If your issue is with TidyMultiqc, refer to the issue here: multimeric/TidyMultiqc#9. I have one proposed solution, but it hasn't been confirmed to work.
Activity
cmatKhan commentedon Sep 5, 2021
What did you do? replace NaN with some known nonsense number in the JSON?
brainstorm commentedon Sep 8, 2021
I wonder if we could somehow lure @pcingola (main dev of snpEff AFAICT) to drop the use of
NaNin snpEff and instead use a very large number to stay within the designated schema type:https://github.com/pcingola/SnpEff/search?p=1&q=NaN
That'd solve the issue(s) we are seeing here with Python's JSON serialization where the data type for several fields flips from
Doubleto something that JSON parsers do not accept asDouble(becauseNaNisn'tDoubleanymore).Please note that turning
NaNinto a string is not a good solution either for the aforementioned reasons... also two differentNaNs are not even equal between each other, which is semantically even worse ;)/cc @reisingerf @ohofmann @andrewpatto
ewels commentedon Jan 27, 2022
I guess that this is the best solution.. The Stack Overflow post you linked to has a comment saying that the
simplejsonpackage can do this conversion, instead of just falling over with aValueError.If it's only a limited number of modules doing this (just SnpEff?) then the easiest solution would probably be to get the module code to replace
NaNwithNone, which will then be serialised tonullin the JSON.multimeric commentedon Jun 7, 2022
It's not just SnpEff. I'm getting error reports (multimeric/TidyMultiqc#9 and multimeric/TidyMultiqc#6), which suggest that the following fields are often NaN:
mapped_failed_pctproperly paired_failed_pctproperly paired_passed_pctsingletons_failed_pctsingletons_passed_pctI think these are all from the
samtoolsmodule.I'd like to +1 the suggestion of changing these to
null. I think there's always going to be a risk that modules output NaN (intentionally or otherwise), but we never want invalid JSON to be output.ewels commentedon Jun 7, 2022
Ok, thanks @multimeric. This is best done within the general function that saves JSON outputs then I think. Then it will apply for all modules.
loukesio commentedon Oct 11, 2022
Hello all,
Have you found a solution in the meantime, running the
i am still getting the same error as @ewels
multimeric commentedon Oct 11, 2022
If your issue is with
TidyMultiqc, refer to the issue here: multimeric/TidyMultiqc#9. I have one proposed solution, but it hasn't been confirmed to work.edmundmiller commentedon Nov 21, 2023
https://stackoverflow.com/questions/6601812/sending-nan-in-json Just ran into this. Might get cleaned up in #1790 anyways 🙃
vladsavelyev commentedon Mar 8, 2024
Too bad the standard JSON module doesn't take a custom handler for that :( I didn't want to add simplejson, so just went with a hack: #2432
ewels commentedon Mar 14, 2024
Thank you everyone for your patience! Hopefully this is now finally fixed..