use of uk.ac.babraham.SeqMonk.Gradients.HotColdColourGradient in project SeqMonk by s-andrews.
the class MAPlotPanel method calculateNonredundantSet.
/**
* This collapses individual points which are over the same
* pixel when redrawing the plot at a different scale
*/
private synchronized void calculateNonredundantSet() {
closestPoint = null;
ProbePairValue[][] grid = new ProbePairValue[getWidth()][getHeight()];
Probe[] probes = probeList.getAllProbes();
try {
for (int p = 0; p < probes.length; p++) {
float xValue = (xStore.getValueForProbe(probes[p]) + yStore.getValueForProbe(probes[p])) / 2;
float yValue = xStore.getValueForProbe(probes[p]) - yStore.getValueForProbe(probes[p]);
if (Float.isNaN(xValue) || Float.isInfinite(xValue) || Float.isNaN(yValue) || Float.isInfinite(yValue)) {
continue;
}
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
grid[x][y] = new ProbePairValue(xValue, yValue, x, y);
grid[x][y].setProbe(probes[p]);
} else {
// belong to
if (subLists == null)
grid[x][y].count++;
// As we have multiple probes at this point we remove the
// specific probe annotation.
grid[x][y].setProbe(null);
}
}
if (subLists != null) {
for (int s = 0; s < subLists.length; s++) {
Probe[] subListProbes = subLists[s].getAllProbes();
for (int p = 0; p < subListProbes.length; p++) {
float xValue = (xStore.getValueForProbe(subListProbes[p]) + yStore.getValueForProbe(subListProbes[p])) / 2;
float yValue = xStore.getValueForProbe(subListProbes[p]) - yStore.getValueForProbe(subListProbes[p]);
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
// This messes up where we catch it in the middle of a redraw
continue;
// throw new IllegalArgumentException("Found subList position not in main list");
}
// 1 = no list so 2 is the lowest sublist index
grid[x][y].count = s + 2;
}
}
}
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
// Now we need to put all of the ProbePairValues into
// a single array;
int count = 0;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null)
count++;
}
}
ProbePairValue[] nonred = new ProbePairValue[count];
count--;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null) {
nonred[count] = grid[x][y];
count--;
}
}
}
Arrays.sort(nonred);
// Work out the 95% percentile count
int minCount = 1;
int maxCount = 2;
if (nonred.length > 0) {
minCount = nonred[0].count;
maxCount = nonred[((nonred.length - 1) * 95) / 100].count;
}
// Go through every nonred assigning a suitable colour
ColourGradient gradient = new HotColdColourGradient();
for (int i = 0; i < nonred.length; i++) {
if (subLists == null) {
nonred[i].color = gradient.getColor(nonred[i].count, minCount, maxCount);
} else {
if (nonred[i].count > subLists.length + 1) {
throw new IllegalArgumentException("Count above threshold when showing sublists");
}
if (nonred[i].count == 1) {
nonred[i].color = VERY_LIGHT_GREY;
} else {
nonred[i].color = ColourIndexSet.getColour(nonred[i].count - 2);
}
}
}
nonRedundantValues = nonred;
lastNonredWidth = getWidth();
lastNonredHeight = getHeight();
// System.out.println("Nonred was "+nonRedundantValues.length+" from "+probes.length);
}
use of uk.ac.babraham.SeqMonk.Gradients.HotColdColourGradient in project SeqMonk by s-andrews.
the class PCAScatterPlotPanel method calculateNonredundantSet.
/**
* This collapses individual points which are over the same
* pixel when redrawing the plot at a different scale
*/
private synchronized void calculateNonredundantSet() {
closestPoint = null;
ProbePairValue[][] grid = new ProbePairValue[getWidth()][getHeight()];
int storeCount = data.getStoreCount();
for (int p = 0; p < storeCount; p++) {
float xValue = data.getPCAValue(p, xIndex);
float yValue = data.getPCAValue(p, yIndex);
if (Float.isNaN(xValue) || Float.isInfinite(xValue) || Float.isNaN(yValue) || Float.isInfinite(yValue)) {
continue;
}
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
grid[x][y] = new ProbePairValue(xValue, yValue, x, y);
grid[x][y].setStore(data.getStore(p));
} else {
// belong to
if (highlightedSets == null)
grid[x][y].count++;
// We have multiple probes at this location but we'll leave
// the store set to the first one so we've got something
// to label at least.
// grid[x][y].setStore(null);
}
}
if (highlightedSets != null) {
for (int s = 0; s < highlightedSets.length; s++) {
for (int p = 0; p < storeCount; p++) {
if (highlightedSets[s].containsDataStore(data.getStore(p))) {
float xValue = data.getPCAValue(p, xIndex);
float yValue = data.getPCAValue(p, yIndex);
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
// This messes up where we catch it in the middle of a redraw
continue;
}
// 1 = no list so 2 is the lowest sublist index
grid[x][y].count = s + 2;
}
}
}
}
// Now we need to put all of the ProbePairValues into
// a single array;
int count = 0;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null)
count++;
}
}
ProbePairValue[] nonred = new ProbePairValue[count];
count--;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null) {
nonred[count] = grid[x][y];
count--;
}
}
}
Arrays.sort(nonred);
// Work out the 95% percentile count
int minCount = 1;
int maxCount = 2;
if (nonred.length > 0) {
minCount = nonred[0].count;
maxCount = nonred[((nonred.length - 1) * 95) / 100].count;
}
// Go through every nonred assigning a suitable colour
ColourGradient gradient = new HotColdColourGradient();
for (int i = 0; i < nonred.length; i++) {
if (highlightedSets == null) {
nonred[i].color = gradient.getColor(nonred[i].count, minCount, maxCount);
} else {
if (nonred[i].count > highlightedSets.length + 1) {
throw new IllegalArgumentException("Count above threshold when showing sublists");
}
if (nonred[i].count == 1) {
nonred[i].color = VERY_LIGHT_GREY;
} else {
nonred[i].color = ColourIndexSet.getColour(nonred[i].count - 2);
}
}
}
nonRedundantValues = nonred;
lastNonredWidth = getWidth();
lastNonredHeight = getHeight();
// System.out.println("Nonred was "+nonRedundantValues.length+" from "+probes.length);
}
use of uk.ac.babraham.SeqMonk.Gradients.HotColdColourGradient in project SeqMonk by s-andrews.
the class DisplayPreferences method setGradient.
public void setGradient(int gradientType) {
if (equalsAny(new int[] { GRADIENT_GREYSCALE, GRADIENT_HOT_COLD, GRADIENT_RED_GREEN, GRADIENT_MAGENTA_GREEN, GRADIENT_RED_WHITE }, gradientType)) {
currentGradientValue = gradientType;
switch(gradientType) {
case GRADIENT_GREYSCALE:
currentGradient = new GreyscaleColourGradient();
break;
case GRADIENT_HOT_COLD:
currentGradient = new HotColdColourGradient();
break;
case GRADIENT_RED_GREEN:
currentGradient = new RedGreenColourGradient();
break;
case GRADIENT_MAGENTA_GREEN:
currentGradient = new MagentaGreenColourGradient();
break;
case GRADIENT_RED_WHITE:
currentGradient = new RedWhiteColourGradient();
break;
}
if (invertGradient) {
currentGradient = new InvertedGradient(currentGradient);
}
optionsChanged();
} else {
throw new IllegalArgumentException("Value " + gradientType + " is not a valid gradient type");
}
}
use of uk.ac.babraham.SeqMonk.Gradients.HotColdColourGradient in project SeqMonk by s-andrews.
the class StrandBiasPlotPanel method calculateNonredundantSet.
/**
* This collapses individual points which are over the same
* pixel when redrawing the plot at a different scale
*/
private synchronized void calculateNonredundantSet() {
closestPoint = null;
ProbePairValue[][] grid = new ProbePairValue[getWidth()][getHeight()];
for (int p = 0; p < allValues.length; p++) {
if (allValues[p].count == 0)
continue;
int x = getX(allValues[p].count);
int y = getY(allValues[p].proportion);
if (grid[x][y] == null) {
grid[x][y] = new ProbePairValue(allValues[p].count, allValues[p].proportion, x, y);
grid[x][y].setProbe(allValues[p].probe);
// See if we're assigning a sublist
if (subListProbes.containsKey(allValues[p].probe)) {
grid[x][y].count = subListProbes.get(allValues[p].probe);
}
} else {
// belong to
if (subLists == null)
grid[x][y].count++;
// As we have multiple probes at this point we remove the
// specific probe annotation.
grid[x][y].setProbe(null);
}
}
// Now we need to put all of the ProbePairValues into
// a single array;
int count = 0;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null)
count++;
}
}
ProbePairValue[] nonred = new ProbePairValue[count];
count--;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null) {
nonred[count] = grid[x][y];
count--;
}
}
}
Arrays.sort(nonred);
// Work out the 95% percentile count
int minCount = 1;
int maxCount = 2;
if (nonred.length > 0) {
minCount = nonred[0].count;
maxCount = nonred[((nonred.length - 1) * 95) / 100].count;
}
// Go through every nonred assigning a suitable colour
ColourGradient gradient = new HotColdColourGradient();
for (int i = 0; i < nonred.length; i++) {
if (subLists == null) {
nonred[i].color = gradient.getColor(nonred[i].count, minCount, maxCount);
} else {
if (nonred[i].count > subLists.length + 1) {
throw new IllegalArgumentException("Count above threshold when showing sublists");
}
if (nonred[i].count == 1) {
nonred[i].color = VERY_LIGHT_GREY;
} else {
nonred[i].color = ColourIndexSet.getColour(nonred[i].count - 2);
}
}
}
nonRedundantValues = nonred;
lastNonredWidth = getWidth();
lastNonredHeight = getHeight();
// System.out.println("Nonred was "+nonRedundantValues.length+" from "+probes.length);
}
use of uk.ac.babraham.SeqMonk.Gradients.HotColdColourGradient in project SeqMonk by s-andrews.
the class VariancePlotPanel method calculateNonredundantSet.
/**
* This collapses individual points which are over the same
* pixel when redrawing the plot at a different scale
*/
private synchronized void calculateNonredundantSet() {
closestPoint = null;
ProbePairValue[][] grid = new ProbePairValue[getWidth()][getHeight()];
Probe[] probes = probeList.getAllProbes();
try {
for (int p = 0; p < probes.length; p++) {
float xValue = repSet.getValueForProbeExcludingUnmeasured(probes[p]);
float yValue = getYValue(probes[p]);
if (Float.isNaN(xValue) || Float.isInfinite(xValue) || Float.isNaN(yValue) || Float.isInfinite(yValue)) {
continue;
}
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
grid[x][y] = new ProbePairValue(xValue, yValue, x, y);
grid[x][y].setProbe(probes[p]);
} else {
// belong to
if (subLists == null)
grid[x][y].count++;
// As we have multiple probes at this point we remove the
// specific probe annotation.
grid[x][y].setProbe(null);
}
}
if (subLists != null) {
for (int s = 0; s < subLists.length; s++) {
Probe[] subListProbes = subLists[s].getAllProbes();
for (int p = 0; p < subListProbes.length; p++) {
float xValue = repSet.getValueForProbeExcludingUnmeasured(subListProbes[p]);
float yValue = getYValue(subListProbes[p]);
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
// This messes up where we catch it in the middle of a redraw
continue;
// throw new IllegalArgumentException("Found subList position not in main list");
}
// 1 = no list so 2 is the lowest sublist index
grid[x][y].count = s + 2;
}
}
}
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
// Now we need to put all of the ProbePairValues into
// a single array;
int count = 0;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null)
count++;
}
}
ProbePairValue[] nonred = new ProbePairValue[count];
count--;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null) {
nonred[count] = grid[x][y];
count--;
}
}
}
Arrays.sort(nonred);
// Work out the 95% percentile count
int minCount = 1;
int maxCount = 2;
if (nonred.length > 0) {
minCount = nonred[0].count;
maxCount = nonred[((nonred.length - 1) * 95) / 100].count;
}
// Go through every nonred assigning a suitable colour
ColourGradient gradient = new HotColdColourGradient();
for (int i = 0; i < nonred.length; i++) {
if (subLists == null) {
nonred[i].color = gradient.getColor(nonred[i].count, minCount, maxCount);
} else {
if (nonred[i].count > subLists.length + 1) {
throw new IllegalArgumentException("Count above threshold when showing sublists");
}
if (nonred[i].count == 1) {
nonred[i].color = VERY_LIGHT_GREY;
} else {
nonred[i].color = ColourIndexSet.getColour(nonred[i].count - 2);
}
}
}
nonRedundantValues = nonred;
lastNonredWidth = getWidth();
lastNonredHeight = getHeight();
// System.out.println("Nonred was "+nonRedundantValues.length+" from "+probes.length);
}
Aggregations