Changeset 3879


Ignore:
Timestamp:
Oct 26, 2007, 11:01:46 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #797: Enhance performance for LOWESS and Medin-ratio plug-ins

Location:
trunk/src/plugins/core/net/sf/basedb/plugins
Files:
2 edited

Legend:

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

    r3877 r3879  
    334334    Expression ch2 = Dynamic.column(VirtualColumn.channel(2));
    335335    // A = log10(sqrt(ch1 * ch2))
    336     Expression A = Expressions.log10(Expressions.sqrt(Expressions.multiply(ch1, ch2)));
     336    Expression pseudoA = Expressions.multiply(ch1, ch2);
     337    Expression A = Expressions.log10(Expressions.sqrt(pseudoA));
    337338
    338339    // Create restriction: ch1 > 0 and ch2 > 0
     
    363364    query.restrict(bioAssayRestriction);
    364365    query.order(Orders.asc(block));
    365     query.order(Orders.asc(A));
     366    query.order(Orders.asc(pseudoA));
    366367     
    367368    // Normalize one bioassay at a time
     
    428429              SpotData spot = data.get(fromIndex + j);
    429430              double factor = Math.exp(smoothCurve.get(j) * 0.5);
    430               double newCh1 = spot.ch1/factor;
    431               double newCh2 = spot.ch2*factor;
    432               batcher.insert(bioassayColumn, spot.position, (float) newCh1, (float) newCh2);
     431              batcher.insert(bioassayColumn, spot.position, (float)(spot.ch1/factor), (float)(spot.ch2*factor));
    433432            }
    434433            normalizedSpots += smoothCurve.size();
     
    645644    final double A;
    646645    final int block;
    647     static final double LN2 = Math.log(2);
     646    static final double INV_LN2 = 1 / Math.log(2);
    648647
    649648    public SpotData(int position, float ch1, float ch2, int block)
     
    653652      this.ch2 = ch2;
    654653      this.block = block;
    655       this.M = Math.log(ch1 / ch2) / LN2;
     654      this.M = Math.log(ch1 / ch2) * INV_LN2;
    656655      this.A = Math.log10(Math.sqrt(ch1 * ch2));
    657656    }
  • trunk/src/plugins/core/net/sf/basedb/plugins/MedianRatioNormalization.java

    r3878 r3879  
    429429             
    430430              // Correct all spot intensities
    431               float sqrtMedRatio = (float)Math.sqrt(median);
    432               float invSqrtMedRatio = 1 / sqrtMedRatio;
     431              double sqrtMedRatio = Math.sqrt(median);
     432              double invSqrtMedRatio = 1 / sqrtMedRatio;
    433433              for (int j = fromIndex; j < toIndex; ++j)
    434434              {
    435435                SpotData spot = data.get(j);
    436                 double newCh1 = spot.ch1 * invSqrtMedRatio;
    437                 double newCh2 = spot.ch2 * sqrtMedRatio;
    438                 batcher.insert(bioassayColumn, spot.position, (float)newCh1, (float)newCh2);
     436                float newCh1 = (float)(spot.ch1 * invSqrtMedRatio);
     437                float newCh2 = (float)(spot.ch2 * sqrtMedRatio);
     438                batcher.insert(bioassayColumn, spot.position, newCh1, newCh2);
    439439              }
    440440            }
Note: See TracChangeset for help on using the changeset viewer.