Search code examples
rmatrixextrapolation

Extrapolate capped values in heat matrix


I have a number of heatmaps (example below), from each of which I extract a value matrix. My problem is that, in the images, values above a certain threshold (in this case 200) are capped at that threshold and shown as a fuschia color. I'm trying to extrapolate these values. I tried replacing 200 with NA and using na.approx and na.spline from the zoo package, approxExtrap from the Hmisc package, as well as using columnwise loess regression. Loess was the only technique that yielded values above 200 at all, but still nowhere near the actual values (I have those for a few images). Any ideas?

heatmap with values above 200 shown as fuschia


Solution

  • Okay, I was able to do this with moderate success using the interp() function from the akima package, using the flags linear = FALSE, extrap = TRUE. It took a full 30 seconds to run per image, performing perfectly on some images, but tending to overestimate when the fuschia region was too large.