Search in sources :

Example 11 with ProbeList

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

the class RunningWindowProbeGenerator method designPerProbe.

private ProbeSet designPerProbe() {
    Chromosome[] chromosomes = collection.genome().getAllChromosomes();
    ProbeList activeList;
    if (limitRegionBox.getSelectedItem().equals("Active Probe List")) {
        activeList = collection.probeSet().getActiveList();
    } else {
        // We're just analysing a single probe over the current region
        existingListName = "Currently visible region";
        Probe p = new Probe(DisplayPreferences.getInstance().getCurrentChromosome(), DisplayPreferences.getInstance().getCurrentLocation());
        activeList = new ProbeSet("Current Region", 1);
        activeList.addProbe(p, 0f);
    }
    Vector<Probe> newProbes = new Vector<Probe>();
    for (int c = 0; c < chromosomes.length; c++) {
        // Time for an update
        updateGenerationProgress("Processed " + c + " chromosomes", c, chromosomes.length);
        Probe[] probes = activeList.getProbesForChromosome(chromosomes[c]);
        for (int p = 0; p < probes.length; p++) {
            int pos = probes[p].start();
            while (pos < probes[p].end() - (probeSize - 1)) {
                // See if we need to quit
                if (cancel) {
                    generationCancelled();
                }
                int end = pos + (probeSize - 1);
                if (end > chromosomes[c].length())
                    end = chromosomes[c].length();
                Probe pr = new Probe(chromosomes[c], pos, end, probes[p].strand());
                newProbes.add(pr);
                pos += stepSize;
            }
        }
    }
    Probe[] finalList = newProbes.toArray(new Probe[0]);
    ProbeSet finalSet = new ProbeSet(getDescription(), finalList);
    return finalSet;
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector)

Example 12 with ProbeList

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

the class InterstitialProbeGenerator 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("Make probes at the end of each chromosome"), gbc);
    gbc.gridx = 2;
    makeEndProbesBox = new JCheckBox("", makeEndProbes);
    optionPanel.add(makeEndProbesBox, gbc);
    return optionPanel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) JLabel(javax.swing.JLabel)

Example 13 with ProbeList

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

the class CodonBiasPipeline method startPipeline.

protected void startPipeline() {
    // We first need to generate probes over all of the features listed in
    // the feature types.  The probes should cover the whole area of the
    // feature regardless of where it splices.
    Vector<Probe> probes = new Vector<Probe>();
    double pValue = optionsPanel.pValue();
    String libraryType = optionsPanel.libraryType();
    Chromosome[] chrs = collection().genome().getAllChromosomes();
    for (int c = 0; c < chrs.length; c++) {
        if (cancel) {
            progressCancelled();
            return;
        }
        progressUpdated("Making probes for chr" + chrs[c].name(), c, chrs.length * 2);
        Feature[] features = collection().genome().annotationCollection().getFeaturesForType(chrs[c], optionsPanel.getSelectedFeatureType());
        for (int f = 0; f < features.length; f++) {
            if (cancel) {
                progressCancelled();
                return;
            }
            Probe p = new Probe(chrs[c], features[f].location().start(), features[f].location().end(), features[f].location().strand(), features[f].name());
            probes.add(p);
        }
    }
    allProbes = probes.toArray(new Probe[0]);
    collection().setProbeSet(new ProbeSet("Features over " + optionsPanel.getSelectedFeatureType(), allProbes));
    // Now we can quantitate each individual feature and test for whether it is significantly
    // showing codon bias
    ArrayList<Vector<ProbeTTestValue>> significantProbes = new ArrayList<Vector<ProbeTTestValue>>();
    // data contains the data stores that this pipeline is going to use. We need to test each data store.
    for (int d = 0; d < data.length; d++) {
        significantProbes.add(new Vector<ProbeTTestValue>());
    }
    int probeCounter = 0;
    for (int c = 0; c < chrs.length; c++) {
        if (cancel) {
            progressCancelled();
            return;
        }
        progressUpdated("Quantitating features on chr" + chrs[c].name(), chrs.length + c, chrs.length * 2);
        Feature[] features = collection().genome().annotationCollection().getFeaturesForType(chrs[c], optionsPanel.getSelectedFeatureType());
        for (int p = 0; p < features.length; p++) {
            // Get the corresponding feature and work out the mapping between genomic position and codon sub position.
            int[] mappingArray = createGenomeMappingArray(features[p]);
            DATASTORE_LOOP: for (int d = 0; d < data.length; d++) {
                if (cancel) {
                    progressCancelled();
                    return;
                }
                long[] reads = data[d].getReadsForProbe(allProbes[probeCounter]);
                // TODO: make this configurable
                if (reads.length < 5) {
                    data[d].setValueForProbe(allProbes[probeCounter], Float.NaN);
                    continue DATASTORE_LOOP;
                }
                int pos1Count = 0;
                int pos2Count = 0;
                int pos3Count = 0;
                READ_LOOP: for (int r = 0; r < reads.length; r++) {
                    int genomicReadStart = SequenceRead.start(reads[r]);
                    int genomicReadEnd = SequenceRead.end(reads[r]);
                    int readStrand = SequenceRead.strand(reads[r]);
                    int relativeReadStart = -1;
                    // forward reads
                    if (readStrand == 1) {
                        if (libraryType == "Same strand specific") {
                            if (features[p].location().strand() == Location.FORWARD) {
                                // The start of the read needs to be within the feature
                                if (genomicReadStart - features[p].location().start() < 0) {
                                    continue READ_LOOP;
                                } else {
                                    // look up the read start pos in the mapping array
                                    relativeReadStart = mappingArray[genomicReadStart - features[p].location().start()];
                                }
                            }
                        } else if (libraryType == "Opposing strand specific") {
                            if (features[p].location().strand() == Location.REVERSE) {
                                // The "start" of a reverse read/probe is actually the end
                                if (features[p].location().end() - genomicReadEnd < 0) {
                                    continue READ_LOOP;
                                } else {
                                    relativeReadStart = mappingArray[features[p].location().end() - genomicReadEnd];
                                }
                            }
                        }
                    }
                    // reverse reads
                    if (readStrand == -1) {
                        if (libraryType == "Same strand specific") {
                            if (features[p].location().strand() == Location.REVERSE) {
                                if (features[p].location().end() - genomicReadEnd < 0) {
                                    continue READ_LOOP;
                                } else {
                                    // System.out.println("features[p].location().end() is " + features[p].location().end() + ", genomicReadEnd is " + genomicReadEnd);
                                    // System.out.println("mapping array[0] is " + mappingArray[0]);
                                    relativeReadStart = mappingArray[features[p].location().end() - genomicReadEnd];
                                }
                            }
                        } else if (libraryType == "Opposing strand specific") {
                            if (features[p].location().strand() == Location.FORWARD) {
                                // The start of the read needs to be within the feature
                                if (genomicReadStart - features[p].location().start() < 0) {
                                    continue READ_LOOP;
                                } else {
                                    // look up the read start position in the mapping array
                                    relativeReadStart = mappingArray[genomicReadStart - features[p].location().start()];
                                }
                            }
                        }
                    }
                    // find out which position the read is in
                    if (relativeReadStart == -1) {
                        continue READ_LOOP;
                    } else if (relativeReadStart % 3 == 0) {
                        pos3Count++;
                        continue READ_LOOP;
                    } else if ((relativeReadStart + 1) % 3 == 0) {
                        pos2Count++;
                        continue READ_LOOP;
                    } else if ((relativeReadStart + 2) % 3 == 0) {
                        pos1Count++;
                    }
                }
                // closing bracket for read loop
                // System.out.println("pos1Count for "+ features[p].name() + " is " + pos1Count);
                // System.out.println("pos2Count for "+ features[p].name() + " is " + pos2Count);
                // System.out.println("pos3Count for "+ features[p].name() + " is " + pos3Count);
                int interestingCodonCount = 0;
                int otherCodonCount = 0;
                if (optionsPanel.codonSubPosition() == 1) {
                    interestingCodonCount = pos1Count;
                    otherCodonCount = pos2Count + pos3Count;
                } else if (optionsPanel.codonSubPosition() == 2) {
                    interestingCodonCount = pos2Count;
                    otherCodonCount = pos1Count + pos3Count;
                } else if (optionsPanel.codonSubPosition() == 3) {
                    interestingCodonCount = pos3Count;
                    otherCodonCount = pos1Count + pos2Count;
                }
                int totalCount = interestingCodonCount + otherCodonCount;
                // BinomialDistribution bd = new BinomialDistribution(interestingCodonCount+otherCodonCount, 1/3d);
                BinomialDistribution bd = new BinomialDistribution(totalCount, 1 / 3d);
                // Since the binomial distribution gives the probability of getting a value higher than
                // this we need to subtract one so we get the probability of this or higher.
                double thisPValue = 1 - bd.cumulativeProbability(interestingCodonCount - 1);
                if (interestingCodonCount == 0)
                    thisPValue = 1;
                // We have to add all results at this stage so we don't mess up the multiple
                // testing correction later on.
                significantProbes.get(d).add(new ProbeTTestValue(allProbes[probeCounter], thisPValue));
                float percentageCount;
                if (totalCount == 0) {
                    percentageCount = 0;
                } else {
                    percentageCount = ((float) interestingCodonCount / (float) totalCount) * 100;
                }
                data[d].setValueForProbe(allProbes[probeCounter], percentageCount);
            // System.out.println("totalCount = " + totalCount);
            // System.out.println("interestingCodonCount " + interestingCodonCount);
            // System.out.println("pValue = " + thisPValue);
            // System.out.println("percentageCount = " + percentageCount);
            // System.out.println("");
            }
            probeCounter++;
        }
    }
    // filtering those which pass our p-value cutoff
    for (int d = 0; d < data.length; d++) {
        ProbeTTestValue[] ttestResults = significantProbes.get(d).toArray(new ProbeTTestValue[0]);
        BenjHochFDR.calculateQValues(ttestResults);
        ProbeList newList = new ProbeList(collection().probeSet(), "Codon bias < " + pValue + " in " + data[d].name(), "Probes showing significant codon bias for position " + optionsPanel.codonSubPosition() + " with a cutoff of " + pValue, "FDR");
        for (int i = 0; i < ttestResults.length; i++) {
            if (ttestResults[i].q < pValue) {
                newList.addProbe(ttestResults[i].probe, (float) ttestResults[i].q);
            }
        }
    }
    StringBuffer quantitationDescription = new StringBuffer();
    quantitationDescription.append("Codon bias pipeline using codon position " + optionsPanel.codonSubPosition() + " for " + optionsPanel.libraryType() + " library.");
    collection().probeSet().setCurrentQuantitation(quantitationDescription.toString());
    quantitatonComplete();
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) ArrayList(java.util.ArrayList) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Feature(uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature) ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) ProbeTTestValue(uk.ac.babraham.SeqMonk.Analysis.Statistics.ProbeTTestValue) BinomialDistribution(org.apache.commons.math3.distribution.BinomialDistribution) Vector(java.util.Vector)

