this.featureType = featureType;
this.longestFeature = new HashMap();
// Gather statistics for setting scales.
boolean isEncodePeak = featureType == EncodePeakFeature.class;
DoubleArrayList signals = isEncodePeak ? new DoubleArrayList(50000) : null;
DoubleArrayList qvalues = isEncodePeak ? new DoubleArrayList(50000) : null;
DoubleArrayList pvalues = isEncodePeak ? new DoubleArrayList(50000) : null;
for (Map.Entry<String, List<BasicFeature>> entry : featureMap.entrySet()) {
String chr = entry.getKey();
List<BasicFeature> features = entry.getValue();
int longest = 0;
for (BasicFeature f : features) {
float s = f.getScore();
hasScore = hasScore || !Float.isNaN(s);
if (isEncodePeak) {
EncodePeakFeature pf = (EncodePeakFeature) f;
signals.add(pf.getSignal());
qvalues.add(pf.getQValue());
pvalues.add(pf.getPValue());
}
final int length = f.getLength();
if (length > longest) longest = length;
}
longestFeature.put(chr, longest);
}
scales = new HashMap<SignalField, Range>();
scales.put(SignalField.Score, new Range(0, 1000));
double[] s = signals.toArray();
double sMin = 0;
double sMax = StatUtils.percentile(s, 90);
scales.put(SignalField.Signal, new Range(sMin, sMax));
double[] q = qvalues.toArray();
scales.put(SignalField.QValue, new Range(0, StatUtils.percentile(q, 90)));
double[] p = pvalues.toArray();
scales.put(SignalField.PValue, new Range(0, StatUtils.percentile(p, 90)));
}