Search in sources :

Example 76 with ProbeList

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.

the class PCADataCalculator method getProbeList.

public ProbeList getProbeList(int pcaIndex, double rotationCutoff) {
    float[] rotations = getPCARotations(pcaIndex);
    IntVector higherIndices = new IntVector();
    IntVector lowerIndices = new IntVector();
    for (int i = 0; i < rotations.length; i++) {
        if (rotations[i] > rotationCutoff) {
            higherIndices.add(i);
        } else {
            lowerIndices.add(i);
        }
    }
    int[] indicesToAdd;
    String direction;
    if (higherIndices.length() > lowerIndices.length()) {
        indicesToAdd = lowerIndices.toArray();
        direction = "below";
    } else {
        indicesToAdd = higherIndices.toArray();
        direction = "above";
    }
    String descriptionDirection;
    if (direction.equals("below")) {
        descriptionDirection = "low";
    } else {
        descriptionDirection = "high";
    }
    ProbeList filteredList = new ProbeList(probeList, "PC" + (pcaIndex + 1) + " " + descriptionDirection + " rotation probes", "Probes from PC" + (pcaIndex + 1) + " with a rotation " + direction + " " + rotationCutoff, "Rotation");
    for (int i = 0; i < indicesToAdd.length; i++) {
        filteredList.addProbe(usedProbes[indicesToAdd[i]], rotations[indicesToAdd[i]]);
    }
    return filteredList;
}
Also used : IntVector(uk.ac.babraham.SeqMonk.Utilities.IntVector) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)

Example 77 with ProbeList

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.

the class ScatterPlotPanel method getFilteredProbes.

/**
 * Gets the filtered probes.
 *
 * @param probeset the probeset
 * @return the filtered probes
 */
public ProbeList getFilteredProbes(ProbeSet probeset) {
    double minDiff = Math.min(diffStart, diffEnd);
    double maxDiff = Math.max(diffStart, diffEnd);
    ProbeList list = new ProbeList(probeList, "Difference between " + df.format(minDiff) + " and " + df.format(maxDiff), "Difference between " + xStore.name() + " and " + yStore.name() + " was between " + df.format(minDiff) + " and " + df.format(maxDiff), null);
    if (madeSelection) {
        Probe[] probes = probeList.getAllProbes();
        for (int p = 0; p < probes.length; p++) {
            try {
                double diff = xStore.getValueForProbe(probes[p]) - yStore.getValueForProbe(probes[p]);
                if (diff < minDiff)
                    continue;
                if (diff > maxDiff)
                    continue;
                list.addProbe(probes[p], null);
            } catch (SeqMonkException e) {
                e.printStackTrace();
            }
        }
    }
    return list;
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)

Example 78 with ProbeList

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.

the class HeatmapGenomeWindow method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("close")) {
        setVisible(false);
        dispose();
    } else if (ae.getActionCommand().equals("save_image")) {
        ImageSaver.saveImage(heatmapPanel);
    } else if (ae.getActionCommand().equals("cluster")) {
        if (clusterButton.getText().equals("Cluster Interactions")) {
            // First we need to make up an interaction cluster matrix which we
            // can then feed to the generic hierarchical clustering program
            InteractionClusterMatrix clusterMatrix = new InteractionClusterMatrix(matrix.filteredInteractions(), matrix.probeCount());
            clusterMatrix.addListener(new ProgressDialog(this, "HiC Interaction Clustering", clusterMatrix));
            clusterMatrix.addListener(this);
            clusterMatrix.startCorrelating();
            clusterButton.setEnabled(false);
        } else {
            matrix.setCluster(null);
            saveClustersButton.setEnabled(false);
            clusterButton.setText("Cluster Interactions");
        }
    } else if (ae.getActionCommand().equals("save_probes")) {
        ProbeList newList = matrix.createProbeListFromCurrentInteractions();
        // Ask for a name for the list
        String groupName = null;
        while (true) {
            groupName = (String) JOptionPane.showInputDialog(this, "Enter list name", "Found " + newList.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, newList.name());
            if (groupName == null) {
                // Since the list will automatically have been added to
                // the ProbeList tree we actively need to delete it if
                // they choose to cancel at this point.
                newList.delete();
                // They cancelled
                return;
            }
            if (groupName.length() == 0)
                // Try again
                continue;
            break;
        }
        newList.setName(groupName);
    } else if (ae.getActionCommand().equals("save_clusters")) {
        if (matrix.cluster() == null)
            return;
        // Get a limit for how many probes per cluster
        String howManyProbes = JOptionPane.showInputDialog(this, "Minimum number of probes per cluster", "10");
        if (howManyProbes == null)
            return;
        int minProbes;
        try {
            minProbes = Integer.parseInt(howManyProbes);
        } catch (NumberFormatException nfe) {
            JOptionPane.showMessageDialog(this, howManyProbes + " was not an integer", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        ProbeList newList = matrix.createProbeListsFromClusters(minProbes, heatmapPanel.genomePanel().currentYStartIndex(), heatmapPanel.genomePanel().currentYEndIndex());
        // This was called before clustering had completed.
        if (newList == null)
            return;
        // Ask for a name for the list
        String groupName = null;
        while (true) {
            groupName = (String) JOptionPane.showInputDialog(this, "Enter list name", "Found " + newList.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, newList.name());
            if (groupName == null) {
                // Since the list will automatically have been added to
                // the ProbeList tree we actively need to delete it if
                // they choose to cancel at this point.
                newList.delete();
                // They cancelled
                return;
            }
            if (groupName.length() == 0)
                // Try again
                continue;
            break;
        }
        newList.setName(groupName);
    } else if (ae.getActionCommand().equals("send_x")) {
        DisplayPreferences.getInstance().setLocation(xChr, SequenceRead.packPosition(xStart, xEnd, Location.UNKNOWN));
    } else if (ae.getActionCommand().equals("send_y")) {
        DisplayPreferences.getInstance().setLocation(yChr, SequenceRead.packPosition(yStart, yEnd, Location.UNKNOWN));
    } else if (ae.getActionCommand().equals("match")) {
        Chromosome chr = DisplayPreferences.getInstance().getCurrentChromosome();
        int start = SequenceRead.start(DisplayPreferences.getInstance().getCurrentLocation());
        int end = SequenceRead.end(DisplayPreferences.getInstance().getCurrentLocation());
        heatmapPanel.genomePanel().setCurrentPosition(chr, start, end);
    } else if (ae.getActionCommand().equals("make_report")) {
        new InteractionReportOptions(SeqMonkApplication.getInstance(), new AnnotatedInteractionReport(SeqMonkApplication.getInstance().dataCollection(), matrix));
    }
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) InteractionClusterMatrix(uk.ac.babraham.SeqMonk.DataTypes.Interaction.InteractionClusterMatrix) InteractionReportOptions(uk.ac.babraham.SeqMonk.Displays.Report.InteractionReport.InteractionReportOptions) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) ProgressDialog(uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog) AnnotatedInteractionReport(uk.ac.babraham.SeqMonk.Reports.Interaction.AnnotatedInteractionReport)

