@Override public void actionPerformed(ActionEvent arg0) { List<Xref> xrefs = standaloneEngine.getSwingEngine().getEngine().getActivePathway().getDataNodeXrefs(); Set<Xref> setRefs = new HashSet<Xref>(xrefs); DataInterface gex = standaloneEngine.getGexManager().getCurrentGex(); CachedData cache = standaloneEngine.getGexManager().getCachedData(); Collection<? extends ISample> names = null; Map<String, List<TissueResult>> data = new TreeMap<String, List<TissueResult>>(); try { names = gex.getOrderedSamples(); for (ISample is : names) { if (!is.getName().equals(" Gene Name")) { data.put(is.getName().trim(), new ArrayList<TissueResult>()); } } for (Xref ref : setRefs) { List<? extends IRow> pwData = cache.syncGet(ref); if (!pwData.isEmpty()) { for (ISample is : names) { for (IRow ir : pwData) { if (!is.getName().equals(" Gene Name")) { Double value = (Double) ir.getSampleData(is); String dd = ir.getXref().getId(); TissueResult tr = new TissueResult(dd, value); data.get(is.getName().trim()).add(tr); } } } } } } catch (DataException e) { e.printStackTrace(); } catch (IDMapperException e) { e.printStackTrace(); } Vector<Double> vP = new Vector<Double>(); Vector<Double> vM = new Vector<Double>(); for (Entry<String, List<TissueResult>> entry : data.entrySet()) { int length = entry.getValue().size(); double i = 0; double tmp = 0; for (TissueResult tr : entry.getValue()) { if (tr.getExpression() >= (2 / Math.log10(2))) { i++; } tmp += tr.getExpression(); } vP.add(i / length * 100); vM.add(tmp / length); } dtm.addCollum(vP, 2); dtm.addCollum(vM, 3); }
@Override public void tableChanged(TableModelEvent arg0) { VisualizationManager visMgr = standaloneEngine.getVisualizationManager(); ColorSetManager csmgr = visMgr.getColorSetManager(); ColorSet cs = new ColorSet(csmgr); csmgr.addColorSet(cs); ColorGradient gradient = new ColorGradient(); cs.setGradient(gradient); double lowerbound = 3; double upperbound = 10; gradient.addColorValuePair(new ColorValuePair(new Color(218, 242, 249), lowerbound)); gradient.addColorValuePair(new ColorValuePair(new Color(0, 0, 255), upperbound)); Visualization v = new Visualization("auto-generated"); ColorByExpression cby = new ColorByExpression( standaloneEngine.getGexManager(), standaloneEngine.getVisualizationManager().getColorSetManager()); DataInterface gex = standaloneEngine.getGexManager().getCurrentGex(); Map<Integer, ? extends ISample> samplesMap = null; try { samplesMap = gex.getSamples(); } catch (DataException e1) { e1.printStackTrace(); } for (Entry<Integer, ? extends ISample> entry : samplesMap.entrySet()) { ISample valeur = entry.getValue(); String tissues = valeur.getName().trim(); for (int i = 0; i < vT.size(); i++) { if (vB.get(i) && vT.get(i).equals(tissues)) { cby.addUseSample(valeur); } } } cby.setSingleColorSet(cs); v.addMethod(cby); DataNodeLabel dnl = new DataNodeLabel(); v.addMethod(dnl); visMgr.removeVisualization(v); visMgr.addVisualization(v); visMgr.setActiveVisualization(v); }