Example 14 with ProbeList

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

the class SeqMonkMenu method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    String action = ae.getActionCommand();
    if (action.equals("exit")) {
        application.dispose();
    } else if (action.equals("new")) {
        application.startNewProject();
    } else if (action.equals("import_other")) {
        JOptionPane.showMessageDialog(application, "SeqMonk can be extended to support other file formats.\n\nIf you'd like support for the format you use then please contact the program authors\nand provide them with example data files so they can write the appropriate import filters.", "Import other formats", JOptionPane.INFORMATION_MESSAGE);
    } else if (action.equals("import_generic")) {
        application.importData(new GenericSeqReadParser(application.dataCollection()));
    } else if (action.equals("import_bed")) {
        application.importData(new BedFileParser(application.dataCollection()));
    } else if (action.equals("import_bedpe")) {
        application.importData(new BedPEFileParser(application.dataCollection()));
    } else if (action.equals("import_bowtie")) {
        application.importData(new BowtieFileParser(application.dataCollection()));
    } else if (action.equals("import_bismark_cov")) {
        application.importData(new BismarkCovFileParser(application.dataCollection()));
    } else if (action.equals("import_quasr")) {
        application.importData(new QuasRFileParser(application.dataCollection()));
    } else if (action.equals("import_methylkit")) {
        application.importData(new MethylKitFileParser(application.dataCollection()));
    } else if (action.equals("import_gff")) {
        application.importData(new GffFileParser(application.dataCollection()));
    } else if (action.equals("import_seqmonk")) {
        application.importData(new SeqMonkReimportParser(application.dataCollection()));
    } else if (action.equals("import_bam")) {
        application.importData(new BAMFileParser(application.dataCollection()));
    } else if (action.equals("import_visible_stores")) {
        if (application.drawnDataStores() == null || application.drawnDataStores().length == 0) {
            JOptionPane.showMessageDialog(application, "You need to have some data stores visible before you can use this option", "Can't reimport data", JOptionPane.ERROR_MESSAGE);
            return;
        }
        application.importData(new VisibleStoresParser(application));
    } else if (action.equals("import_active_probes")) {
        if (application.dataCollection().probeSet() == null) {
            JOptionPane.showMessageDialog(application, "You don't have any active probes to import at the moment", "Can't import data", JOptionPane.ERROR_MESSAGE);
            return;
        }
        application.importData(new ActiveProbeListParser(application));
    } else if (action.equals("import_hic")) {
        DataStore[] drawnStores = application.drawnDataStores();
        boolean foundHic = false;
        for (int i = 0; i < drawnStores.length; i++) {
            if (drawnStores[i] instanceof HiCDataStore && ((HiCDataStore) drawnStores[i]).isValidHiC()) {
                foundHic = true;
            }
        }
        if (!foundHic) {
            JOptionPane.showMessageDialog(application, "You need to have at least one visible HiC data set to use this option", "Can't import HiC data", JOptionPane.ERROR_MESSAGE);
            return;
        }
        application.importData(new HiCOtherEndExtractor(application.dataCollection(), application.drawnDataStores()));
    } else if (action.equals("annot_gff")) {
        AnnotationParserRunner.RunAnnotationParser(application, new GFF3AnnotationParser(application.dataCollection().genome()));
    } else if (action.equals("annot_generic")) {
        AnnotationParserRunner.RunAnnotationParser(application, new GenericAnnotationParser(application.dataCollection().genome()));
    } else if (action.equals("annot_probe")) {
        if (application.dataCollection().probeSet() == null) {
            JOptionPane.showMessageDialog(application, "You haven't made a probeset yet (Do Data > Quantitation > Define Probes)", "Can't make new annotation", JOptionPane.ERROR_MESSAGE);
            return;
        }
        String featureType = null;
        while (true) {
            featureType = (String) JOptionPane.showInputDialog(application, "Enter new feature type", "Set feature type", JOptionPane.QUESTION_MESSAGE, null, null, application.dataCollection().probeSet().getActiveList().name());
            if (featureType == null)
                // They cancelled
                return;
            if (featureType.length() == 0)
                // Try again
                continue;
            break;
        }
        AnnotationParserRunner.RunAnnotationParser(application, new ProbeListAnnotationParser(application.dataCollection().genome(), application.dataCollection().probeSet().getActiveList(), featureType));
    } else if (action.equals("about")) {
        new AboutDialog();
    } else if (action.equals("help_license")) {
        try {
            new LicenseDialog(application);
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (action.equals("help_contents")) {
        try {
            // Java has a bug in it which affects the creation of valid URIs from
            // URLs relating to an windows UNC path.  We therefore have to mung
            // URLs starting file file:// to add 5 forward slashes so that we
            // end up with a valid URI.
            URL url = ClassLoader.getSystemResource("Help");
            if (url.toString().startsWith("file://")) {
                try {
                    url = new URL(url.toString().replace("file://", "file://///"));
                } catch (MalformedURLException e) {
                    throw new IllegalStateException(e);
                }
            }
            new HelpDialog(new File(url.toURI()));
        } catch (URISyntaxException ux) {
            System.err.println("Couldn't parse URL falling back to path");
            new HelpDialog(new File(ClassLoader.getSystemResource("Help").getPath()));
        }
    } else if (action.equals("zoom_in")) {
        application.chromosomeViewer().zoomIn();
    } else if (action.equals("zoom_out")) {
        application.chromosomeViewer().zoomOut();
    } else if (action.equals("move_left")) {
        application.chromosomeViewer().moveLeft();
    } else if (action.equals("move_right")) {
        application.chromosomeViewer().moveRight();
    } else if (action.equals("page_left")) {
        application.chromosomeViewer().pageLeft();
    } else if (action.equals("page_right")) {
        application.chromosomeViewer().pageRight();
    } else if (action.equals("view_display_options")) {
        new DisplayPreferencesEditorDialog();
    } else if (action.equals("data_reads_probes")) {
        DisplayPreferences.getInstance().setDisplayMode(DisplayPreferences.DISPLAY_MODE_READS_AND_QUANTITATION);
    } else if (action.equals("data_reads")) {
        DisplayPreferences.getInstance().setDisplayMode(DisplayPreferences.DISPLAY_MODE_READS_ONLY);
    } else if (action.equals("data_probes")) {
        DisplayPreferences.getInstance().setDisplayMode(DisplayPreferences.DISPLAY_MODE_QUANTITATION_ONLY);
    } else if (action.equals("read_density_low")) {
        DisplayPreferences.getInstance().setReadDensity(DisplayPreferences.READ_DENSITY_LOW);
    } else if (action.equals("read_density_medium")) {
        DisplayPreferences.getInstance().setReadDensity(DisplayPreferences.READ_DENSITY_MEDIUM);
    } else if (action.equals("read_density_high")) {
        DisplayPreferences.getInstance().setReadDensity(DisplayPreferences.READ_DENSITY_HIGH);
    } else if (action.equals("read_pack_combine")) {
        DisplayPreferences.getInstance().setReadDisplay(DisplayPreferences.READ_DISPLAY_COMBINED);
    } else if (action.equals("read_pack_separate")) {
        DisplayPreferences.getInstance().setReadDisplay(DisplayPreferences.READ_DISPLAY_SEPARATED);
    } else if (action.equals("data_colour_dynamic")) {
        DisplayPreferences.getInstance().setColourType(DisplayPreferences.COLOUR_TYPE_GRADIENT);
    } else if (action.equals("data_colour_fixed")) {
        DisplayPreferences.getInstance().setColourType(DisplayPreferences.COLOUR_TYPE_INDEXED);
    } else if (action.equals("scale_positive")) {
        DisplayPreferences.getInstance().setScaleType(DisplayPreferences.SCALE_TYPE_POSITIVE);
    } else if (action.equals("scale_negative")) {
        DisplayPreferences.getInstance().setScaleType(DisplayPreferences.SCALE_TYPE_POSITIVE_AND_NEGATIVE);
    } else if (action.equals("view_annotation_tracks")) {
        new AnnotationTrackSelector(application);
    } else if (action.equals("view_data_tracks")) {
        new DataTrackSelector(application);
    } else if (action.equals("view_boxwhisker")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new MultiBoxWhiskerDialog(application.drawnDataSets(), new ProbeList[] { application.dataCollection().probeSet().getActiveList() });
        }
    } else if (action.equals("view_starwars")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new MultiStarWarsDialog(application.drawnDataSets(), new ProbeList[] { application.dataCollection().probeSet().getActiveList() });
        }
    } else if (action.equals("view_beanplot")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new MultiBeanPlotDialog(application.drawnDataSets(), new ProbeList[] { application.dataCollection().probeSet().getActiveList() });
        }
    } else if (action.equals("view_cumdist")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            try {
                new CumulativeDistributionDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
            } catch (SeqMonkException e) {
                throw new IllegalStateException(e);
            }
        }
    } else if (action.equals("view_qqdist")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            try {
                new QQDistributionDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
            } catch (SeqMonkException e) {
                throw new IllegalStateException(e);
            }
        }
    } else if (action.equals("plot_rna_qc")) {
        new RNAQCPreferencesDialog(application.dataCollection(), application.drawnDataSets());
    } else if (action.equals("plot_small_rna_qc")) {
        new SmallRNAQCPreferencesDialog(application.dataCollection());
    } else if (action.startsWith("toolbar_")) {
        // We're toggling the visibility of one of the toolbars;
        int index = Integer.parseInt(action.replaceAll("toolbar_", ""));
        toolbars[index].setShown(!toolbars[index].shown());
        updateVisibleToolBars();
    } else if (action.startsWith("multiprobe")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        ProbeList[] probeLists = ProbeListSelectorDialog.selectProbeLists();
        if (probeLists == null || probeLists.length == 0)
            return;
        else if (action.equals("multiprobe_view_boxwhisker")) {
            if (application.dataCollection().getActiveDataStore() == null) {
                JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            new MultiBoxWhiskerDialog(new DataStore[] { application.dataCollection().getActiveDataStore() }, probeLists);
        } else if (action.equals("multiprobe_view_beanplot")) {
            if (application.dataCollection().getActiveDataStore() == null) {
                JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            new MultiBeanPlotDialog(new DataStore[] { application.dataCollection().getActiveDataStore() }, probeLists);
        } else if (action.equals("multiprobe_view_starwars")) {
            if (application.dataCollection().getActiveDataStore() == null) {
                JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            new MultiStarWarsDialog(new DataStore[] { application.dataCollection().getActiveDataStore() }, probeLists);
        } else if (action.equals("multiprobe_view_multistore_boxwhisker")) {
            new MultiBoxWhiskerDialog(application.drawnDataSets(), probeLists);
        } else if (action.equals("multiprobe_view_multistore_beanplot")) {
            new MultiBeanPlotDialog(application.drawnDataSets(), probeLists);
        } else if (action.equals("multiprobe_view_multistore_starwars")) {
            new MultiStarWarsDialog(application.drawnDataSets(), probeLists);
        } else if (action.equals("multiprobe_view_probetrend")) {
            if (!application.dataCollection().isQuantitated()) {
                JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
            } else {
                new TrendOverProbePreferencesDialog(probeLists, application.drawnDataSets());
            }
        } else if (action.equals("multiprobe_view_cumdist")) {
            if (application.dataCollection().getActiveDataStore() == null) {
                JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            try {
                new CumulativeDistributionDialog(application.dataCollection().getActiveDataStore(), probeLists);
            } catch (SeqMonkException e) {
                throw new IllegalStateException(e);
            }
        } else if (action.equals("multiprobe_view_qqdist")) {
            if (application.dataCollection().getActiveDataStore() == null) {
                JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
                return;
            }
            try {
                new QQDistributionDialog(application.dataCollection().getActiveDataStore(), probeLists);
            } catch (SeqMonkException e) {
                throw new IllegalStateException(e);
            }
        } else if (action.equals("multiprobe_view_line_graph")) {
            try {
                new LineGraphDialog(application.drawnDataSets(), probeLists);
            } catch (SeqMonkException sme) {
                JOptionPane.showMessageDialog(application, sme.getLocalizedMessage(), "Can't draw graph", JOptionPane.ERROR_MESSAGE);
            }
        } else if (action.equals("multiprobe_view_heatmap_active")) {
            if (application.dataCollection().getActiveDataStore() == null) {
                JOptionPane.showMessageDialog(application, "You need to select an active data store to view this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
            } else if (!(application.dataCollection().getActiveDataStore() instanceof HiCDataStore && ((HiCDataStore) application.dataCollection().getActiveDataStore()).isValidHiC())) {
                JOptionPane.showMessageDialog(application, "Your active data store needs to be a HiC dataset to view this plot", "Wrong data selected...", JOptionPane.INFORMATION_MESSAGE);
            } else {
                new HeatmapProbeListWindow((HiCDataStore) application.dataCollection().getActiveDataStore(), probeLists, application.dataCollection().genome());
            }
        } else if (action.equals("multiprobe_plot_list_overlap")) {
            new ListOverlapsDialog(probeLists);
        } else if (action.equals("multiprobe_list_giraph_plot")) {
            if (probeLists.length > 50) {
                JOptionPane.showMessageDialog(application, "Please select fewer than 50 probe lists to display", "Too many probe lists...", JOptionPane.INFORMATION_MESSAGE);
            } else {
                new GiraphPlot(probeLists);
            }
        }
    } else if (action.equals("view_value_histogram")) {
        if (application.dataCollection().getActiveDataStore() == null) {
            JOptionPane.showMessageDialog(application, "You need to select a data store in the Data panel before viewing this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            if (!application.dataCollection().getActiveDataStore().isQuantitated()) {
                JOptionPane.showMessageDialog(application, "Your active data store hasn't been quantitated yet", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
            } else {
                try {
                    new ProbeValueHistogramPlot(application.dataCollection().getActiveDataStore(), application.dataCollection().probeSet().getActiveList());
                } catch (SeqMonkException e) {
                    throw new IllegalStateException(e);
                }
            }
        }
    } else if (action.equals("plot_duplication")) {
        if (application.dataCollection().probeSet() == null) {
            JOptionPane.showMessageDialog(application, "You need to make some probes before running this plot", "No probes...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new DuplicationPlotDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
        }
    } else if (action.equals("view_read_length_histogram")) {
        if (application.dataCollection().getActiveDataStore() == null) {
            JOptionPane.showMessageDialog(application, "You need to select a data store in the Data panel before viewing this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new ReadLengthHistogramPlot(application.dataCollection().getActiveDataStore());
        }
    } else if (action.startsWith("view_hic_length_")) {
        if (application.dataCollection().getActiveDataStore() == null) {
            JOptionPane.showMessageDialog(application, "You need to select a data store in the Data panel before viewing this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
        } else if (!(application.dataCollection().getActiveDataStore() instanceof HiCDataStore && ((HiCDataStore) application.dataCollection().getActiveDataStore()).isValidHiC())) {
            JOptionPane.showMessageDialog(application, "This plot can only be used on HiC data stores", "Not HiC data...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            if (action.equals("view_hic_length_histogram")) {
                new HiCLengthHistogramPlot((HiCDataStore) application.dataCollection().getActiveDataStore(), null);
            } else if (action.equals("view_hic_length_probes")) {
                if (application.dataCollection().probeSet() != null) {
                    new HiCLengthHistogramPlot((HiCDataStore) application.dataCollection().getActiveDataStore(), application.dataCollection().probeSet().getActiveList());
                } else {
                    JOptionPane.showMessageDialog(application, "You need to have quantitated your data before selecting this option", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
    } else if (action.equals("cis_trans_scatterplot")) {
        // Check to see if we have any HiC datasets
        DataStore[] stores = application.dataCollection().getAllDataStores();
        boolean foundHiC = false;
        for (int s = 0; s < stores.length; s++) {
            if (stores[s] instanceof HiCDataStore && ((HiCDataStore) stores[s]).isValidHiC()) {
                foundHiC = true;
                break;
            }
        }
        if (!foundHiC) {
            JOptionPane.showMessageDialog(application, "You don't appear to have any HiC data to plot", "No data available...", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        new CisTransScatterPlotDialog(application.dataCollection());
    } else if (action.equals("view_probe_length_histogram")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new ProbeLengthHistogramPlot(application.dataCollection().probeSet().getActiveList());
        }
    } else if (action.equals("view_probetrend")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new TrendOverProbePreferencesDialog(new ProbeList[] { application.dataCollection().probeSet().getActiveList() }, application.drawnDataSets());
        }
    } else if (action.equals("view_quanttrend")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new QuantiationTrendPlotPreferencesDialog(application.dataCollection(), application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
        }
    } else // }
    if (action.equals("view_aligned_probes")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new AlignedSummaryPreferencesDialog(new ProbeList[] { application.dataCollection().probeSet().getActiveList() }, application.drawnDataSets());
        }
    } else if (action.equals("view_aligned_probes_multi")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            ProbeList[] probeLists = ProbeListSelectorDialog.selectProbeLists();
            if (probeLists == null || probeLists.length == 0)
                return;
            new AlignedSummaryPreferencesDialog(probeLists, application.drawnDataSets());
        }
    } else if (action.equals("view_heatmap_active")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else if (application.dataCollection().getActiveDataStore() == null) {
            JOptionPane.showMessageDialog(application, "You need to select an active data store to view this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
        } else if (!(application.dataCollection().getActiveDataStore() instanceof HiCDataStore && ((HiCDataStore) application.dataCollection().getActiveDataStore()).isValidHiC())) {
            JOptionPane.showMessageDialog(application, "Your active data store needs to be a HiC dataset to view this plot", "Wrong data selected...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new HeatmapGenomeWindow((HiCDataStore) application.dataCollection().getActiveDataStore(), application.dataCollection().probeSet().getActiveList(), application.dataCollection().genome());
        }
    } else if (action.equals("plot_domainogram")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new DomainogramPreferencesDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
        }
    } else if (action.equals("view_variance_plot")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else if (application.dataCollection().getAllReplicateSets().length == 0) {
            JOptionPane.showMessageDialog(application, "This plot only works on Replicate Sets and you don't have any", "No replicate sets...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new VariancePlotDialog(application.dataCollection());
        }
    } else if (action.equals("view_strand_bias_plot")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new StrandBiasPlotDialog(application.dataCollection());
        }
    } else if (action.equals("view_scatterplot")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new ScatterPlotDialog(application.dataCollection());
        }
    } else if (action.equals("view_ma_plot")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new MAPlotDialog(application.dataCollection());
        }
    } else if (action.equals("view_line_graph")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            try {
                new LineGraphDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
            } catch (SeqMonkException sme) {
                JOptionPane.showMessageDialog(application, sme.getLocalizedMessage(), "Can't draw graph", JOptionPane.ERROR_MESSAGE);
            }
        }
    } else if (action.equals("view_datastore_tree")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new DataStoreTreeDialog(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
        }
    } else if (action.equals("view_pca")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new PCADataCalculator(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
        }
    } else if (action.equals("view_tsne")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new TsneOptionsDialog(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
        }
    } else if (action.equals("view_correlation_matrix")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            new CorrelationMatrix(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
        }
    } else if (action.startsWith("view_hierarchical_cluster")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
        } else {
            boolean normalise = false;
            if (action.endsWith("normalised")) {
                normalise = true;
            }
            new HierarchicalClusterDialog(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets(), normalise);
        }
    } else if (action.equals("view_all_labels")) {
        application.chromosomeViewer().toggleLabels();
    } else if (action.equals("view_set_zoom")) {
        new DataZoomSelector(application);
    } else if (action.equals("define_probes")) {
        new DefineProbeOptions(application);
    } else if (action.equals("quantitation")) {
        if (application.dataCollection().probeSet() == null) {
            JOptionPane.showMessageDialog(application, "You need to define some probes before quantitating", "No probes...", JOptionPane.INFORMATION_MESSAGE);
            new DefineProbeOptions(application);
        } else {
            new DefineQuantitationOptions(application);
        }
    } else if (action.equals("pipeline_quantitation")) {
        new DefinePipelineOptions(application);
    } else if (action.equals("edit_groups")) {
        new GroupEditor(application);
    } else if (action.equals("edit_replicates")) {
        new ReplicateSetEditor(application);
    } else if (action.equals("auto_create_groups")) {
        new AutoSplitDataDialog(application);
    } else if (action.equals("edit_samples")) {
        new DataSetEditor(application.dataCollection());
    } else if (action.equals("save")) {
        application.saveProject();
    } else if (action.equals("save_as")) {
        application.saveProjectAs();
    } else if (action.equals("file_export_chromosome_view")) {
        // We don't want the scroll bars to appear in the drawn image
        // so we temporarily remove them.
        // application.chromosomeViewer().scrollPane().setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        // application.chromosomeViewer().scrollPane().validate();
        ImageSaver.saveImage(application.chromosomeViewer());
    // application.chromosomeViewer().scrollPane().setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    // application.chromosomeViewer().scrollPane().validate();
    } else if (action.equals("file_export_genome_view")) {
        ImageSaver.saveImage(application.genomeViewer());
    } else if (action.equals("file_export_bedgraph")) {
        if (!application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You need to have quantitated your data", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        BedGraphDataWriter bgw = new BedGraphDataWriter(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
        bgw.startProcessing();
    } else if (action.equals("open")) {
        application.loadProject();
    } else if (action.equals("open_switch")) {
        application.loadProjectAndSwitchAssembly();
    } else if (action.startsWith("filter")) {
        try {
            if (action.startsWith("filter_r_")) {
                try {
                    RVersionTest.testRVersion(SeqMonkPreferences.getInstance().RLocation());
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(application, "<html>Can't find R at '" + SeqMonkPreferences.getInstance().RLocation() + "'<br><br>Please set the path to R under Edit &gt; Preferences &gt; Programs", "Can't find R", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (action.equals("filter_r_deseq2")) {
                    new FilterOptionsDialog(application.dataCollection(), new DESeqFilter(application.dataCollection()));
                } else if (action.equals("filter_r_limma")) {
                    new FilterOptionsDialog(application.dataCollection(), new LimmaFilter(application.dataCollection()));
                } else if (action.equals("filter_r_edger")) {
                    new FilterOptionsDialog(application.dataCollection(), new EdgeRFilter(application.dataCollection()));
                } else if (action.equals("filter_r_edger_forrev")) {
                    new FilterOptionsDialog(application.dataCollection(), new EdgeRForRevFilter(application.dataCollection()));
                } else if (action.equals("filter_r_logistic_regression")) {
                    new FilterOptionsDialog(application.dataCollection(), new LogisticRegressionFilter(application.dataCollection()));
                } else if (action.equals("filter_r_logistic_regression_splicing")) {
                    new FilterOptionsDialog(application.dataCollection(), new LogisticRegressionSplicingFilter(application.dataCollection()));
                } else {
                    throw new IllegalArgumentException("Didn't understand command '" + action + "'");
                }
            } else if (action.equals("filter_values_individual")) {
                new FilterOptionsDialog(application.dataCollection(), new ValuesFilter(application.dataCollection()));
            } else if (action.equals("filter_values_windowed")) {
                new FilterOptionsDialog(application.dataCollection(), new WindowedValuesFilter(application.dataCollection()));
            } else if (action.equals("filter_values_distribution")) {
                new FilterOptionsDialog(application.dataCollection(), new DistributionPositionFilter(application.dataCollection()));
            } else if (action.equals("filter_diffs_individual")) {
                new FilterOptionsDialog(application.dataCollection(), new DifferencesFilter(application.dataCollection()));
            } else if (action.equals("filter_diffs_windowed")) {
                new FilterOptionsDialog(application.dataCollection(), new WindowedDifferencesFilter(application.dataCollection()));
            } else if (action.equals("filter_var_individual")) {
                new FilterOptionsDialog(application.dataCollection(), new VarianceValuesFilter(application.dataCollection()));
            } else if (action.equals("filter_intensity_stats")) {
                new FilterOptionsDialog(application.dataCollection(), new IntensityDifferenceFilter(application.dataCollection()));
            } else if (action.equals("filter_intensity_var_stats")) {
                new FilterOptionsDialog(application.dataCollection(), new VarianceIntensityDifferenceFilter(application.dataCollection()));
            } else if (action.equals("filter_proportion_library")) {
                new FilterOptionsDialog(application.dataCollection(), new ProportionOfLibraryStatisticsFilter(application.dataCollection()));
            } else if (action.equals("filter_intensity_replicate_stats")) {
                new FilterOptionsDialog(application.dataCollection(), new IntensityReplicateFilter(application.dataCollection()));
            } else if (action.equals("filter_statsr")) {
                new FilterOptionsDialog(application.dataCollection(), new WindowedReplicateStatsFilter(application.dataCollection()));
            } else if (action.equals("filter_stats")) {
                new FilterOptionsDialog(application.dataCollection(), new ReplicateSetStatsFilter(application.dataCollection()));
            } else if (action.equals("filter_monte_carlo")) {
                new FilterOptionsDialog(application.dataCollection(), new MonteCarloFilter(application.dataCollection()));
            } else // Laura
            if (action.equals("filter_genesets")) {
                new FilterOptionsDialog(application.dataCollection(), new GeneSetIntensityDifferenceFilter(application.dataCollection()));
            } else if (action.equals("filter_boxwhisker")) {
                BoxWhiskerFilter filter = new BoxWhiskerFilter(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_chisquare_stores")) {
                ChiSquareFilter filter = new ChiSquareFilter(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_chisquare_forrev")) {
                ChiSquareFilterForRev filter = new ChiSquareFilterForRev(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_chisquare_frontback")) {
                ChiSquareFilterFrontBack filter = new ChiSquareFilterFrontBack(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_binomial_forrev")) {
                BinomialFilterForRev filter = new BinomialFilterForRev(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_correlation_cluster")) {
                CorrelationClusterFilter filter = new CorrelationClusterFilter(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_correlation_probes")) {
                CorrelationFilter filter = new CorrelationFilter(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_correlation_manual")) {
                ManualCorrelationFilter filter = new ManualCorrelationFilter(application.dataCollection());
                new FilterOptionsDialog(application.dataCollection(), filter);
            } else if (action.equals("filter_position")) {
                new FilterOptionsDialog(application.dataCollection(), new PositionFilter(application.dataCollection(), DisplayPreferences.getInstance().getCurrentChromosome(), SequenceRead.start(DisplayPreferences.getInstance().getCurrentLocation()), SequenceRead.end(DisplayPreferences.getInstance().getCurrentLocation())));
            } else // }
            if (action.equals("filter_length")) {
                new FilterOptionsDialog(application.dataCollection(), new ProbeLengthFilter(application.dataCollection()));
            } else if (action.equals("filter_features")) {
                new FilterOptionsDialog(application.dataCollection(), new FeatureFilter(application.dataCollection()));
            } else if (action.equals("filter_feature_names")) {
                new FilterOptionsDialog(application.dataCollection(), new FeatureNameFilter(application.dataCollection()));
            } else if (action.equals("filter_probe_names")) {
                new FilterOptionsDialog(application.dataCollection(), new ProbeNameFilter(application.dataCollection()));
            } else if (action.equals("filter_deduplication")) {
                new FilterOptionsDialog(application.dataCollection(), new DeduplicationFilter(application.dataCollection()));
            } else if (action.equals("filter_random")) {
                new FilterOptionsDialog(application.dataCollection(), new RandomFilter(application.dataCollection()));
            } else if (action.equals("filter_combine")) {
                new FilterOptionsDialog(application.dataCollection(), new CombineFilter(application.dataCollection()));
            } else if (action.equals("filter_collate")) {
                new FilterOptionsDialog(application.dataCollection(), new CollateListsFilter(application.dataCollection()));
            }
        } catch (SeqMonkException e) {
            JOptionPane.showMessageDialog(application, e.getMessage(), "Can't run filter", JOptionPane.ERROR_MESSAGE);
        }
    } else if (action.startsWith("report")) {
        if (action != "report_summary" && !application.dataCollection().isQuantitated()) {
            JOptionPane.showMessageDialog(application, "You must quantiate your data before creating reports", "Can't generate report", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (action.equals("report_annotated")) {
            new ReportOptions(application, new AnnotatedListReport(application.dataCollection(), application.drawnDataSets()));
        } else if (action.equals("report_description")) {
            new ProbeListReportCreator(application.dataCollection().probeSet().getActiveList());
        } else if (action.equals("report_group")) {
            new ReportOptions(application, new ProbeGroupReport(application.dataCollection(), application.drawnDataSets()));
        } else if (action.equals("report_feature")) {
            new ReportOptions(application, new FeatureReport(application.dataCollection(), application.drawnDataSets()));
        } else if (action.equals("report_summary")) {
            new ReportOptions(application, new DataStoreSummaryReport(application.dataCollection(), application.drawnDataSets()));
        } else if (action.equals("report_chromosome")) {
            new ReportOptions(application, new ChromosomeViewReport(application.dataCollection(), application.drawnDataSets()));
        }
    } else if (action.equals("edit_preferences")) {
        new EditPreferencesDialog(application.dataCollection());
    } else if (action.equals("find_feature")) {
        new FindFeatureDialog(application.dataCollection());
    } else if (action.equals("find_feature_names")) {
        new FindFeaturesByNameDialog(application.dataCollection());
    } else if (action.equals("goto_position")) {
        new GotoDialog(application);
    } else if (action.equals("goto_window")) {
        new GotoWindowDialog(application);
    } else if (action.equals("copy_position")) {
        Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable t = new StringSelection("chr" + DisplayPreferences.getInstance().getCurrentChromosome().name() + ":" + SequenceRead.start(DisplayPreferences.getInstance().getCurrentLocation()) + "-" + SequenceRead.end(DisplayPreferences.getInstance().getCurrentLocation()));
        c.setContents(t, null);
    } else {
        throw new IllegalStateException("Unknown command '" + action + "' from main menu");
    }
}
Also used : QuantiationTrendPlotPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.QuantitationTrendPlot.QuantiationTrendPlotPreferencesDialog) BedPEFileParser(uk.ac.babraham.SeqMonk.DataParsers.BedPEFileParser) MalformedURLException(java.net.MalformedURLException) DuplicationPlotDialog(uk.ac.babraham.SeqMonk.Displays.DuplicationPlot.DuplicationPlotDialog) AboutDialog(uk.ac.babraham.SeqMonk.Dialogs.AboutDialog) LogisticRegressionSplicingFilter(uk.ac.babraham.SeqMonk.Filters.LogisticRegressionFilter.LogisticRegressionSplicingFilter) DefinePipelineOptions(uk.ac.babraham.SeqMonk.Pipelines.Options.DefinePipelineOptions) MethylKitFileParser(uk.ac.babraham.SeqMonk.DataParsers.MethylKitFileParser) EdgeRFilter(uk.ac.babraham.SeqMonk.Filters.EdgeRFilter.EdgeRFilter) GenericAnnotationParser(uk.ac.babraham.SeqMonk.AnnotationParsers.GenericAnnotationParser) ProbeLengthHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.ProbeLengthHistogramPlot) WindowedValuesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedValuesFilter) VarianceValuesFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceValuesFilter) ValuesFilter(uk.ac.babraham.SeqMonk.Filters.ValuesFilter) FeatureNameFilter(uk.ac.babraham.SeqMonk.Filters.FeatureNameFilter) VarianceIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceIntensityDifferenceFilter) LogisticRegressionFilter(uk.ac.babraham.SeqMonk.Filters.LogisticRegressionFilter.LogisticRegressionFilter) DeduplicationFilter(uk.ac.babraham.SeqMonk.Filters.DeduplicationFilter) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) DisplayPreferencesEditorDialog(uk.ac.babraham.SeqMonk.Preferences.Editor.DisplayPreferencesEditorDialog) CumulativeDistributionDialog(uk.ac.babraham.SeqMonk.Displays.CumulativeDistribution.CumulativeDistributionDialog) LineGraphDialog(uk.ac.babraham.SeqMonk.Displays.LineGraph.LineGraphDialog) GiraphPlot(uk.ac.babraham.SeqMonk.Displays.GiraphPlot.GiraphPlot) ReplicateSetEditor(uk.ac.babraham.SeqMonk.Dialogs.ReplicateSetEditor) VarianceIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceIntensityDifferenceFilter) GeneSetIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.GeneSetFilter.GeneSetIntensityDifferenceFilter) IntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.IntensityDifferenceFilter) ReplicateSetStatsFilter(uk.ac.babraham.SeqMonk.Filters.ReplicateSetStatsFilter) SmallRNAQCPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.SmallRNAQCPlot.SmallRNAQCPreferencesDialog) RNAQCPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.RNASeqQCPlot.RNAQCPreferencesDialog) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) WindowedDifferencesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedDifferencesFilter) BedGraphDataWriter(uk.ac.babraham.SeqMonk.DataWriters.BedGraphDataWriter) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) GffFileParser(uk.ac.babraham.SeqMonk.DataParsers.GffFileParser) LimmaFilter(uk.ac.babraham.SeqMonk.Filters.LimmaFilter.LimmaFilter) DistributionPositionFilter(uk.ac.babraham.SeqMonk.Filters.DistributionPositionFilter) PositionFilter(uk.ac.babraham.SeqMonk.Filters.PositionFilter) SeqMonkReimportParser(uk.ac.babraham.SeqMonk.DataParsers.SeqMonkReimportParser) MultiBeanPlotDialog(uk.ac.babraham.SeqMonk.Displays.BeanPlot.MultiBeanPlotDialog) ProbeGroupReport(uk.ac.babraham.SeqMonk.Reports.ProbeGroupReport) PCADataCalculator(uk.ac.babraham.SeqMonk.Displays.PCAPlot.PCADataCalculator) DataZoomSelector(uk.ac.babraham.SeqMonk.Dialogs.DataZoomSelector) BoxWhiskerFilter(uk.ac.babraham.SeqMonk.Filters.BoxWhiskerFilter) ActiveProbeListParser(uk.ac.babraham.SeqMonk.DataParsers.ActiveProbeListParser) MonteCarloFilter(uk.ac.babraham.SeqMonk.Filters.MonteCarloFilter) QQDistributionDialog(uk.ac.babraham.SeqMonk.Displays.QQDistributionPlot.QQDistributionDialog) HiCLengthHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.HiCLengthHistogramPlot) ProbeNameFilter(uk.ac.babraham.SeqMonk.Filters.ProbeNameFilter) FeatureFilter(uk.ac.babraham.SeqMonk.Filters.FeatureFilter) FeatureReport(uk.ac.babraham.SeqMonk.Reports.FeatureReport) BismarkCovFileParser(uk.ac.babraham.SeqMonk.DataParsers.BismarkCovFileParser) ProbeValueHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.ProbeValueHistogramPlot) ProbeListAnnotationParser(uk.ac.babraham.SeqMonk.AnnotationParsers.ProbeListAnnotationParser) URL(java.net.URL) GroupEditor(uk.ac.babraham.SeqMonk.Dialogs.GroupEditor) ChiSquareFilter(uk.ac.babraham.SeqMonk.Filters.ChiSquareFilter) GotoDialog(uk.ac.babraham.SeqMonk.Dialogs.GotoDialog.GotoDialog) AlignedSummaryPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.AlignedProbePlot.AlignedSummaryPreferencesDialog) HelpDialog(uk.ac.babraham.SeqMonk.Displays.Help.HelpDialog) BowtieFileParser(uk.ac.babraham.SeqMonk.DataParsers.BowtieFileParser) LicenseDialog(uk.ac.babraham.SeqMonk.Dialogs.LicenseDialog) ListOverlapsDialog(uk.ac.babraham.SeqMonk.Dialogs.ListOverlapsDialog) MultiBoxWhiskerDialog(uk.ac.babraham.SeqMonk.Displays.BoxWhisker.MultiBoxWhiskerDialog) TsneOptionsDialog(uk.ac.babraham.SeqMonk.Displays.TsneDataStorePlot.TsneOptionsDialog) BinomialFilterForRev(uk.ac.babraham.SeqMonk.Filters.BinomialFilterForRev) ManualCorrelationFilter(uk.ac.babraham.SeqMonk.Filters.ManualCorrelation.ManualCorrelationFilter) IOException(java.io.IOException) IntensityReplicateFilter(uk.ac.babraham.SeqMonk.Filters.IntensityReplicateFilter) ChiSquareFilterFrontBack(uk.ac.babraham.SeqMonk.Filters.ChiSquareFilterFrontBack) AnnotatedListReport(uk.ac.babraham.SeqMonk.Reports.AnnotatedListReport) AnnotationTrackSelector(uk.ac.babraham.SeqMonk.Dialogs.AnnotationTrackSelector) GeneSetIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.GeneSetFilter.GeneSetIntensityDifferenceFilter) MAPlotDialog(uk.ac.babraham.SeqMonk.Displays.MAPlot.MAPlotDialog) Clipboard(java.awt.datatransfer.Clipboard) ProbeLengthFilter(uk.ac.babraham.SeqMonk.Filters.ProbeLengthFilter) GenericSeqReadParser(uk.ac.babraham.SeqMonk.DataParsers.GenericSeqReadParser) GotoWindowDialog(uk.ac.babraham.SeqMonk.Dialogs.GotoDialog.GotoWindowDialog) ProbeListReportCreator(uk.ac.babraham.SeqMonk.Displays.ProbeListReport.ProbeListReportCreator) FilterOptionsDialog(uk.ac.babraham.SeqMonk.Dialogs.Filters.FilterOptionsDialog) CorrelationClusterFilter(uk.ac.babraham.SeqMonk.Filters.CorrelationCluster.CorrelationClusterFilter) StringSelection(java.awt.datatransfer.StringSelection) CorrelationMatrix(uk.ac.babraham.SeqMonk.Displays.CorrelationMatrix.CorrelationMatrix) DefineProbeOptions(uk.ac.babraham.SeqMonk.ProbeGenerators.DefineProbeOptions) TrendOverProbePreferencesDialog(uk.ac.babraham.SeqMonk.Displays.ProbeTrendPlot.TrendOverProbePreferencesDialog) CombineFilter(uk.ac.babraham.SeqMonk.Filters.CombineFilter) CollateListsFilter(uk.ac.babraham.SeqMonk.Filters.CollateListsFilter) FindFeaturesByNameDialog(uk.ac.babraham.SeqMonk.Dialogs.FindFeaturesByNameDialog) DataSetEditor(uk.ac.babraham.SeqMonk.Dialogs.DataSetEditor.DataSetEditor) DomainogramPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.Domainogram.DomainogramPreferencesDialog) ReportOptions(uk.ac.babraham.SeqMonk.Displays.Report.ReportOptions) ChiSquareFilterForRev(uk.ac.babraham.SeqMonk.Filters.ChiSquareFilterForRev) DataStoreSummaryReport(uk.ac.babraham.SeqMonk.Reports.DataStoreSummaryReport) EdgeRForRevFilter(uk.ac.babraham.SeqMonk.Filters.EdgeRFilter.EdgeRForRevFilter) VariancePlotDialog(uk.ac.babraham.SeqMonk.Displays.VariancePlot.VariancePlotDialog) WindowedValuesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedValuesFilter) DESeqFilter(uk.ac.babraham.SeqMonk.Filters.DESeqFilter.DESeqFilter) HeatmapGenomeWindow(uk.ac.babraham.SeqMonk.Displays.HiCHeatmap.HeatmapGenomeWindow) MultiStarWarsDialog(uk.ac.babraham.SeqMonk.Displays.StarWars.MultiStarWarsDialog) VarianceValuesFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceValuesFilter) ManualCorrelationFilter(uk.ac.babraham.SeqMonk.Filters.ManualCorrelation.ManualCorrelationFilter) CorrelationFilter(uk.ac.babraham.SeqMonk.Filters.CorrelationFilter) DifferencesFilter(uk.ac.babraham.SeqMonk.Filters.DifferencesFilter) WindowedDifferencesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedDifferencesFilter) VisibleStoresParser(uk.ac.babraham.SeqMonk.DataParsers.VisibleStoresParser) AutoSplitDataDialog(uk.ac.babraham.SeqMonk.Dialogs.AutoSplitDataDialog) File(java.io.File) ProportionOfLibraryStatisticsFilter(uk.ac.babraham.SeqMonk.Filters.ProportionOfLibraryStatisticsFilter) BedFileParser(uk.ac.babraham.SeqMonk.DataParsers.BedFileParser) StrandBiasPlotDialog(uk.ac.babraham.SeqMonk.Displays.StrandBias.StrandBiasPlotDialog) URISyntaxException(java.net.URISyntaxException) RandomFilter(uk.ac.babraham.SeqMonk.Filters.RandomFilter) DataStoreTreeDialog(uk.ac.babraham.SeqMonk.Displays.DataStoreTree.DataStoreTreeDialog) ReadLengthHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.ReadLengthHistogramPlot) HierarchicalClusterDialog(uk.ac.babraham.SeqMonk.Displays.HierarchicalClusterPlot.HierarchicalClusterDialog) GFF3AnnotationParser(uk.ac.babraham.SeqMonk.AnnotationParsers.GFF3AnnotationParser) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) HiCOtherEndExtractor(uk.ac.babraham.SeqMonk.DataParsers.HiCOtherEndExtractor) DataTrackSelector(uk.ac.babraham.SeqMonk.Dialogs.DataTrackSelector.DataTrackSelector) WindowedReplicateStatsFilter(uk.ac.babraham.SeqMonk.Filters.WindowedReplicateStatsFilter) EditPreferencesDialog(uk.ac.babraham.SeqMonk.Dialogs.EditPreferencesDialog) HeatmapProbeListWindow(uk.ac.babraham.SeqMonk.Displays.HiCHeatmap.HeatmapProbeListWindow) Transferable(java.awt.datatransfer.Transferable) SmallRNAQCPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.SmallRNAQCPlot.SmallRNAQCPreferencesDialog) FindFeatureDialog(uk.ac.babraham.SeqMonk.Dialogs.FindFeatureDialog) DistributionPositionFilter(uk.ac.babraham.SeqMonk.Filters.DistributionPositionFilter) ScatterPlotDialog(uk.ac.babraham.SeqMonk.Displays.ScatterPlot.ScatterPlotDialog) CisTransScatterPlotDialog(uk.ac.babraham.SeqMonk.Displays.CisTransScatterplot.CisTransScatterPlotDialog) ChromosomeViewReport(uk.ac.babraham.SeqMonk.Reports.ChromosomeViewReport) CisTransScatterPlotDialog(uk.ac.babraham.SeqMonk.Displays.CisTransScatterplot.CisTransScatterPlotDialog) DefineQuantitationOptions(uk.ac.babraham.SeqMonk.Quantitation.Options.DefineQuantitationOptions) BAMFileParser(uk.ac.babraham.SeqMonk.DataParsers.BAMFileParser) QuasRFileParser(uk.ac.babraham.SeqMonk.DataParsers.QuasRFileParser)

