Changeset 4913


Ignore:
Timestamp:
Apr 29, 2009, 2:54:49 PM (13 years ago)
Author:
Nicklas Nordborg
Message:

References #1120: The dynamic part of BASE should keep track whether intensity data is in log space or not

BioAssaySetExporter? can now handle transformed data.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/IntensityTransform.java

    r4912 r4913  
    4141    No transformation has been applied to the spot intensities.
    4242  */
    43   NONE(0, "None", false)
     43  NONE(0, "None", false, Formula.AverageMethod.ARITHMETIC_MEAN)
    4444  {
    4545    /**
     
    6464    Spot intensities are stored as base-2 logged values
    6565  */
    66   LOG2(1, "Logarithmic (base-2)", true)
     66  LOG2(1, "Logarithmic (base-2)", true, Formula.AverageMethod.GEOMETRIC_MEAN)
    6767  {
    6868    /**
     
    8787    Spot intensities are stored as base-10 logged values
    8888  */
    89   LOG10(2, "Logarithmic (base-10)", true)
     89  LOG10(2, "Logarithmic (base-10)", true, Formula.AverageMethod.GEOMETRIC_MEAN)
    9090  {
    9191    /**
     
    136136  private final boolean isTransformed;
    137137 
     138  private final Formula.AverageMethod averageMethod;
     139 
    138140  /**
    139141    Creates a new intensity transform. Used internal only.
    140142    @param value The integer value of this location.
    141143  */
    142   private IntensityTransform(int value, String displayValue, boolean isTransformed)
     144  private IntensityTransform(int value, String displayValue,
     145      boolean isTransformed, Formula.AverageMethod averageMethod)
    143146  {
    144147    this.value = value;
    145148    this.displayValue = displayValue;
    146149    this.isTransformed = isTransformed;
     150    this.averageMethod = averageMethod;
    147151  }
    148152 
     
    186190 
    187191  /**
     192    Get the averaging method to use when averaging values
     193    that has been transformed with the specified transformation.
     194    @return An average method
     195  */
     196  public Formula.AverageMethod getAverageMethod()
     197  {
     198    return averageMethod;
     199  }
     200 
     201  /**
    188202    Un-transform an expression representing a transformed intensity
    189203    value so that it represents a raw intensity value. This method
  • trunk/src/core/net/sf/basedb/core/VirtualColumn.java

    r4912 r4913  
    195195  public static VirtualColumn channelRaw(int channel)
    196196  {
    197     return new VirtualColumn("ch"+channel, "ch"+channel, Hibernate.FLOAT, 0,
     197    return new VirtualColumn("rch"+channel, "ch"+channel, Hibernate.FLOAT, 0,
    198198          !INDEXED, NULLABLE, !PRIMARY_KEY, false);
    199199  }
  • trunk/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java

    r4889 r4913  
    4545import net.sf.basedb.core.Formula;
    4646import net.sf.basedb.core.Include;
     47import net.sf.basedb.core.IntensityTransform;
    4748import net.sf.basedb.core.Item;
    4849import net.sf.basedb.core.ItemParameterType;
     
    801802    for (int i=1; i<=nofchannels; ++i)
    802803    {
    803       query.select(Dynamic.select(VirtualColumn.channel(i)));
     804      query.select(Dynamic.select(VirtualColumn.channelRaw(i)));
    804805    }
    805806    query.order(Orders.asc(Dynamic.column(VirtualColumn.POSITION)));
     
    812813    for (int i=1; i<=nofchannels; ++i)
    813814    {
    814       column_channel[i-1] = spotData.getIndex(VirtualColumn.channel(i).getName());
     815      column_channel[i-1] = spotData.getIndex(VirtualColumn.channelRaw(i).getName());
    815816    }
    816817    int position = -1;
     
    819820    int progress_report_interval = nof_reporters/10;
    820821    long nof_processed_reporters = 0;
     822    IntensityTransform transform = bioassayset.getIntensityTransform();
     823    boolean isLogged = transform == IntensityTransform.LOG10 ||
     824      transform == IntensityTransform.LOG2;
    821825    while (spotData.hasNext())
    822826    {
     
    860864      {
    861865        double ch2 = item.getFloat(column_channel[1]);
    862         if (ch2 != 0)
    863         {
    864           ch1 /= ch2;
    865           if (ch1 <= 0)
     866        if (isLogged)
     867        {
     868          ch1 -= ch2;
     869        }
     870        else
     871        {
     872          if (ch2 != 0)
     873          {
     874            ch1 /= ch2;
     875            if (ch1 <= 0) goodvalue = false;
     876          }
     877          else
    866878          {
    867879            goodvalue = false;
    868880          }
    869         }
    870         else
    871         {
    872           goodvalue = false;
    873881        }
    874882      }
     
    936944    for (int i=1; i<=nof_channels; ++i)
    937945    {
    938       query.select(Dynamic.select(VirtualColumn.channel(i)));
     946      query.select(Dynamic.select(VirtualColumn.channelRaw(i)));
    939947    }
    940948
     
    949957    for (int i=0; i<nof_channels; ++i)
    950958    {
    951       column_channel[i]=spotData.getIndex(VirtualColumn.channel(i+1).getName());
     959      column_channel[i]=spotData.getIndex(VirtualColumn.channelRaw(i+1).getName());
    952960    }
    953961
     
    957965    int progress_spot_interval=nof_spots/10;
    958966    long nof_processed_spots=0;
     967    IntensityTransform transform = bioassayset.getIntensityTransform();
     968    boolean isLogged = transform == IntensityTransform.LOG10 ||
     969      transform == IntensityTransform.LOG2;
    959970    while (spotData.hasNext())
    960971    {
     
    10011012      {
    10021013        double ch2=item.getFloat(column_channel[1]);
    1003         if (ch2!=0)
    1004         {
    1005           exValue/=ch2;
     1014        if (isLogged)
     1015        {
     1016          exValue -= ch2;
    10061017        }
    10071018        else
    10081019        {
    1009           goodvalue=false;
     1020          if (ch2!=0)
     1021          {
     1022            exValue /= ch2;
     1023          }
     1024          else
     1025          {
     1026            goodvalue=false;
     1027          }
    10101028        }
    10111029      }
     
    11781196    List<QueryItem> items = new ArrayList<QueryItem>();
    11791197    int channels = bas.getRawDataType().getChannels();
     1198    IntensityTransform transform = bas.getIntensityTransform();
    11801199    for (int channel = 1; channel <= channels; ++channel)
    11811200    {
    1182       items.add(new QueryItem("intensity"+channel, "Int ch"+channel, "intensity" + channel, "ch("+channel+")", Formula.AverageMethod.ARITHMETIC_MEAN));
     1201      items.add(new QueryItem("intensity"+channel,
     1202          "Int ch"+channel, "intensity" + channel,
     1203          "rawCh("+channel+")", transform.getAverageMethod()));
    11831204    }
    11841205    Collections.sort(items, new QueryItemTitleComparator());
Note: See TracChangeset for help on using the changeset viewer.