use of uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet in project SeqMonk by s-andrews.
the class DataCollectionTreeModel method replicateSetsRemoved.
public void replicateSetsRemoved(ReplicateSet[] r) {
// Find the indices of each of these datasets and sort them low to high
// before telling the listeners
Hashtable<Integer, ReplicateSet> indices = new Hashtable<Integer, ReplicateSet>();
for (int i = 0; i < r.length; i++) {
indices.put(getIndexOfChild(replicateSetNode, r[i]), r[i]);
}
// We have to make an Integer object array before we can convert this
// to a primitive int array
Integer[] deleteIndices = indices.keySet().toArray(new Integer[0]);
Arrays.sort(deleteIndices);
ReplicateSet[] deleteSets = new ReplicateSet[deleteIndices.length];
for (int i = 0; i < deleteIndices.length; i++) {
deleteSets[i] = indices.get(deleteIndices[i]);
}
int[] delInd = new int[deleteIndices.length];
for (int i = 0; i < deleteIndices.length; i++) {
delInd[i] = deleteIndices[i];
}
TreeModelEvent me = new TreeModelEvent(r, getPathToRoot(replicateSetNode), delInd, deleteSets);
Enumeration<TreeModelListener> e = listeners.elements();
while (e.hasMoreElements()) {
e.nextElement().treeNodesRemoved(me);
}
}
use of uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet in project SeqMonk by s-andrews.
the class MatchDistributionsQuantitation method getOptionsPanel.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
*/
public JPanel getOptionsPanel() {
if (optionsPanel == null) {
optionsPanel = new JPanel();
optionsPanel.setLayout(new BorderLayout());
optionsPanel.add(new JLabel("Data Stores to Normalise", JLabel.CENTER), BorderLayout.NORTH);
DataStore[] stores = application.dataCollection().getAllDataStores();
Vector<DataStore> usableStores = new Vector<DataStore>();
for (int i = 0; i < stores.length; i++) {
if (stores[i] instanceof ReplicateSet)
continue;
if (!stores[i].isQuantitated())
continue;
usableStores.add(stores[i]);
}
usedStoresList = new JList(usableStores.toArray(new DataStore[0]));
usedStoresList.getSelectionModel().addListSelectionListener(this);
usedStoresList.setCellRenderer(new TypeColourRenderer());
int[] selectedIndices = new int[usableStores.size()];
for (int i = 0; i < selectedIndices.length; i++) selectedIndices[i] = i;
usedStoresList.setSelectedIndices(selectedIndices);
optionsPanel.add(new JScrollPane(usedStoresList), BorderLayout.CENTER);
}
return optionsPanel;
}
use of uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet in project SeqMonk by s-andrews.
the class VariancePlotDialog 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("sublists")) {
// Select a set of sublists from the current probe list to highlight
// in the plot
OrderedListSelector selector = new OrderedListSelector(this, probeList, subLists);
// It's modal so by the time we get here the selection has been made
subLists = selector.getOrderedLists();
// try to highlight anything.
if (subLists != null && subLists.length == 0) {
subLists = null;
}
selector.dispose();
actionPerformed(new ActionEvent(this, 1, "plot"));
} else if (ae.getActionCommand().equals("plot")) {
ReplicateSet xStore = (ReplicateSet) stores.getSelectedItem();
getContentPane().remove(variancePlotPanel);
// Check if these stores are quantitated
if (!xStore.isQuantitated()) {
JOptionPane.showMessageDialog(this, xStore.name() + " is not quantiated", "Can't make plot", JOptionPane.INFORMATION_MESSAGE);
} else {
int varianceMeasure = VariancePlotPanel.VARIANCE_COEF;
if (varianceMeasures.getSelectedItem().equals("StDev")) {
varianceMeasure = VariancePlotPanel.VARIANCE_STDEV;
} else if (varianceMeasures.getSelectedItem().equals("SEM")) {
varianceMeasure = VariancePlotPanel.VARIANCE_SEM;
} else if (varianceMeasures.getSelectedItem().equals("QuartDisp")) {
varianceMeasure = VariancePlotPanel.VARIANCE_QUARTILE_DISP;
} else if (varianceMeasures.getSelectedItem().equals("Unmeasured")) {
varianceMeasure = VariancePlotPanel.VARIANCE_NUMBER_UNMEASURED;
}
variancePlotPanel = new VariancePlotPanel(xStore, varianceMeasure, probeList, subLists, dotSizeSlider.getValue());
getContentPane().add(variancePlotPanel, BorderLayout.CENTER);
}
validate();
} else if (ae.getActionCommand().equals("save_probe_list")) {
if (variancePlotPanel instanceof VariancePlotPanel) {
ProbeList list = ((VariancePlotPanel) variancePlotPanel).getFilteredProbes(collection.probeSet());
if (list.getAllProbes().length == 0) {
JOptionPane.showMessageDialog(this, "No probes were selected", "No probes", 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 " + list.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, list.name());
if (groupName == null) {
// Remove the list which will have been created by this stage
list.delete();
// They cancelled
return;
}
if (groupName.length() == 0)
// Try again
continue;
break;
}
list.setName(groupName);
}
} else if (ae.getActionCommand().equals("save_image")) {
ImageSaver.saveImage(variancePlotPanel);
} else {
throw new IllegalArgumentException("Unknown command " + ae.getActionCommand());
}
}
use of uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet in project SeqMonk by s-andrews.
the class ReplicateSetEditor method actionPerformed.
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent ae) {
String c = ae.getActionCommand();
if (c.equals("add")) {
Object[] addObjs = availableList.getSelectedValues();
DataStore[] adds = new DataStore[addObjs.length];
for (int i = 0; i < adds.length; i++) {
adds[i] = (DataStore) addObjs[i];
}
usedModel.addElements(adds);
availableModel.removeElements(adds);
usedList.setSelectedIndices(new int[0]);
availableList.setSelectedIndices(new int[0]);
DataStore[] s = usedModel.getStores();
ReplicateSet r = (ReplicateSet) replicateSetList.getSelectedValue();
r.setDataStores(s);
} else if (c.equals("select_named")) {
new NameGatherer();
} else if (c.equals("remove")) {
Object[] addObjs = usedList.getSelectedValues();
DataStore[] adds = new DataStore[addObjs.length];
for (int i = 0; i < adds.length; i++) {
adds[i] = (DataStore) addObjs[i];
}
usedModel.removeElements(adds);
availableModel.addElements(adds);
usedList.setSelectedIndices(new int[0]);
availableList.setSelectedIndices(new int[0]);
DataStore[] s = usedModel.getStores();
ReplicateSet r = (ReplicateSet) replicateSetList.getSelectedValue();
r.setDataStores(s);
} else if (c.equals("new_set")) {
String setName = null;
while (true) {
setName = (String) JOptionPane.showInputDialog(this, "Enter set name", "Group Name", JOptionPane.QUESTION_MESSAGE, null, null, "New replicate set");
if (setName == null)
// They cancelled
return;
if (setName.length() == 0)
// Try again
continue;
break;
}
ReplicateSet s = new ReplicateSet(setName, new DataStore[0]);
application.dataCollection().addReplicateSet(s);
replicateSetModel.addElements(new DataStore[] { s });
} else if (c.equals("rename_set")) {
ReplicateSet s = (ReplicateSet) replicateSetList.getSelectedValue();
String setName = null;
while (true) {
setName = (String) JOptionPane.showInputDialog(this, "Enter set name", "Set Name", JOptionPane.QUESTION_MESSAGE, null, null, s.name());
// They cancelled
if (setName == null)
return;
if (setName.length() > 0)
break;
}
s.setName(setName);
replicateSetModel.setElementAt(s, replicateSetList.getSelectedIndex());
} else if (c.equals("delete_set")) {
Object[] o = replicateSetList.getSelectedValues();
ReplicateSet[] repSets = new ReplicateSet[o.length];
for (int i = 0; i < o.length; i++) {
repSets[i] = (ReplicateSet) o[i];
}
replicateSetModel.removeElements(repSets);
application.dataCollection().removeReplicateSets(repSets);
} else if (c.equals("close")) {
setVisible(false);
dispose();
}
}
use of uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet in project SeqMonk by s-andrews.
the class DataStoreTreeDialog method progressComplete.
public void progressComplete(String command, Object result) {
getContentPane().setLayout(new BorderLayout());
clusterPanel = new DataStoreClusterPanel((ClusterPair) result, stores, listName);
getContentPane().add(clusterPanel, BorderLayout.CENTER);
rValueSlider = new JSlider(JSlider.HORIZONTAL, 0, 1000, 0);
rValueSlider.setPaintTicks(true);
getContentPane().add(rValueSlider, BorderLayout.NORTH);
rValueSlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
clusterPanel.setRProportion(rValueSlider.getValue() / 1000f);
}
});
JPanel buttonPanel = new JPanel();
JButton closeButton = new JButton("Close");
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
});
buttonPanel.add(closeButton);
JButton saveImageButton = new JButton("Save Image");
saveImageButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ImageSaver.saveImage(clusterPanel);
}
});
buttonPanel.add(saveImageButton);
JButton createRepSetsButton = new JButton("Split data stores");
createRepSetsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int s = 0; s < stores.length; s++) {
if (stores[s] instanceof ReplicateSet) {
JOptionPane.showMessageDialog(DataStoreTreeDialog.this, "One of the stores you plotted is already a replicate set so you can't make a new set with it in.", "Can't split stores", JOptionPane.ERROR_MESSAGE);
return;
}
}
// TODO: Ask for min count per store
DataStore[][] splitStores = clusterPanel.getSplitStores(2);
for (int s = 0; s < splitStores.length; s++) {
SeqMonkApplication.getInstance().dataCollection().addReplicateSet(new ReplicateSet("Cluster Group " + (s + 1), splitStores[s]));
}
JOptionPane.showMessageDialog(DataStoreTreeDialog.this, "Created " + splitStores.length + " new replicate sets", "Splitting Complete", JOptionPane.INFORMATION_MESSAGE);
}
});
buttonPanel.add(createRepSetsButton);
JButton reorderStoresButton = new JButton("Reorder stores");
reorderStoresButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DataStore[] orderedStores = clusterPanel.getOrderedStores();
SeqMonkApplication.getInstance().setDrawnDataStores(orderedStores);
}
});
buttonPanel.add(reorderStoresButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
setSize(800, 800);
setLocationRelativeTo(SeqMonkApplication.getInstance());
setVisible(true);
}
Aggregations