// the samples) for raw data files
List<RawDataFile> referenceDataFiles = new ArrayList<RawDataFile>();
List<RawDataFile> nonReferenceDataFiles = new ArrayList<RawDataFile>();
List<String> groups = new ArrayList<String>();
MZmineProject project = MZmineCore.getCurrentProject();
for (RawDataFile rawDataFile : allDataFiles) {
Object paramValue = project.getParameterValue(selectedParameter,
rawDataFile);
if (!groups.contains(String.valueOf(paramValue))) {
groups.add(String.valueOf(paramValue));
}
if (String.valueOf(paramValue).equals(referenceGroup)) {
referenceDataFiles.add(rawDataFile);
} else {
nonReferenceDataFiles.add(rawDataFile);
}
}
int numRows = 0;
for (int row = 0; row < peakList.getNumberOfRows(); row++) {
if (!onlyIdentified
|| (onlyIdentified && peakList.getRow(row)
.getPeakIdentities().length > 0)) {
numRows++;
}
}
// Create a new aligned peak list with all the samples if the reference
// group has to be shown or with only
// the non reference group if not.
double[][] dataMatrix = new double[groups.size() - 1][numRows];
pValueMatrix = new String[groups.size() - 1][numRows];
// data files that should be in the heat map
List<RawDataFile> shownDataFiles = nonReferenceDataFiles;
for (int row = 0, rowIndex = 0; row < peakList.getNumberOfRows(); row++) {
PeakListRow rowPeak = peakList.getRow(row);
if (!onlyIdentified
|| (onlyIdentified && rowPeak.getPeakIdentities().length > 0)) {
// Average area or height of the reference group
meanControlStats.clear();
for (int column = 0; column < referenceDataFiles.size(); column++) {
if (rowPeak.getPeak(referenceDataFiles.get(column)) != null) {
if (area) {
meanControlStats.addValue(rowPeak.getPeak(
referenceDataFiles.get(column)).getArea());
} else {
meanControlStats
.addValue(rowPeak.getPeak(
referenceDataFiles.get(column))
.getHeight());
}
}
}
// Divide the area or height of each peak by the average of the
// area or height of the reference peaks in each row
int columnIndex = 0;
for (int column = 0; column < groups.size(); column++) {
String group = groups.get(column);
meanGroupStats.clear();
if (!group.equals(referenceGroup)) {
for (int dataColumn = 0; dataColumn < shownDataFiles
.size(); dataColumn++) {
Object paramValue = project.getParameterValue(
selectedParameter,
shownDataFiles.get(dataColumn));
if (rowPeak.getPeak(shownDataFiles.get(dataColumn)) != null
&& String.valueOf(paramValue).equals(group)) {