tmap icon indicating copy to clipboard operation
tmap copied to clipboard

Advice on dealing with nan values for colormaps

Open aparente-nurix opened this issue 5 years ago • 1 comments

I may want to post this issue in the faerun-python github but posting here for now since its relevant to tmap.

I'm creating tmaps for chemical libraries and coloring each structure by various numerical (non-categorical) properties (eg. cLogP). How would you suggest dealing with missing data points (eg. only having some cLogP measurements for some samples)? I tried using np.nan to fill the missing values but the html files come out blank, black background & menu appear but no tree or legend.

It also generates a Runtime Exception when calculating the diff variable in faerun.py because the max/min values yield nan.

RuntimeWarning: invalid value encountered in double_scalars

A couple things I tried in editing faerun.py: Changing the the way diff is calculated to use np.nanmin and np.nanmax removes the runtime warning but still doesn't create the plot correctly. Similarly, trying to set the color for NaN values using cmap.set_bad(color='gray') doesn't work either.

aparente-nurix avatar Dec 12 '19 04:12 aparente-nurix

I'm running into this issue as well. As a temporary workaround, I'm casting the value for NaN data points out of range (for example, setting the value to -1 for a property that's strictly positive), but I agree that there should be a better way to deal with this.

CC @daenuprobst

slochower avatar Mar 13 '20 18:03 slochower