Example 15 with ProbeList

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

the class BoxWhiskerFilter method generateProbeList.

/* (non-Javadoc)
	 * @see uk.ac.babraham.SeqMonk.Filters.ProbeFilter#generateProbeList()
	 */
protected void generateProbeList() {
    ProbeList newList = new ProbeList(startingList, "Filtered Probes", "", null);
    Hashtable<Probe, Integer> hitCounts = new Hashtable<Probe, Integer>();
    for (int s = 0; s < stores.length; s++) {
        progressUpdated("Processing " + stores[s].name(), s, stores.length);
        if (cancel) {
            cancel = false;
            progressCancelled();
            return;
        }
        BoxWhisker bw;
        try {
            bw = new BoxWhisker(stores[s], startingList, stringency);
        } catch (SeqMonkException e) {
            System.err.println("Ignoring unquantitated dataset");
            e.printStackTrace();
            continue;
        }
        if (useUpper) {
            Probe[] p = bw.upperProbeOutliers();
            if (cancel) {
                cancel = false;
                progressCancelled();
                return;
            }
            for (int i = 0; i < p.length; i++) {
                if (hitCounts.containsKey(p[i])) {
                    hitCounts.put(p[i], hitCounts.get(p[i]).intValue() + 1);
                } else {
                    hitCounts.put(p[i], 1);
                }
            }
        }
        if (useLower) {
            Probe[] p = bw.lowerProbeOutliers();
            for (int i = 0; i < p.length; i++) {
                if (cancel) {
                    cancel = false;
                    progressCancelled();
                    return;
                }
                if (hitCounts.containsKey(p[i])) {
                    hitCounts.put(p[i], hitCounts.get(p[i]).intValue() + 1);
                } else {
                    hitCounts.put(p[i], 1);
                }
            }
        }
    }
    // Now we can go through the probes which hit and see if
    // we had enough hits to put them into our final list.
    Enumeration<Probe> candidates = hitCounts.keys();
    while (candidates.hasMoreElements()) {
        if (cancel) {
            cancel = false;
            progressCancelled();
            return;
        }
        Probe candidate = candidates.nextElement();
        int count = hitCounts.get(candidate).intValue();
        // probe to the probe set.
        switch(filterType) {
            case EXACTLY:
                if (count == storeCutoff)
                    newList.addProbe(candidate, null);
                break;
            case AT_LEAST:
                if (count >= storeCutoff)
                    newList.addProbe(candidate, null);
                break;
            case NO_MORE_THAN:
                if (count <= storeCutoff)
                    newList.addProbe(candidate, null);
                break;
        }
    }
    filterFinished(newList);
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) Hashtable(java.util.Hashtable) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) BoxWhisker(uk.ac.babraham.SeqMonk.Analysis.Statistics.BoxWhisker)

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