Example 79 with ProbeList

use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.

the class VariancePlotPanel method getFilteredProbes.

/**
 * Gets the filtered probes.
 *
 * @param probeset the probeset
 * @return the filtered probes
 */
public ProbeList getFilteredProbes(ProbeSet probeset) {
    double minDiff = Math.min(diffStart, diffEnd);
    double maxDiff = Math.max(diffStart, diffEnd);
    String varianceName = "Standard Deviation";
    switch(varianceMeasure) {
        case VARIANCE_COEF:
            {
                varianceName = "Coefficient of variation";
                break;
            }
        case VARIANCE_SEM:
            {
                varianceName = "Standard error of the mean";
                break;
            }
        case VARIANCE_QUARTILE_DISP:
            {
                varianceName = "Quartile dispersion";
                break;
            }
        case VARIANCE_NUMBER_UNMEASURED:
            {
                varianceName = "Number of unmeasured data stores";
                break;
            }
    }
    ProbeList list = new ProbeList(probeList, varianceName + " difference between " + df.format(minDiff) + " and " + df.format(maxDiff), varianceName + " difference in " + repSet.name() + " was between " + df.format(minDiff) + " and " + df.format(maxDiff), varianceName + " diff");
    if (madeSelection) {
        Probe[] probes = probeList.getAllProbes();
        for (int p = 0; p < probes.length; p++) {
            try {
                float varianceMeasure = getYValue(probes[p]);
                double diff = varianceMeasure - smoothedTrend.getSmoothedValueForX(repSet.getValueForProbeExcludingUnmeasured(probes[p]));
                if (diff < minDiff)
                    continue;
                if (diff > maxDiff)
                    continue;
                list.addProbe(probes[p], new Float(diff));
            } catch (SeqMonkException e) {
                e.printStackTrace();
            }
        }
    }
    return list;
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)

Aggregations

ProbeList (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)79 Probe (uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)54 SeqMonkException (uk.ac.babraham.SeqMonk.SeqMonkException)32 Vector (java.util.Vector)16 DataStore (uk.ac.babraham.SeqMonk.DataTypes.DataStore)15 Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)12 HashSet (java.util.HashSet)10 JLabel (javax.swing.JLabel)8 ProbeTTestValue (uk.ac.babraham.SeqMonk.Analysis.Statistics.ProbeTTestValue)8 GridBagConstraints (java.awt.GridBagConstraints)7 GridBagLayout (java.awt.GridBagLayout)7 File (java.io.File)7 JComboBox (javax.swing.JComboBox)7 JPanel (javax.swing.JPanel)7 BufferedReader (java.io.BufferedReader)6 FileReader (java.io.FileReader)6 PrintWriter (java.io.PrintWriter)6 JCheckBox (javax.swing.JCheckBox)6 ProgressRecordDialog (uk.ac.babraham.SeqMonk.Dialogs.ProgressRecordDialog)6 RProgressListener (uk.ac.babraham.SeqMonk.R.RProgressListener)6