Search in sources :

Example 16 with DataSet

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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) JLabel(javax.swing.JLabel) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) Vector(java.util.Vector)

Example 17 with DataSet

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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) TxtFileFilter(uk.ac.babraham.SeqMonk.Utilities.FileFilters.TxtFileFilter) JTextField(javax.swing.JTextField) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) FileReader(java.io.FileReader) Vector(java.util.Vector) JScrollPane(javax.swing.JScrollPane) DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) IOException(java.io.IOException) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) BufferedReader(java.io.BufferedReader) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener) File(java.io.File)

Example 18 with DataSet

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();
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Vector(java.util.Vector)

Example 19 with DataSet

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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) JLabel(javax.swing.JLabel) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) Vector(java.util.Vector)

Example 20 with DataSet

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();
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Vector(java.util.Vector)

Aggregations

DataSet (uk.ac.babraham.SeqMonk.DataTypes.DataSet)36 SeqMonkException (uk.ac.babraham.SeqMonk.SeqMonkException)22 DataGroup (uk.ac.babraham.SeqMonk.DataTypes.DataGroup)16 PairedDataSet (uk.ac.babraham.SeqMonk.DataTypes.PairedDataSet)14 File (java.io.File)12 Vector (java.util.Vector)11 DataStore (uk.ac.babraham.SeqMonk.DataTypes.DataStore)11 BufferedReader (java.io.BufferedReader)10 FileReader (java.io.FileReader)10 FileInputStream (java.io.FileInputStream)9 InputStreamReader (java.io.InputStreamReader)9 GZIPInputStream (java.util.zip.GZIPInputStream)9 Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)8 ChromosomeWithOffset (uk.ac.babraham.SeqMonk.Utilities.ChromosomeWithOffset)7 Probe (uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)6 JLabel (javax.swing.JLabel)5 ReplicateSet (uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet)5 IOException (java.io.IOException)4 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3