use of uk.ac.babraham.SeqMonk.DataTypes.DataSet in project SeqMonk by s-andrews.
the class SubsetNormalisationQuantitation 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("Summation Method"), gbc);
gbc.gridx = 2;
summationActions = new JComboBox(new String[] { "Mean", "Sum" });
optionPanel.add(summationActions, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Target Value"), gbc);
gbc.gridx = 2;
targetActions = new JComboBox(new String[] { "Largest", "1" });
optionPanel.add(targetActions, gbc);
Vector<DataStore> quantitatedStores = new Vector<DataStore>();
DataSet[] sets = application.dataCollection().getAllDataSets();
for (int s = 0; s < sets.length; s++) {
if (sets[s].isQuantitated()) {
quantitatedStores.add(sets[s]);
}
}
DataGroup[] groups = application.dataCollection().getAllDataGroups();
for (int g = 0; g < groups.length; g++) {
if (groups[g].isQuantitated()) {
quantitatedStores.add(groups[g]);
}
}
data = quantitatedStores.toArray(new DataStore[0]);
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.DataSet in project SeqMonk by s-andrews.
the class ManualCorrectionQuantitation 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", "Subtract", "Multiply", "Divide" });
optionPanel.add(correctionActions, gbc);
Vector<DataStore> quantitatedStores = new Vector<DataStore>();
DataSet[] sets = application.dataCollection().getAllDataSets();
for (int s = 0; s < sets.length; s++) {
if (sets[s].isQuantitated()) {
quantitatedStores.add(sets[s]);
}
}
DataGroup[] groups = application.dataCollection().getAllDataGroups();
for (int g = 0; g < groups.length; g++) {
if (groups[g].isQuantitated()) {
quantitatedStores.add(groups[g]);
}
}
data = quantitatedStores.toArray(new DataStore[0]);
correctionFactors = new JTextField[data.length];
// Now we work our way through the sets
JPanel correctionPanel = new JPanel();
correctionPanel.setLayout(new GridBagLayout());
GridBagConstraints cbc = new GridBagConstraints();
cbc.gridx = 1;
cbc.gridy = 1;
cbc.weightx = 0.5;
cbc.weighty = 0.5;
cbc.insets = new Insets(1, 3, 1, 3);
cbc.fill = GridBagConstraints.HORIZONTAL;
for (int d = 0; d < data.length; d++) {
cbc.gridx = 1;
cbc.gridy++;
correctionPanel.add(new JLabel(data[d].name()), cbc);
cbc.gridx = 2;
correctionFactors[d] = new JTextField();
if (storedCorrections.containsKey(data[d].name())) {
correctionFactors[d].setText("" + storedCorrections.get(data[d].name()));
}
correctionFactors[d].addKeyListener(new NumberKeyListener(true, true));
correctionPanel.add(correctionFactors[d], cbc);
}
gbc.gridx = 1;
gbc.gridy++;
gbc.gridwidth = 2;
optionPanel.add(new JLabel("Correction factors", JLabel.CENTER), gbc);
gbc.gridy++;
gbc.weighty = 0.9;
gbc.fill = GridBagConstraints.BOTH;
optionPanel.add(new JScrollPane(correctionPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), gbc);
gbc.gridx = 1;
gbc.gridy++;
gbc.gridwidth = 2;
gbc.weighty = 0.001;
gbc.fill = GridBagConstraints.NONE;
JButton loadFromFileButton = new JButton("Load from file");
loadFromFileButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser(SeqMonkPreferences.getInstance().getDataLocation());
chooser.setMultiSelectionEnabled(false);
chooser.setFileFilter(new TxtFileFilter());
int result = chooser.showOpenDialog(optionPanel);
if (result == JFileChooser.CANCEL_OPTION)
return;
File file = chooser.getSelectedFile();
SeqMonkPreferences.getInstance().setLastUsedDataLocation(file);
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
line.trim();
if (line.startsWith("#"))
continue;
String[] sections = line.split("\t");
if (sections.length < 2)
continue;
if (sections[1].length() == 0)
continue;
// See if we can find a dataset with the name of this section
for (int d = 0; d < data.length; d++) {
if (data[d].name().equals(sections[0])) {
// We try setting the value to whatever is stored for this
try {
Double.parseDouble(sections[1]);
correctionFactors[d].setText(sections[1]);
} catch (NumberFormatException nfe) {
JOptionPane.showMessageDialog(optionPanel, "Skipping " + sections[0] + " as " + sections[1] + " isn't a number", "Correction import error", JOptionPane.WARNING_MESSAGE);
}
}
}
}
br.close();
} catch (IOException ioe) {
JOptionPane.showMessageDialog(optionPanel, "Failed to read input file:" + ioe.getMessage(), "Correction import error", JOptionPane.ERROR_MESSAGE);
return;
}
}
});
optionPanel.add(loadFromFileButton, gbc);
return optionPanel;
}
use of uk.ac.babraham.SeqMonk.DataTypes.DataSet in project SeqMonk by s-andrews.
the class SmoothingSubtractionQuantitation method run.
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
if (!isReady()) {
progressExceptionReceived(new SeqMonkException("Options weren't set correctly"));
}
Chromosome[] chromosomes = application.dataCollection().genome().getAllChromosomes();
Vector<DataStore> quantitatedStores = new Vector<DataStore>();
DataSet[] sets = application.dataCollection().getAllDataSets();
for (int s = 0; s < sets.length; s++) {
if (sets[s].isQuantitated()) {
quantitatedStores.add(sets[s]);
}
}
DataGroup[] groups = application.dataCollection().getAllDataGroups();
for (int g = 0; g < groups.length; g++) {
if (groups[g].isQuantitated()) {
quantitatedStores.add(groups[g]);
}
}
DataStore[] data = quantitatedStores.toArray(new DataStore[0]);
for (int c = 0; c < chromosomes.length; c++) {
// See if we need to quit
if (cancel) {
progressCancelled();
return;
}
progressUpdated(c, chromosomes.length);
Probe[] allProbes = application.dataCollection().probeSet().getProbesForChromosome(chromosomes[c]);
float[][] newValues = new float[data.length][allProbes.length];
try {
for (int p = 0; p < allProbes.length; p++) {
// See if we need to quit
if (cancel) {
progressCancelled();
return;
}
// Find the min and max indices we're going to use.
int minIndex = p;
int maxIndex = p;
if (correctionAction == ADJACENT) {
minIndex = p - (distance / 2);
maxIndex = minIndex + (distance - 1);
if (minIndex < 0)
minIndex = 0;
if (maxIndex > allProbes.length - 1)
maxIndex = allProbes.length - 1;
} else if (correctionAction == WINDOW) {
for (int i = p; i >= 0; i--) {
if (allProbes[i].end() < allProbes[p].start() - (distance / 2)) {
break;
}
minIndex = i;
}
for (int i = p; i < allProbes.length; i++) {
if (allProbes[i].start() > allProbes[p].end() + (distance / 2)) {
break;
}
maxIndex = i;
}
}
// Now go through all of the datasets working out the new value for this range
float[] tempValues = new float[(maxIndex - minIndex) + 1];
for (int d = 0; d < data.length; d++) {
for (int i = minIndex; i <= maxIndex; i++) {
tempValues[i - minIndex] = data[d].getValueForProbe(allProbes[i]);
}
newValues[d][p] = SimpleStats.mean(tempValues);
}
}
// Now assign the values for the probes on this chromosome
for (int d = 0; d < data.length; d++) {
for (int p = 0; p < allProbes.length; p++) {
data[d].setValueForProbe(allProbes[p], data[d].getValueForProbe(allProbes[p]) - newValues[d][p]);
}
}
} catch (SeqMonkException e) {
progressExceptionReceived(e);
}
}
quantitatonComplete();
}
use of uk.ac.babraham.SeqMonk.DataTypes.DataSet in project SeqMonk by s-andrews.
the class PerProbeNormalisationQuantitation 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[] { "Subtract", "Log Divide", "Scale" });
optionPanel.add(correctionActions, gbc);
gbc.gridy++;
gbc.gridx = 1;
optionPanel.add(new JLabel("Averaging Method"), gbc);
gbc.gridx = 2;
averageMethod = new JComboBox(new String[] { "Median", "Mean" });
optionPanel.add(averageMethod, gbc);
Vector<DataStore> quantitatedStores = new Vector<DataStore>();
DataSet[] sets = application.dataCollection().getAllDataSets();
for (int s = 0; s < sets.length; s++) {
if (sets[s].isQuantitated()) {
quantitatedStores.add(sets[s]);
}
}
DataGroup[] groups = application.dataCollection().getAllDataGroups();
for (int g = 0; g < groups.length; g++) {
if (groups[g].isQuantitated()) {
quantitatedStores.add(groups[g]);
}
}
data = quantitatedStores.toArray(new DataStore[0]);
return optionPanel;
}
use of uk.ac.babraham.SeqMonk.DataTypes.DataSet in project SeqMonk by s-andrews.
the class SmoothingQuantitation method run.
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
if (!isReady()) {
progressExceptionReceived(new SeqMonkException("Options weren't set correctly"));
}
Chromosome[] chromosomes = application.dataCollection().genome().getAllChromosomes();
Vector<DataStore> quantitatedStores = new Vector<DataStore>();
DataSet[] sets = application.dataCollection().getAllDataSets();
for (int s = 0; s < sets.length; s++) {
if (sets[s].isQuantitated()) {
quantitatedStores.add(sets[s]);
}
}
DataGroup[] groups = application.dataCollection().getAllDataGroups();
for (int g = 0; g < groups.length; g++) {
if (groups[g].isQuantitated()) {
quantitatedStores.add(groups[g]);
}
}
DataStore[] data = quantitatedStores.toArray(new DataStore[0]);
for (int c = 0; c < chromosomes.length; c++) {
// See if we need to quit
if (cancel) {
progressCancelled();
return;
}
progressUpdated(c, chromosomes.length);
Probe[] allProbes = application.dataCollection().probeSet().getProbesForChromosome(chromosomes[c]);
float[][] newValues = new float[data.length][allProbes.length];
try {
for (int p = 0; p < allProbes.length; p++) {
// See if we need to quit
if (cancel) {
progressCancelled();
return;
}
// Find the min and max indices we're going to use.
int minIndex = p;
int maxIndex = p;
if (correctionAction == ADJACENT) {
minIndex = p - (distance / 2);
maxIndex = minIndex + (distance - 1);
if (minIndex < 0)
minIndex = 0;
if (maxIndex > allProbes.length - 1)
maxIndex = allProbes.length - 1;
} else if (correctionAction == WINDOW) {
for (int i = p; i >= 0; i--) {
if (allProbes[i].end() < allProbes[p].start() - (distance / 2)) {
break;
}
minIndex = i;
}
for (int i = p; i < allProbes.length; i++) {
if (allProbes[i].start() > allProbes[p].end() + (distance / 2)) {
break;
}
maxIndex = i;
}
}
// Now go through all of the datasets working out the new value for this range
float[] tempValues = new float[(maxIndex - minIndex) + 1];
for (int d = 0; d < data.length; d++) {
for (int i = minIndex; i <= maxIndex; i++) {
tempValues[i - minIndex] = data[d].getValueForProbe(allProbes[i]);
}
newValues[d][p] = SimpleStats.mean(tempValues);
}
}
// Now assign the values for the probes on this chromosome
for (int d = 0; d < data.length; d++) {
for (int p = 0; p < allProbes.length; p++) {
data[d].setValueForProbe(allProbes[p], newValues[d][p]);
}
}
} catch (SeqMonkException e) {
progressExceptionReceived(e);
}
}
quantitatonComplete();
}
Aggregations