Changeset 4308


Ignore:
Timestamp:
May 21, 2008, 10:49:43 PM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes #1030. User selects scaling/subtraction depending on whether data is log values or not.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7-stable/src/plugins/core/net/sf/basedb/plugins/MedianRatioNormalization.java

    r4281 r4308  
    5353import net.sf.basedb.core.RequestInformation;
    5454import net.sf.basedb.core.SpotBatcher;
     55import net.sf.basedb.core.StringParameterType;
    5556import net.sf.basedb.core.Transformation;
    5657import net.sf.basedb.core.Type;
     
    9495  (
    9596    "Normalization: Median ratio",
    96     ("This normalizer behaves differently depending on the array type.\n" +
    97      "1-channel arrays: Intensities are translated such that resulting median is zero.\n" +
     97    ("This normalizer behaves differently depending on the array type.\n\n" +
     98
     99     "1-channel arrays: Intensities are changed in two different ways depending " +
     100     "on user selection.\n" +
     101     "a) For absolute intensity data the intensities should be scaled with the " +
     102     "median intensity, Inew=Iold/Imedian, such that resulting median is 1.\n" +
     103     "b) For log intensity data the intensities should be subtracted with the median " +
     104     "intensity, log(Inew)=log(Iold)-log(Imedian), such that resulting median is 0.\n\n" +
     105
    98106     "2-channel arrays: Intensities are scaled such " +
    99107     "that their geometric mean (sqrt(i1 * i2)) is kept constant but " +
    100      "the median of their ratios (i1/i2) is shifted to 1.\n" +
    101      "All arrray types: The user can optionally exclude spots; all spots " +
     108     "the median of their ratios (i1/i2) is shifted to 1.\n\n" +
     109
     110     "All array types: The user can optionally exclude spots; all spots " +
    102111     "with at least one intensity below a user selectable threshold are " +
    103112     "removed. User selectable (low/high intensity) fractions of the " +
     
    138147    new FloatParameterType(0F, 100F, 5F, true)
    139148  );
    140  
     149
     150  /**
     151     List of median normalization methods.
     152
     153     The method to use depends whether data is log values or
     154     not. Absolute intensities should be scaled with the median
     155     whereas log intensities should be subtracted with the median
     156     intensity.
     157
     158       Inew = Iold/Imedian for absolute intensities.
     159
     160       log(Inew) = log(Iold) - log(Imedian) for log intensities.
     161
     162     Used with 1-channel data only
     163  */
     164  private static final
     165  PluginParameter<String> methodParameter = new PluginParameter<String>
     166    ( "method",
     167      "Normalization method",
     168      "Scale: Scaling of intensities, Inew=Iold/Imedian. Use with absolute intensities.\n" +
     169      "Subtract: Subtraction of intensities, log(Inew)=log(Iold)-log(Imedian), Use with " +
     170      "log intensities.",
     171      new StringParameterType(255, "Scale", true, 1, 0, 0,
     172                              Arrays.asList(
     173                                new String[] { "Scale" ,
     174                                               "Subtract" }
     175                                )
     176        )
     177      );
     178
     179  /**
     180     Used with 2-channel data only
     181   */
    141182  private static final PluginParameter<Integer> blockGroupParameter = new PluginParameter<Integer>
    142183  (
     
    226267        {
    227268            case 1:
     269              String method = (String) job.getValue(methodParameter.getName());
    228270              normalize1ch(dc, source, batcher, minIntensity, lowExclude,
    229                            highExclude, progress);
     271                           highExclude, method.equals("Scale"), progress);
    230272              break;
    231273            case 2:
     
    332374        storeValue(job, request, highExcludeParameter);
    333375        storeValue(job, request, lowExcludeParameter);
     376        // 1-channel only
     377        storeValue(job, request, methodParameter);
    334378        // 2-channel only
    335379        storeValue(job, request, blockGroupParameter);
     
    365409    @param highExclude A percentage of the spots with highest ratio
    366410      that are excluded in the median calculation
     411    @param scale If true, scale intensities with median intensity,
     412      otherwise subtract median intensity
    367413    @param progress Progress reporter for the caller to keep track of
    368414    the plugin's progress. Null is allowed.
     
    373419  normalize1ch(DbControl dc, BioAssaySet source, SpotBatcher batcher,
    374420               float minIntensity, float lowExclude, float highExclude,
    375                ProgressReporter progress)
     421               boolean scale, ProgressReporter progress)
    376422  {
    377423    // Expressions used to get data
     
    444490        for (int i = 0; i<nofChildSpots; ++i)
    445491        {
    446           batcher.insert(bioassayColumn, position[i], intensity[i]-median);
     492          batcher.insert(bioassayColumn, position[i],
     493                         (scale ? intensity[i]/median : intensity[i]-median) );
    447494        }
    448495        normalizedSpots += nofChildSpots;
     
    647694        parameters.add(highExcludeParameter);
    648695        parameters.add(lowExcludeParameter);
    649         String description="Set minimum intensity, low exclude and high exclude";
    650         if (nofChannels == 2)
     696        String description="Set minimum intensity, low exclude, high exclude, and select method";
     697        if (nofChannels == 1) {
     698          parameters.add(methodParameter);
     699        }
     700        else if (nofChannels == 2)
    651701        {
    652702          parameters.add(blockGroupParameter);
Note: See TracChangeset for help on using the changeset viewer.