MD-Anderson-Bioinformatics / NGCHM-R

An R library for creating Next-Generation Clustered Heat Maps (NG-CHM)
http://bioinformatics.mdanderson.org/main/NG-CHM-V2:Overview
7 stars 3 forks source link

Use more precision for toJSON of singleElement #38

Closed marohrdanz closed 1 year ago

marohrdanz commented 1 year ago

This pull request addresses an issue discovered with closely spaced color map breakpoints. For example: breakpoints 0.00019, 0.00022 will both be written to files in the shaidy repo as 0.0002. When the file is then read in by ShaidyMapGen.jar, the following error is generated: "HEAT MAP PARAMETER ERROR: Supplied Matrix Breakpoint values are not in ascending order", because curValue <= preValue evaluates as TRUE line 114 in InputFile.java in the NGCHM viewer project.

jsonlite::toJSON prints 4 by default (at least with R version 4.3.0 and jsonlite 1.8.4). This pull request uses scientific notation and 7 significant digits. From the documentation for jsonlite::toJSON:

  digits: max number of decimal digits to print for numeric values. Use
          ‘I()’ to specify significant digits. Use ‘NA’ for max
          precision.
marohrdanz commented 1 year ago

On alternative to this PR is to use digits = I(8) for scientific notation. (I tested with ShaidyMapGen and verified it works.)