Changeset 1060
- Timestamp:
- May 11, 2009, 1:06:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.normalizers/trunk/src/net/sf/basedb/plugins/AverageNormalization.java
r947 r1060 32 32 import net.sf.basedb.core.DynamicSpotQuery; 33 33 import net.sf.basedb.core.FloatParameterType; 34 import net.sf.basedb.core.IntensityTransform; 34 35 import net.sf.basedb.core.InvalidUseOfNullException; 35 36 import net.sf.basedb.core.Job; … … 89 90 private static final String yesOption = "yes"; 90 91 private static final String noOption = "no"; 92 private static final String geometricOption = "geometric"; 93 private static final String arithmeticOption = "arithmetic"; 91 94 92 95 /* … … 123 126 "This parameter cannot be null if 'Use global geometric mean intensity' is " + noOption + ".", 124 127 new FloatParameterType(null, null, 100f, false) 128 ); 129 130 /* 131 Define which average method to use when calculating. 132 */ 133 private PluginParameter<String> averageMethodParameter = new PluginParameter<String> 134 ( 135 "averageMethod", 136 "Average calculation method", 137 "Select which method to use when calculating the averages.\n" + 138 "Geometric mean is default for none-logged values and arithmetic " + 139 "is default for logged values.", 140 null 125 141 ); 126 142 … … 212 228 storeValue(job, request, ri.getParameter(CHILD_DESCRIPTION)); 213 229 // Average specific parameters 230 storeValue(job, request, averageMethodParameter); 214 231 storeValue(job, request, minIntensityParameter); 215 232 storeValue(job, request, ri.getParameter("useGlobalAvgInt")); 216 233 217 234 // Reference value cannot be null if the global average intensity shouldn't be used. 218 235 String useGlobal = (String)request.getParameterValue("useGlobalAvgInt"); … … 374 391 375 392 // Average normalization options 393 StringParameterType spt = new StringParameterType 394 ( 395 null, 396 bas.getIntensityTransform().equals(IntensityTransform.NONE) ? geometricOption : arithmeticOption , 397 true, 1, 0, 0, 398 Arrays.asList(new String[] {geometricOption, arithmeticOption} ) 399 ); 400 averageMethodParameter = new PluginParameter<String> 401 ( 402 averageMethodParameter.getName(), 403 averageMethodParameter.getLabel(), 404 averageMethodParameter.getDescription(), 405 spt 406 ); 376 407 parameters.add(normalizationSection); 408 parameters.add(averageMethodParameter); 377 409 parameters.add(minIntensityParameter); 378 410 parameters.add(useGlobalAverageIntensityParameter); … … 405 437 long numSpots; 406 438 long normalizedSpots = 0; 439 440 boolean useGeometricMean = geometricOption.equals(job.getParameterValue("averageMethod")); 407 441 408 442 // Create Transformation … … 483 517 // Calculate the average intensity for the current assay. 484 518 double sum = 0; 485 for (Normalizable d : data) 486 { 487 sum = sum + Math.log(d.getNormalizableData()); 488 } 489 float assayAverage = (float)Math.exp(sum/dataSize); 519 float assayAverage; 520 if (useGeometricMean) 521 { 522 for (Normalizable d : data) 523 { 524 sum = sum + Math.log(d.getNormalizableData()); 525 } 526 assayAverage = (float)Math.exp(sum/dataSize); 527 } 528 else 529 { 530 for (Normalizable d : data) 531 { 532 sum = sum + d.getNormalizableData(); 533 } 534 assayAverage = (float)sum/dataSize; 535 } 490 536 scaleFactor = refValue / assayAverage; 491 537
Note: See TracChangeset
for help on using the changeset viewer.