yat  0.14.5pre
SAMScore.h
1 #ifndef _theplu_yat_statistics_sam_score_
2 #define _theplu_yat_statistics_sam_score_
3 
4 // $Id: SAMScore.h 2119 2009-12-12 23:11:43Z peter $
5 
6 /*
7  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "Score.h"
26 
27 #include <cmath>
28 
29 namespace theplu {
30 namespace yat {
31  namespace utility {
32  class VectorBase;
33  }
34  namespace classifier {
35  class DataLookWeighted1D;
36  }
37 namespace statistics {
38 
50  class SAMScore : public Score
51  {
52 
53  public:
58  SAMScore(const double s0, bool absolute=true);
59 
69  double score(const classifier::Target& target,
70  const utility::VectorBase& value) const;
71 
83  double score(const classifier::Target& target,
84  const classifier::DataLookupWeighted1D& value) const;
85 
97  double score(const classifier::Target& target,
98  const utility::VectorBase& value,
99  const utility::VectorBase& weight) const;
100  private:
101  double s0_;
102 
103  template<class T>
104  double score(const T& positive, const T& negative) const
105  {
106  if(positive.n()+negative.n()<=2)
107  return 0;
108  double diff = positive.mean() - negative.mean();
109  double s2 = ( (1.0/positive.n()+1.0/negative.n()) *
110  (positive.sum_xx_centered()+negative.sum_xx_centered()) /
111  (positive.n()+negative.n()-2) );
112  if (diff<0 && absolute_)
113  return -diff/(sqrt(s2)+s0_);
114  return diff/(sqrt(s2)+s0_);
115  }
116  };
117 
118 }}} // of namespace statistics, yat, and theplu
119 
120 #endif
SAMScore(const double s0, bool absolute=true)
Class for containing sample labels.
Definition: Target.h:47
bool absolute_
Definition: Score.h:130
This is the yat interface to GSL vector.
Definition: VectorBase.h:52
Interface Class for score classes.
Definition: Score.h:42
Class for score used in Significance Analysis of Microarrays (SAM).
Definition: SAMScore.h:50
void absolute(bool absolute)
Function changing mode of Score.
double score(const classifier::Target &target, const utility::VectorBase &value) const
Class for general weighted vector view.
Definition: DataLookupWeighted1D.h:43

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5