use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class EnrichmentNormalisationQuantitation method getOptionsPanel.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
*/
public JPanel getOptionsPanel() {
if (optionPanel != null) {
// We've done this already
return optionPanel;
}
optionPanel = new JPanel();
optionPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0.5;
gbc.weighty = 0.1;
gbc.fill = GridBagConstraints.HORIZONTAL;
optionPanel.add(new JLabel("Lower Percentile"), gbc);
lowerPercentileField = new JTextField("" + lowerPercentile);
lowerPercentileField.addKeyListener(new NumberKeyListener(true, false));
gbc.gridx++;
optionPanel.add(lowerPercentileField, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Upper Percentile"), gbc);
gbc.gridx = 2;
upperPercentileField = new JTextField("" + upperPercentile);
upperPercentileField.addKeyListener(new NumberKeyListener(true, false));
optionPanel.add(upperPercentileField, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Ignore unquantitated probes"), gbc);
ignoreUnquantitatedBox = new JCheckBox("", true);
gbc.gridx++;
optionPanel.add(ignoreUnquantitatedBox, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Calculate from probe list"), gbc);
ProbeList[] currentLists = application.dataCollection().probeSet().getAllProbeLists();
calculateFromProbeList = new JComboBox(currentLists);
calculateFromProbeList.setPrototypeDisplayValue("No longer than this please");
for (int i = 0; i < currentLists.length; i++) {
if (currentLists[i] == application.dataCollection().probeSet().getActiveList()) {
calculateFromProbeList.setSelectedIndex(i);
}
}
gbc.gridx++;
optionPanel.add(calculateFromProbeList, gbc);
return optionPanel;
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class HiCPCADomainQuantitation method run.
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
// We're going to go through the probes one chromosome at a time so we
// can reduce the complexity we have to deal with
Chromosome[] chromosomes = application.dataCollection().genome().getAllChromosomes();
for (int c = 0; c < chromosomes.length; c++) {
if (cancel) {
progressCancelled();
return;
}
currentChromosome = chromosomes[c];
Probe[] probes = application.dataCollection().probeSet().getProbesForChromosome(chromosomes[c]);
if (probes.length < 5) {
progressWarningReceived(new SeqMonkException("Too few probes on chromosome " + currentChromosome.name() + " - assigning zero to everything"));
// It's not worth trying to find domains
for (int d = 0; d < data.length; d++) {
for (int p = 0; p < probes.length; p++) {
((DataStore) data[d]).setValueForProbe(probes[p], 0f);
}
}
continue;
}
ProbeList thisChrProbes = new ProbeList(application.dataCollection().probeSet(), chromosomes[c].name(), "", null);
for (int p = 0; p < probes.length; p++) {
thisChrProbes.addProbe(probes[p], 0f);
}
for (int d = 0; d < data.length; d++) {
if (cancel) {
progressCancelled();
return;
}
currentStore = data[d];
current = (d * chromosomes.length) + c;
total = chromosomes.length * data.length;
progressUpdated("Processing chromosome " + chromosomes[c].name() + " for " + data[d].name(), current, total);
HeatmapMatrix matrix = new HeatmapMatrix(data[d], new ProbeList[] { thisChrProbes }, application.dataCollection().genome(), optionsPanel.minDistance(), optionsPanel.maxDistance(), optionsPanel.minStrength(), optionsPanel.maxSignificance(), optionsPanel.minAbsolute(), optionsPanel.correctLinkage());
matrix.addProgressListener(this);
wait = true;
matrix.startCalculating();
while (wait) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
if (cancel) {
progressCancelled();
return;
}
if (matrix.filteredInteractions().length < 10) {
progressWarningReceived(new SeqMonkException("Too few interactions on chromosome " + currentChromosome.name() + " for " + data[d].name() + " - assigning zero to everything"));
// not going to get a sensible answer anyway.
for (int p = 0; p < probes.length; p++) {
((DataStore) data[d]).setValueForProbe(probes[p], 0f);
}
continue;
}
InteractionClusterMatrix clusterMatrix = new InteractionClusterMatrix(matrix.filteredInteractions(), probes.length);
clusterMatrix.addListener(this);
wait = true;
clusterMatrix.startCorrelating();
while (wait) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
float[][] correlationMatrix = clusterMatrix.correlationMatix();
// Annoyingly the PCA needs a double [][]
double[][] correlationMatrixDouble = new double[correlationMatrix.length][];
for (int i = 0; i < correlationMatrix.length; i++) {
double[] db = new double[correlationMatrix[i].length];
for (int j = 0; j < db.length; j++) {
db[j] = correlationMatrix[i][j];
}
correlationMatrixDouble[i] = db;
}
// Now we can calculate the PCA values from the correlation matrix
PCA pca = new PCA(correlationMatrixDouble);
pca.addProgressListener(this);
wait = true;
pca.startCalculating();
while (wait) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
double[] extractedEigenValues = pca.extractedEigenValues();
// for these probes
for (int p = 0; p < probes.length; p++) {
((DataStore) data[d]).setValueForProbe(probes[p], (float) extractedEigenValues[p]);
}
}
thisChrProbes.delete();
}
quantitatonComplete();
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class PercentileNormalisationQuantitation method run.
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
if (!isReady()) {
progressExceptionReceived(new SeqMonkException("Options weren't set correctly"));
}
Probe[] allProbes = application.dataCollection().probeSet().getAllProbes();
Probe[] calculateProbes = ((ProbeList) calculateFromProbeList.getSelectedItem()).getAllProbes();
float[][] percentileValues = new float[data.length][];
float[] minValues = new float[data.length];
// Work out the value at the appropriate percentile
for (int d = 0; d < data.length; d++) {
// Otherwise we'll calculate for each percentage (0-100)
if (autoPercentileBox.isSelected()) {
percentileValues[d] = new float[101];
} else {
percentileValues[d] = new float[1];
}
progressUpdated("Calculating correction for " + data[d].name(), d, data.length);
float[] theseValues = new float[calculateProbes.length];
for (int p = 0; p < calculateProbes.length; p++) {
try {
theseValues[p] = data[d].getValueForProbe(calculateProbes[p]);
} catch (SeqMonkException e) {
progressExceptionReceived(e);
}
}
Arrays.sort(theseValues);
if (autoPercentileBox.isSelected()) {
for (int i = 0; i <= 100; i++) {
// percentileValues[d][i] = theseValues[(int)((theseValues.length-1)*i)/100];
percentileValues[d][i] = getPercentileValue(theseValues, i);
}
} else {
// percentileValues[d][0] = theseValues[(int)((theseValues.length-1)*percentile)/100];
percentileValues[d][0] = getPercentileValue(theseValues, percentile);
}
minValues[d] = theseValues[0];
}
float[] maxPercentiles = new float[percentileValues[0].length];
for (int i = 0; i < percentileValues.length; i++) {
for (int j = 0; j < maxPercentiles.length; j++) {
if (i == 0 || percentileValues[i][j] > maxPercentiles[j]) {
maxPercentiles[j] = percentileValues[i][j];
}
}
}
for (int d = 0; d < data.length; d++) {
// See if we need to quit
if (cancel) {
progressCancelled();
return;
}
progressUpdated(d, data.length);
// Get the correction value
float[] correctionFactors = new float[percentileValues[0].length];
if (correctionAction == ADD) {
for (int i = 0; i < correctionFactors.length; i++) {
correctionFactors[i] = maxPercentiles[i] - percentileValues[d][i];
}
} else if (correctionAction == MULTIPLY) {
for (int i = 0; i < correctionFactors.length; i++) {
correctionFactors[i] = (maxPercentiles[i] - minValues[d]) / (percentileValues[d][i] - minValues[d]);
}
}
// Now we work out the correction factor we're actually going to use
float correctionFactor = SimpleStats.median(correctionFactors);
// Apply the correction to all probes
try {
for (int p = 0; p < allProbes.length; p++) {
// See if we need to quit
if (cancel) {
progressCancelled();
return;
}
if (correctionAction == ADD) {
data[d].setValueForProbe(allProbes[p], data[d].getValueForProbe(allProbes[p]) + correctionFactor);
} else if (correctionAction == MULTIPLY) {
data[d].setValueForProbe(allProbes[p], minValues[d] + ((data[d].getValueForProbe(allProbes[p]) - minValues[d]) * correctionFactor));
}
}
} catch (SeqMonkException e) {
progressExceptionReceived(e);
}
}
quantitatonComplete();
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class PercentileNormalisationQuantitation method getOptionsPanel.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
*/
public JPanel getOptionsPanel() {
if (optionPanel != null) {
// We've done this already
return optionPanel;
}
optionPanel = new JPanel();
optionPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0.5;
gbc.weighty = 0.1;
gbc.fill = GridBagConstraints.HORIZONTAL;
optionPanel.add(new JLabel("Method of correction"), gbc);
gbc.gridx = 2;
correctionActions = new JComboBox(new String[] { "Add", "Multiply" });
optionPanel.add(correctionActions, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Percentile"), gbc);
JPanel percentilePanel = new JPanel();
percentilePanel.setLayout(new BorderLayout());
autoPercentileBox = new JCheckBox("Auto", false);
percentilePanel.add(autoPercentileBox, BorderLayout.WEST);
percentileField = new JTextField("" + percentile);
percentileField.addKeyListener(new NumberKeyListener(true, false));
percentilePanel.add(percentileField, BorderLayout.CENTER);
autoPercentileBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
percentileField.setEnabled(!autoPercentileBox.isSelected());
}
});
gbc.gridx++;
optionPanel.add(percentilePanel, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Ignore unquantitated probes"), gbc);
ignoreUnquantitatedBox = new JCheckBox("", true);
gbc.gridx++;
optionPanel.add(ignoreUnquantitatedBox, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Calculate from probe list"), gbc);
ProbeList[] currentLists = application.dataCollection().probeSet().getAllProbeLists();
calculateFromProbeList = new JComboBox(currentLists);
calculateFromProbeList.setPrototypeDisplayValue("No longer than this please");
for (int i = 0; i < currentLists.length; i++) {
if (currentLists[i] == application.dataCollection().probeSet().getActiveList()) {
calculateFromProbeList.setSelectedIndex(i);
}
}
gbc.gridx++;
optionPanel.add(calculateFromProbeList, gbc);
return optionPanel;
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class DeduplicationProbeGenerator method getOptionsPanel.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.ProbeGenerators.ProbeGenerator#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
*/
public JPanel getOptionsPanel() {
if (optionPanel != null) {
// We've done this already
return optionPanel;
}
optionPanel = new JPanel();
optionPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0.5;
gbc.weighty = 0.5;
gbc.fill = GridBagConstraints.HORIZONTAL;
optionPanel.add(new JLabel("Starting Probe List"), gbc);
gbc.gridx = 2;
if (collection.probeSet() == null) {
probeListBox = new JComboBox(new ProbeList[0]);
} else {
probeListBox = new JComboBox(collection.probeSet().getAllProbeLists());
}
probeListBox.setPrototypeDisplayValue("No longer than this please");
probeListBox.addItemListener(this);
optionPanel.add(probeListBox, gbc);
gbc.gridy++;
gbc.gridx = 1;
optionPanel.add(new JLabel("Merge probes separated by less than (bp)"), gbc);
gbc.gridx = 2;
maxDistanceField = new JTextField("0");
maxDistanceField.addKeyListener(new NumberKeyListener(false, false));
optionPanel.add(maxDistanceField, gbc);
gbc.gridy++;
gbc.gridx = 1;
optionPanel.add(new JLabel("Merge strands separately"), gbc);
gbc.gridx = 2;
separateStrandsBox = new JCheckBox("", true);
optionPanel.add(separateStrandsBox, gbc);
return optionPanel;
}
Aggregations