source: trunk/www/views/experiments/explorer/view/view.jsp @ 5139

Last change on this file since 5139 was 5139, checked in by Nicklas Nordborg, 13 years ago

References #1388: Display the count for each group in the annotation summary in experiment explorer

The 'count' was only visible for 2-channel experiments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 27.7 KB
Line 
1<%-- $Id: view.jsp 5139 2009-10-19 06:22:34Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Johan Enell, Nicklas Nordborg
4  Copyright (C) 2007 Nicklas Nordborg
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.PropertyFilter"
32  import="net.sf.basedb.core.Include"
33  import="net.sf.basedb.core.BioAssaySet"
34  import="net.sf.basedb.core.BioAssay"
35  import="net.sf.basedb.core.Experiment"
36  import="net.sf.basedb.core.RawDataType"
37  import="net.sf.basedb.core.RawBioAssay"
38  import="net.sf.basedb.core.RawDataUtil"
39  import="net.sf.basedb.core.ExtendedProperties"
40  import="net.sf.basedb.core.ExtendedProperty"
41  import="net.sf.basedb.core.AnnotationType"
42  import="net.sf.basedb.core.Annotation"
43  import="net.sf.basedb.core.Formula"
44  import="net.sf.basedb.core.IntensityTransform"
45  import="net.sf.basedb.core.ItemQuery"
46  import="net.sf.basedb.core.ItemResultList"
47  import="net.sf.basedb.core.DynamicSpotQuery"
48  import="net.sf.basedb.core.DynamicResultIterator"
49  import="net.sf.basedb.core.VirtualColumn"
50  import="net.sf.basedb.core.Type"
51  import="net.sf.basedb.core.data.ReporterData"
52  import="net.sf.basedb.core.data.RawData"
53  import="net.sf.basedb.core.query.Restrictions"
54  import="net.sf.basedb.core.query.Expressions"
55  import="net.sf.basedb.core.query.Dynamic"
56  import="net.sf.basedb.core.query.Orders"
57  import="net.sf.basedb.core.query.Selects"
58  import="net.sf.basedb.core.query.Aggregations"
59  import="net.sf.basedb.core.query.Hql"
60  import="net.sf.basedb.core.query.JoinType"
61  import="net.sf.basedb.core.query.SqlResult"
62  import="net.sf.basedb.util.Values"
63  import="net.sf.basedb.clients.web.Base"
64  import="net.sf.basedb.clients.web.DynamicUtil"
65  import="net.sf.basedb.clients.web.ExperimentExplorer"
66  import="net.sf.basedb.clients.web.ExperimentExplorer.AnnotationSummary"
67  import="net.sf.basedb.clients.web.ExperimentExplorer.AnnotationGroup"
68  import="net.sf.basedb.clients.web.WebException"
69  import="net.sf.basedb.clients.web.util.HTML"
70  import="net.sf.basedb.util.formatter.Formatter"
71  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
72  import="net.sf.basedb.clients.web.formatter.SpotImageFormatter"
73  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
74  import="java.util.Date"
75  import="java.util.List"
76  import="java.util.ArrayList"
77  import="java.util.LinkedList"
78  import="java.util.Collection"
79  import="java.util.Arrays"
80  import="java.util.Set"
81  import="java.util.Map"
82  import="java.util.HashMap"
83%>
84<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
85<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
86<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
87<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
88<%!
89  private static final Item itemType = Item.SPOTDATA;
90  private static final String defaultReporterColumns = "name,externalId,symbol,description";
91%>
92<%
93final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
94final String ID = sc.getId();
95final float scale = Base.getScale(sc);
96final String root = request.getContextPath();
97
98final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
99final DbControl dc = sc.newDbControl();
100DynamicResultIterator spotData = null;
101try
102{
103  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
104  String title = null;
105  final BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId);
106  final Experiment experiment = bioAssaySet.getExperiment();
107  final RawDataType rawDataType = experiment.getRawDataType();
108  final int channels = rawDataType.getChannels();
109  final boolean hasRatio = channels == 2;
110  final int maxRawMappings = bioAssaySet.getMaxRawMappingsForSpot();
111  final IntensityTransform transform = bioAssaySet.getIntensityTransform();
112 
113  final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet);
114  final ItemContext cc = explorer.getAndSetSpotContext(sc, pageContext);
115  final ItemContext reporterContext = explorer.getAndSetReporterContext(sc, null);
116  final String subContext = cc.getSubContext();
117 
118  List<TableColumn> columns = new LinkedList<TableColumn>();
119  DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, 
120    transform, "frm.", "", maxRawMappings == 1);
121  DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] ");
122  if (maxRawMappings == 1)
123  {
124    DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] ");
125    columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT, 
126      "[Raw] Spotimage", "", "auto", false, false, false, null, 
127      new SpotImageFormatter(dc, rawDataType, root)));
128  }
129
130  final int matchingReporters = explorer.getMatchingReporters(dc);
131  int reporterIndex = explorer.getReporterIndex();
132  if (reporterIndex >= matchingReporters) reporterIndex = matchingReporters - 1;
133  final ReporterData reporter = matchingReporters == 0 ? 
134      null : explorer.getReporter(dc, reporterIndex);
135
136  final int matchingPositions = matchingReporters == 0 ? 
137      0 : explorer.getNumPositions(dc, reporterIndex);
138 
139  int positionIndex = explorer.getPositionIndex();
140  if (positionIndex >= matchingPositions) positionIndex = matchingPositions - 1;
141  final boolean isAveraging = positionIndex == ExperimentExplorer.SPOT_AVG;
142 
143  final List<AnnotationType> annotationTypes = explorer.getAnnotationTypes(dc, true);
144  final Set<Integer> tmp = explorer.getAnnotationTypeIds();
145  final Map<AnnotationType, AnnotationSummary> selectedAnnotationTypes = 
146    new HashMap<AnnotationType, AnnotationSummary>(tmp.size());
147  for (Integer atId : tmp)
148  {
149    try
150    {
151      selectedAnnotationTypes.put(AnnotationType.getById(dc, atId), null);
152    }
153    catch (Throwable t)
154    {}
155  }
156
157  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, isAveraging);
158 
159  List<String> sortProperties = null;
160  if (isAveraging && cc.getSortProperty() != null)
161  {
162    // We must check that we are not sorting on a non-averagable property
163    sortProperties = new ArrayList<String>(Arrays.asList(cc.getSortProperty().split(",")));
164    for (TableColumn tc : columns)
165    {
166      if (!tc.isAveragable()) sortProperties.remove(tc.getProperty());
167    }
168    cc.setSortProperty(Values.getString(sortProperties, ",", true));
169  }
170 
171  if (matchingReporters > 0)
172  {
173    for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
174    {
175      entry.setValue(explorer.getAnnotationSummary(dc, entry.getKey()));
176    }
177    try
178    {
179      DynamicSpotQuery spotQuery = explorer.getSpotQuery(dc, reporterIndex, positionIndex, selected.selectedColumns);
180      spotData = spotQuery.iterate(dc);
181    }
182    catch (Throwable t)
183    {
184      cc.setMessage(t.getMessage());
185    }
186  }
187  %>
188  <base:page title="<%=title%>">
189  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css,explorer.css">
190  <script language="JavaScript">
191    var submitPage = 'index.jsp';
192    var formId = 'spotdata';
193    function configureColumns()
194    {
195      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
196    }
197    function configureReporterColumns()
198    {
199      var frm = document.forms['reporter'];
200      frm.cmd.value = 'SetReporterColumns';
201      Table.configureColumns('<%=ID%>', 'reporter', '<%=itemType.name()%>', '<%=defaultReporterColumns%>', '<%=subContext%>', 'reporter-columns');
202    }
203    function presetOnChange()
204    {
205      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
206    }
207    function validateReporterIndex()
208    {
209      var frm = document.forms['reporterIndex'];
210      var reporterIndex = parseInt(frm.newReporterIndex.value);
211      var maxIndex = <%=matchingReporters%>;
212      if (reporterIndex < 1 || reporterIndex > maxIndex)
213      {
214        alert('The reporter index must be between 1 and ' + maxIndex);
215        return false;
216      }
217      frm.cmd.value = 'SetReporterIndex';
218      Forms.createHidden(frm, 'reporterIndex', reporterIndex-1);
219      return true;
220    }
221    function validateSpotIndex()
222    {
223      var frm = document.forms['spotIndex'];
224      var spotIndex = parseInt(frm.newSpotIndex.value);
225      var maxIndex = <%=matchingPositions%>;
226      if (spotIndex < 1 || spotIndex > maxIndex)
227      {
228        alert('The spot index must be between 1 and ' + maxIndex);
229        return false;
230      }
231      frm.cmd.value = 'SetSpotIndex';
232      Forms.createHidden(frm, 'spotIndex', spotIndex-1);
233      return true;
234    }
235    function annotationTypeOnChange()
236    {
237      var frm = document.forms['explorer'];
238      frm.cmd.value = 'SetAnnotationType';
239      frm.submit();
240    }
241    function viewSearch()
242    {
243      location.href = '../search/index.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>';
244    }
245    function switchTab(tabControlId, tabId)
246    {
247      if (tabId == 'search')
248      {
249        viewSearch();
250      }
251      else
252      {
253        TabControl.setActiveTab(tabControlId, tabId);
254      }
255    }
256    function plotSpotData()
257    {
258      var url = 'plotter.jsp?ID=<%=ID%>&type=line';
259      url += '&bioAssaySetId=<%=bioAssaySetId%>';
260      url += '&reporterIndex=<%=reporterIndex%>';
261      url += '&positionIndex=<%=positionIndex%>';
262      Main.openPopup(url, 'SpotPlot', 1100, 700);
263    }
264    function boxPlot(annotationType)
265    {
266      var url = 'plotter.jsp?ID=<%=ID%>&type=box';
267      url += '&bioAssaySetId=<%=bioAssaySetId%>';
268      url += '&reporterIndex=<%=reporterIndex%>';
269      url += '&positionIndex=<%=positionIndex%>';
270      url += '&annotationTypeId=' + annotationType;
271      Main.openPopup(url, 'BoxPlot', 1100, 700);
272    }
273  </script>
274  </base:head>
275  <base:body>
276    <p>
277    <p:path>
278      <p:pathelement title="Experiments" href="<%="../../index.jsp?ID="+ID%>" />
279      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" 
280        href="<%="../../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" />
281      <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" 
282        href="<%="../../bioassaysets/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+bioAssaySetId%>" />
283      <p:pathelement title="Explorer" />
284    </p:path>
285   
286    <t:tabcontrol id="explorer" switch="switchTab" remember="false" active="view">
287    <t:tab id="search" title="Reporter search" />
288   
289    <t:tab id="view" title="Reporter view">
290    <div class="boxed">
291   
292    <%
293    Collection<PropertyFilter> filters = reporterContext.getPropertyFilters();
294    String filter = filters != null && filters.size() > 0 ? 
295      "(" + Values.getString(filters, ") AND (", true).replaceAll("@|£", "") + ")" : "- none -";
296    %>
297    <table class="form">
298    <tr>
299      <td class="prompt">Filter</td>
300      <td>
301      <%=HTML.encodeTags(filter)%>
302      </td>
303    </tr>
304    </table>
305   
306   
307    <%
308    if (reporter != null)
309    {
310      %>
311      <form name="reporterIndex" action="index.jsp" method="post">
312      <input type="hidden" name="ID" value="<%=ID%>">
313      <input type="hidden" name="bioassayset_id" value="<%=bioAssaySetId%>">
314      <input type="hidden" name="cmd" value="SetReporterIndex">
315      <h4 class="docked">Current reporter
316            <input name="newReporterIndex" type="text" class="text" value="<%=reporterIndex+1%>" 
317        onkeypress="return Numbers.integerOnly(event, true, validateReporterIndex)"
318        size="6" maxlength="8" title="Enter a number between 1 and <%=matchingReporters%>">
319      of <%=matchingReporters %>
320      <%
321      if (reporterIndex == 0 || matchingReporters == 0)
322      {
323        %>
324        <base:icon image="first_gray.gif" />
325        <base:icon image="previous_gray.gif" />
326        <%
327      }
328      else
329      {
330        %>
331        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=0"
332          title="Go the first reporter"><base:icon image="first.gif" /></a>
333        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=<%=reporterIndex-1%>"
334          title="Go the previous reporter"><base:icon image="previous.gif" /></a>
335        <%
336      }
337      %>
338      &nbsp;&nbsp;
339      <%
340      if (reporterIndex == matchingReporters - 1 || matchingReporters == 0)
341      {
342        %>
343        <base:icon image="next_gray.gif" />
344        <base:icon image="last_gray.gif" />
345        <%
346      }
347      else
348      {
349        %>
350        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=<%=reporterIndex+1%>"
351          title="Go the next reporter"><base:icon image="next.gif" /></a>
352        <a href="index.jsp?ID=<%=ID%>&cmd=SetReporterIndex&bioassayset_id=<%=bioAssaySetId%>&reporterIndex=<%=matchingReporters-1%>"
353          title="Go the last reporter"><base:icon image="last.gif" /></a>
354        <%
355      }
356      %>
357      </h4>
358      </form>
359     
360      <tbl:toolbar>
361        <tbl:button 
362          image="columns.gif" 
363          onclick="configureReporterColumns()" 
364          title="Columns&hellip;" 
365          tooltip="Show, hide and re-order reporter columns" 
366        />
367      </tbl:toolbar>
368   
369    <div class="boxedbottom">
370    <tbl:table 
371      id="reporter" 
372      clazz="form" 
373      columns="<%=Values.getString(cc.getSetting("reporter-columns"), defaultReporterColumns)%>"
374      action="index.jsp"
375      sc="<%=sc%>"
376      item="<%=itemType%>"
377      subcontext="<%=subContext%>"
378      >
379      <tbl:hidden 
380        name="bioassayset_id" 
381        value="<%=String.valueOf(bioAssaySetId)%>" 
382      />
383      <tbl:columndef id="name" title="Name" show="always" clazz="prompt"/>
384      <tbl:columndef id="externalId" title="External ID" clazz="prompt"/>
385      <tbl:columndef id="symbol" title="Gene symbol" clazz="prompt"/>
386      <tbl:columndef id="lastUpdate" title="Last update" clazz="prompt"/>
387      <tbl:columndef id="type" title="Type" clazz="prompt"/>
388      <tbl:columndef id="description" title="Description" clazz="prompt"/>
389      <%
390      List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
391      if (reporterProperties != null)
392      {
393        for (ExtendedProperty ep : reporterProperties)
394        {
395          String name = ep.getName();
396          Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
397          %>
398          <tbl:columndef 
399            id="<%=ep.getName()%>" 
400            title="<%=HTML.encodeTags(ep.getTitle())%>" 
401            clazz="prompt" 
402            formatter="<%=formatter%>"
403          />
404          <%
405        }
406      }
407      %>
408      <tbl:form width="2">
409        <tbl:cell column="name"><%=Base.getLink(ID, reporter.getName(), Item.REPORTER, reporter.getId(), true)%></tbl:cell>
410        <tbl:cell column="externalId"><%=HTML.encodeTags(reporter.getExternalId())%></tbl:cell>
411        <tbl:cell column="symbol"><%=HTML.encodeTags(reporter.getSymbol())%></tbl:cell>
412        <tbl:cell column="lastUpdate"><%=dateFormatter.format(reporter.getLastUpdate())%></tbl:cell>
413        <tbl:cell column="type"><base:propertyvalue dbcontrol="<%=dc%>" item="<%=reporter%>" property="reporterType" /></tbl:cell>
414        <tbl:cell column="description"><%=HTML.niceFormat(reporter.getDescription())%></tbl:cell>
415        <%
416        if (reporterProperties != null)
417        {
418          for (ExtendedProperty ep : reporterProperties)
419          {
420            String name = ep.getName();
421            Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
422            %>
423            <tbl:cell column="<%=ep.getName()%>"><tbl:cellvalue value="<%=reporter.getExtended(name)%>" /></tbl:cell>
424            <%
425          }
426        }
427        %>
428      </tbl:form>
429    </tbl:table>
430    </div>
431    <%
432    }
433    else
434    {
435      %>
436      No reporters found.
437      <%
438    }
439    %>
440   
441    <base:section
442      id="annotation"
443      title="<%="Annotation summary (" + selectedAnnotationTypes.size() + " selected)"%>"
444      context="<%=cc%>"
445      >
446      <form name="annotationSummary" action="index.jsp" method="POST" onsubmit="return false;">
447      <input type="hidden" name="ID" value="<%=ID%>">
448      <input type="hidden" name="bioassayset_id" value="<%=bioAssaySetId%>">
449      <input type="hidden" name="cmd" value="SetAnnotationType">
450        <table border="0" cellspacing="0" cellpadding="0"><tr><td>
451        <div class="multiselect">
452          <input type="text" class="text" size="40" name="display:annotationTypes"
453            title="Click to select experimental factor"><img 
454            class="smartimage" src="../../../../images/pull_down.gif" 
455            onclick="MultiOptions.activateAndDisplay('annotationSummary','display:annotationTypes')"></div>
456          <input type="hidden" name="annotationtype_id" value="">
457          </td></tr></table>
458        <%
459        if (selectedAnnotationTypes.size() > 0)
460        {
461          for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
462          {
463            AnnotationType at = entry.getKey();
464            AnnotationSummary summary = entry.getValue();
465            %>
466            <table border="0" cellspacing="0" cellpadding="2" class="annotationsummary">
467            <tr>
468              <td class="summaryheader"><%=Base.getLinkedName(ID, at, false, true)%></td>
469              <td class="summaryheader"><base:icon
470                image="plotter.gif"
471                onclick="<%="boxPlot(" + at.getId() + ")"%>"
472                tooltip="Box plot for selected spot data per annotation group"
473              /></td>
474              <%
475              for (AnnotationGroup ag : summary.getAnnotationGroups())
476              {
477                %>
478                <td class="groupheader" style="background: <%=ag.getColor()%>;" width="50px">
479                <%=ag.getTitle()%>
480                </td>
481                <%
482              }
483              %>
484              </tr>
485              <%
486              for (int ch = 1; ch <= channels; ++ch)
487              {
488                %>
489                <tr>
490                <td colspan="2">Mean ch <%=ch%> int.</td>
491                <%
492                for (AnnotationGroup ag : summary.getAnnotationGroups())
493                {
494                  %>
495                  <td class="value" style="background: <%=ag.getColor()%>;"><div id="mean.<%=at.getId()%>.<%=ag.getId()%>.ch<%=ch%>"><%=ag.getMean(ch)%></div></td>
496                  <%
497                }
498                %>
499                </tr>
500                <%
501              }
502              if (hasRatio)
503              {
504                %>
505                <tr>
506                <td colspan="2" title="The geometric mean of the ratios">G. mean ratio</td>
507                <%
508                for (AnnotationGroup ag : summary.getAnnotationGroups())
509                {
510                  %>
511                  <td class="value" style="background: <%=ag.getColor()%>;"><div id="gmean.<%=at.getId()%>.<%=ag.getId()%>"></div></td>
512                  <%
513                }
514                %>
515                </tr>
516                <tr>
517                <td colspan="2" title="Standard deviation of log2 ratios">log2ratio SD</td>
518                <%
519                for (AnnotationGroup ag : summary.getAnnotationGroups())
520                {
521                  %>
522                  <td class="value" style="background: <%=ag.getColor()%>;"><div id="sd.<%=at.getId()%>.<%=ag.getId()%>"></div></td>
523                  <%
524                }
525                %>
526                </tr>
527                <%
528              }
529              %>
530              <tr>
531              <td colspan="2" title="The number of spots falling in this group">Count</td>
532              <%
533              for (AnnotationGroup ag : summary.getAnnotationGroups())
534              {
535                %>
536                <td class="value" style="background: <%=ag.getColor()%>;"><div id="count.<%=at.getId()%>.<%=ag.getId()%>">0</div></td>
537                <%
538              }
539              %>
540              </tr>
541            </table>
542            <%
543          }
544        }
545        %>
546        </form>
547    </base:section>
548
549    <form name="spotIndex" action="index.jsp" method="post">
550    <input type="hidden" name="ID" value="<%=ID%>">
551    <input type="hidden" name="bioassayset_id" value="<%=bioAssaySetId%>">
552    <input type="hidden" name="cmd" value="SetSpotIndex">
553   
554      <h4 class="docked">Current spot
555      <input name="newSpotIndex" type="text" class="text" value="<%=positionIndex == -1 ? "all" : positionIndex == -2 ? "avg" : String.valueOf(positionIndex+1)%>" 
556        onkeypress="return Numbers.integerOnly(event, true, validateSpotIndex)"
557        size="6" maxlength="8" title="Enter a number between 1 and <%=matchingPositions%>">
558        of <%=matchingPositions%>
559     
560        <%
561        if (positionIndex == 0)
562        {
563          %>
564          <base:icon image="first_gray.gif" />
565          <%
566        }
567        else
568        {
569          %>
570          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=0"
571            title="Go the first position"><base:icon image="first.gif" /></a>
572          <%
573        }
574        if (positionIndex <= 0)
575        {
576          %>
577          <base:icon image="previous_gray.gif" />
578          <%
579        }
580        else
581        {
582          %>
583          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=<%=positionIndex-1%>"
584            title="Go the previous position"><base:icon image="previous.gif" /></a>
585          <%
586        }
587        %>
588        &nbsp;&nbsp;
589        <%
590        if (positionIndex == matchingPositions - 1 || positionIndex < 0)
591        {
592          %>
593          <base:icon image="next_gray.gif" />
594          <%
595        }
596        else
597        {
598          %>
599          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=<%=positionIndex+1%>"
600            title="Go the next position"><base:icon image="next.gif" /></a>
601          <%
602        }
603        if (positionIndex == matchingPositions - 1)
604        {
605          %>
606          <base:icon image="last_gray.gif" />
607          <%
608        }
609        else
610        {
611          %>
612          <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=<%=matchingPositions-1%>"
613            title="Go the last position"><base:icon image="last.gif" /></a>
614          <%
615        }
616        %>
617        [ <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-1"
618          title="Show all positions">all</a>
619        | <a href="index.jsp?ID=<%=ID%>&cmd=SetSpotIndex&bioassayset_id=<%=bioAssaySetId%>&spotIndex=-2"
620          title="Calculate average values for each bioassay">avg</a>
621        ]
622        </h4>
623     
624      </form>
625    <%
626    if (cc.getMessage() != null)
627    {
628      %>
629      <div class="error"><%=cc.getMessage()%></div>
630      <%
631      cc.setMessage(null);
632    }
633    %>
634   
635    <%
636    if (spotData != null)
637    {
638      Formatter<Number> numberFormatter = FormatterFactory.getNumberFormatter(sc);
639      %>
640
641    <tbl:table 
642      id="spotdata" 
643      clazz="itemlist" 
644      columns="<%=cc.getSetting("columns")%>"
645      sortby="<%=cc.getSortProperty()%>" 
646      direction="<%=cc.getSortDirection()%>"
647      title="<%=title%>"
648      action="index.jsp"
649      sc="<%=sc%>"
650      item="<%=itemType%>"
651      subcontext="<%=subContext%>"
652      >
653      <tbl:hidden 
654        name="bioassayset_id" 
655        value="<%=String.valueOf(bioAssaySetId)%>" 
656      />
657      <%
658      for (AnnotationType at : selectedAnnotationTypes.keySet())
659      {
660        %>
661        <tbl:columndef
662          id="<%="annotation." + at.getId()%>"
663          title="<%=HTML.encodeTags(at.getName()) %>"
664          show="always"
665        />
666        <%
667      }
668      %>
669      <tbl:columndef
670        id="bioassay"
671        property="COLUMN"
672        title="Bioassay"
673        show="always"
674        sortable="true"
675      />
676      <tbl:columndef
677        id="position"
678        property="POSITION"
679        title="Position"
680        show="<%=isAveraging ? "never" : "always" %>"
681        sortable="true"
682      />
683      <tbl:columndef
684        id="count"
685        title="Count"
686        show="<%=isAveraging ? "always" : "never" %>"
687      />
688      <%
689      for (int ch = 1; ch <= channels; ++ch)
690      {
691        %>
692        <tbl:columndef
693          id="<%="ch"+ch%>"
694          property="<%="%"+ch%>"
695          datatype="float"
696          title="<%="Ch " + ch%>"
697          tooltip="<%=transform.isTransformed() ? transform.toString() : null %>"
698          sortable="true"
699          filterable="true"
700          exportable="true"
701          formatter="<%=numberFormatter%>"
702        />
703        <%
704      }
705      %>
706      <%
707      for (TableColumn tc : columns)
708      {
709        %>
710        <tbl:columndef
711          id="<%=tc.getId()%>"
712          property="<%=tc.getProperty()%>"
713          datatype="<%=tc.getDatatype().getStringValue()%>"
714          title="<%=HTML.encodeTags(tc.getTitle())%>"
715          sortable="<%=tc.getSortable()%>"
716          filterable="<%=tc.getFilterable()%>"
717          exportable="<%=tc.getExportable()%>"
718          show="<%=!isAveraging || tc.isAveragable() ? tc.getShow() : "never"%>"
719          formatter="<%=tc.getFormatter()%>"
720        />
721        <%
722      }
723      %>
724       
725      <tbl:toolbar>
726        <tbl:button 
727          image="columns.gif" 
728          onclick="configureColumns()" 
729          title="Columns&hellip;" 
730          tooltip="Show, hide and re-order columns" 
731        />
732        <tbl:button 
733          image="plotter.gif"
734          onclick="plotSpotData()"
735          title="Plot&hellip;"
736          tooltip="Plot selected data from this table"
737        />
738      </tbl:toolbar>
739      <tbl:data>
740        <tbl:columns />
741        <tbl:rows>
742        <%
743        int index = 0;
744        float[] intensity = new float[channels+1];
745        while (spotData.hasNext())
746        {
747          SqlResult item = spotData.next();
748          index++;
749          BioAssay bioAssay = explorer.getBioAssay(dc, item.getShort(1));
750          for (int ch = 1; ch <= channels; ++ch)
751          {
752            intensity[ch] = item.getFloat(2+ch);
753          }
754          %>
755          <tbl:row>
756            <%
757            for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
758            {
759              AnnotationType at = entry.getKey();
760              AnnotationGroup annotationGroup = entry.getValue().getAnnotationGroup(bioAssay.getDataCubeColumnNo());
761              String allValues = annotationGroup.getTitle();
762              if (hasRatio)
763              {
764                float logRatio = (float)(Math.log(transform.unTransform(intensity[1]) / transform.unTransform(intensity[2])));
765                annotationGroup.addStatistics("logratio", logRatio);
766                annotationGroup.addStatistics("logratio2", logRatio * logRatio);
767              }
768              for (int ch = 1; ch <= channels; ++ch)
769              {
770                annotationGroup.addValue(ch, (float)transform.unTransform(intensity[ch]));
771              }
772              %>
773              <tbl:cell column="<%="annotation."+at.getId()%>" style="<%="background: "+annotationGroup.getColor()+";"%>">
774              <%=allValues%>
775              </tbl:cell>
776              <%
777            }
778            %>
779            <tbl:cell column="bioassay"><%=Base.getLinkedName(ID, bioAssay, false, true)%></tbl:cell>
780            <tbl:cell column="position"><%=item.getInt(2)%></tbl:cell>
781            <tbl:cell column="count"><%=item.getInt(2)%></tbl:cell>
782            <%
783            for (int ch = 1; ch <= channels; ++ch)
784            {
785              %>
786              <tbl:cell column="<%="ch" + ch%>" value="<%=intensity[ch]%>" />
787              <%
788            }
789            %>
790            <%
791            int colIndex = 3 + channels;
792            for (String columnId : selected.selectedIds)
793            {
794              %>
795              <tbl:cell column="<%=columnId%>" value="<%=item.getObject(colIndex++)%>" />
796              <%
797            }
798            %>
799          </tbl:row>
800          <%
801        }
802      %>
803      </tbl:rows>
804      </tbl:data>
805      </tbl:table>
806      </div>
807      <%
808      }
809      %>
810      <script language="JavaScript" defer="defer">
811      <%
812      for (Map.Entry<AnnotationType, AnnotationSummary> entry : selectedAnnotationTypes.entrySet())
813      {
814        AnnotationType at = entry.getKey();
815        AnnotationSummary summary = entry.getValue();
816        %>
817        <%
818        for (AnnotationGroup ag : summary.getAnnotationGroups())
819        {
820          for (int ch = 1; ch <= channels; ++ch)
821          {
822            %>
823            var div = document.getElementById('mean.<%=at.getId()%>.<%=ag.getId()%>.ch<%=ch%>');
824            div.innerHTML = '<%=Values.formatNumber(ag.getMean(ch), 2)%>';
825            <%
826          }
827          %>
828          var div = document.getElementById('count.<%=at.getId()%>.<%=ag.getId()%>');
829          div.innerHTML = '<%=ag.getCount(1)%>';
830          <%
831          if (hasRatio)
832          {
833            float r = ag.getStatistics("logratio");
834            int count = ag.getCount(1);
835            float gMean = count > 0 ? (float)Math.exp(r / count) : Float.NaN;
836            float sd = count > 1 ? 
837              (float)Math.sqrt((ag.getStatistics("logratio2") - r * (r / count))/(count-1))
838              : Float.NaN;
839            %>
840            var div = document.getElementById('gmean.<%=at.getId()%>.<%=ag.getId()%>');
841            div.innerHTML = '<%=Values.formatNumber(gMean, 2)%>';
842            var div = document.getElementById('sd.<%=at.getId()%>.<%=ag.getId()%>');
843            div.innerHTML = '<%=Values.formatNumber(sd, 2)%>';
844            <%
845          }
846        }
847      }
848      %>
849      MultiOptions.init();
850      var options = new Array();
851      <%
852      if (annotationTypes != null)
853      {
854        for (AnnotationType at : annotationTypes)
855        {
856          String isSelected = selectedAnnotationTypes.containsKey(at) ? "true" : "false";
857          %>
858          options[options.length] = {key:'<%=at.getId()%>', value:'<%=HTML.javaScriptEncode(at.getName())%>', selected:<%=isSelected%>};
859          <%
860        }
861      }
862      %>
863      MultiOptions.enableForField('annotationSummary', 'display:annotationTypes', 'annotationtype_id', 1, options);
864      </script>
865     
866      </t:tab>
867      </t:tabcontrol>
868
869  </base:body>
870  </base:page>
871  <%
872}
873finally
874{
875  if (spotData != null) spotData.close();
876  if (dc != null) dc.close();
877}
878
879%>
Note: See TracBrowser for help on using the repository browser.