Search in sources :

Example 36 with ProbeList

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

the class DataTreeRenderer method getTreeCellRendererComponent.

/* (non-Javadoc)
	 * @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
	 */
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof DataSet) {
        JLabel label = new JLabel(value.toString(), dataSetIcon, JLabel.LEFT);
        if (value instanceof HiCDataStore && ((HiCDataStore) value).isValidHiC()) {
            label.setText("[HiC] " + label.getText());
        }
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof DataGroup) {
        JLabel label = new JLabel(value.toString(), dataGroupIcon, JLabel.LEFT);
        if (value instanceof HiCDataStore && ((HiCDataStore) value).isValidHiC()) {
            label.setText("[HiC] " + label.getText());
        }
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof ReplicateSet) {
        JLabel label = new JLabel(value.toString(), replicateSetIcon, JLabel.LEFT);
        if (value instanceof HiCDataStore && ((HiCDataStore) value).isValidHiC()) {
            label.setText("[HiC] " + label.getText());
        }
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof ProbeList) {
        JLabel label = new JLabel(value.toString(), probeListIcon, JLabel.LEFT);
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof AnnotationSet) {
        JLabel label = new JLabel(value.toString(), annotationSetIcon, JLabel.LEFT);
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else {
        return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    }
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) ReplicateSet(uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet) JLabel(javax.swing.JLabel) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) AnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet)

Example 37 with ProbeList

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

the class HeatmapMatrix method findCommonProbeListParent.

@SuppressWarnings({ "rawtypes", "unchecked" })
private ProbeList findCommonProbeListParent() {
    if (probeLists.length == 1) {
        return probeLists[0];
    } else {
        HashSet[] parents = new HashSet[probeLists.length - 1];
        for (int i = 1; i < probeLists.length; i++) {
            parents[i - 1] = new HashSet<ProbeList>();
            ProbeList currentList = probeLists[i];
            parents[i - 1].add(currentList);
            while (!(currentList instanceof ProbeSet)) {
                parents[i - 1].add(currentList.parent());
                currentList = currentList.parent();
            }
        }
        // Now we go through the first list to find the common parent
        ProbeList firstList = probeLists[0];
        boolean notFound = false;
        while (true) {
            notFound = false;
            for (int i = 0; i < parents.length; i++) {
                if (!parents[i].contains(firstList)) {
                    notFound = true;
                }
            }
            if (notFound) {
                firstList = firstList.parent();
            } else {
                return firstList;
            }
        }
    }
}
Also used : ProbeSet(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeSet) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) HashSet(java.util.HashSet)

Example 38 with ProbeList

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

the class HeatmapMatrix method createProbeListsFromClusters.

public ProbeList createProbeListsFromClusters(int minClusterSize, int startIndex, int endIndex) {
    if (cluster == null)
        return null;
    ClusterPair[] connectedClusters = cluster.getConnectedClusters(currentClusterRValue);
    ProbeList commonList = findCommonProbeListParent();
    ProbeList allClusterList = new ProbeList(commonList, "HiC Clusters", "HiC Clusters with R > " + commonList, null);
    HashSet<Probe> allClusterProbes = new HashSet<Probe>();
    // Now we need to work our way through the connected clusters
    // to make the appropriate sub-lists
    // Make up the same initial list of probes as before
    Vector<Probe> originallyOrderedProbes = new Vector<Probe>();
    for (int l = 0; l < probeLists.length; l++) {
        Probe[] theseProbes = probeLists[l].getAllProbes();
        for (int p = 0; p < theseProbes.length; p++) {
            originallyOrderedProbes.add(theseProbes[p]);
        }
    }
    int currentPosition = 0;
    for (int subListIndex = 0; subListIndex < connectedClusters.length; subListIndex++) {
        Integer[] indices = connectedClusters[subListIndex].getAllIndices();
        currentPosition += indices.length;
        if (currentPosition - indices.length < startIndex)
            continue;
        if (currentPosition > endIndex)
            break;
        // We may get rid of the list later if there are duplicates in it.
        if (indices.length < minClusterSize)
            continue;
        Probe[] theseProbes = new Probe[indices.length];
        for (int i = 0; i < theseProbes.length; i++) {
            theseProbes[i] = originallyOrderedProbes.elementAt(indices[i]);
        }
        Arrays.sort(theseProbes);
        // Now find the non-redundant count
        int nonRedCount = 1;
        for (int i = 1; i < theseProbes.length; i++) {
            if (theseProbes[i] != theseProbes[i - 1]) {
                nonRedCount++;
            }
        }
        // There aren't enough different probes to keep this set.
        if (nonRedCount < minClusterSize)
            continue;
        ProbeList thisList = new ProbeList(allClusterList, "Cluster " + (subListIndex + 1), "HiC cluster list number " + (subListIndex + 1), "R-value");
        float rValue = connectedClusters[subListIndex].rValue();
        thisList.addProbe(theseProbes[0], rValue);
        if (!allClusterProbes.contains(theseProbes[0])) {
            allClusterList.addProbe(theseProbes[0], null);
            allClusterProbes.add(theseProbes[0]);
        }
        for (int i = 1; i < theseProbes.length; i++) {
            if (theseProbes[i] == theseProbes[i - 1])
                continue;
            thisList.addProbe(theseProbes[i], rValue);
            if (allClusterProbes.contains(theseProbes[i])) {
                continue;
            }
            allClusterList.addProbe(theseProbes[i], null);
            allClusterProbes.add(theseProbes[i]);
        }
    }
    return allClusterList;
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) ClusterPair(uk.ac.babraham.SeqMonk.DataTypes.Cluster.ClusterPair) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) Vector(java.util.Vector) HashSet(java.util.HashSet)

Example 39 with ProbeList

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

the class HeatmapMatrix method createProbeListFromCurrentInteractions.

public ProbeList createProbeListFromCurrentInteractions() {
    ProbeList commonList = findCommonProbeListParent();
    // TODO: Get a better name
    ProbeList allProbesList = new ProbeList(commonList, "Filtered HiC hits", "HiC hits" + commonList, null);
    HashSet<Probe> allClusterProbes = new HashSet<Probe>();
    // Work our way through the interactions to get the subset which are active
    InteractionProbePair[] exportedInteractions = filteredInteractions();
    for (int i = 0; i < exportedInteractions.length; i++) {
        if (!allClusterProbes.contains(exportedInteractions[i].probe1())) {
            allProbesList.addProbe(exportedInteractions[i].probe1(), null);
            allClusterProbes.add(exportedInteractions[i].probe1());
        }
        if (!allClusterProbes.contains(exportedInteractions[i].probe2())) {
            allProbesList.addProbe(exportedInteractions[i].probe2(), null);
            allClusterProbes.add(exportedInteractions[i].probe2());
        }
    }
    return allProbesList;
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) HashSet(java.util.HashSet)

Example 40 with ProbeList

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

the class FilterOptionsDialog method progressComplete.

public void progressComplete(String command, Object result) {
    ProbeList newList = (ProbeList) result;
    filterButton.setEnabled(true);
    // See if any probes actually passed
    if (newList.getAllProbes().length == 0) {
        // We need to remove this empty list.
        newList.delete();
        JOptionPane.showMessageDialog(this, "No probes matched the criteria set", "Info", JOptionPane.INFORMATION_MESSAGE);
        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);
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)

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