Changeset 1045


Ignore:
Timestamp:
Apr 24, 2009, 10:52:57 PM (14 years ago)
Author:
Jari Häkkinen
Message:

Missing values now works with the implemented fix to avoid a bug in yat, http://dev.thep.lu.se/yat/ticket/535

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.normalizers/trunk/src/c++/bin/qQN.cc

    r1044 r1045  
    4343using namespace theplu::yat::utility;
    4444
    45 void create_target(std::vector<double>&, const MatrixWeighted&);
    46 void create_target(std::vector<double>&, const MatrixWeighted&,
    47                    const std::string&);
     45void create_target_and_fix_nans(std::vector<double>&, MatrixWeighted&);
     46void create_target_and_fix_nans(std::vector<double>&, MatrixWeighted&,
     47                                const std::string&);
    4848/**
    4949   writes the data values in the matrix ignoring the weights, i.e.,
     
    100100
    101101  std::vector<double> target(m.rows());
    102   ( assay.present() ? create_target(target,m,assay.value()) :
    103                       create_target(target,m) );
     102  ( assay.present() ? create_target_and_fix_nans(target,m,assay.value()) :
     103                      create_target_and_fix_nans(target,m) );
    104104  qQuantileNormalizer qqn(target.begin(), target.end(), 100);
    105105  ColumnNormalizer<qQuantileNormalizer> cn(qqn);
     
    125125
    126126
    127 void create_target(std::vector<double>& t, const MatrixWeighted& m,
    128                    const std::string& assay)
     127void create_target_and_fix_nans(std::vector<double>& t, MatrixWeighted& m,
     128                                const std::string& assay)
    129129{
    130130  std::ifstream is(assay.c_str());
     
    142142          ++yes[row];
    143143        }
     144        else
     145          m(row,column).data()=0;
    144146    }
    145147    ++column;
     
    155157
    156158
    157 void create_target(std::vector<double>& t, const MatrixWeighted& m)
     159void create_target_and_fix_nans(std::vector<double>& t, MatrixWeighted& m)
    158160{
    159161  for (size_t row=0; row<m.rows(); ++row) {
     
    165167        ++column_contribs;
    166168      }
     169      else
     170        m(row,column).data()=0;
    167171    if (!column_contribs)
    168172      throw std::runtime_error("At least one row with no valid reference");
     
    178182  for(size_t i=0, j=0; i<m.rows(); i++)
    179183    for (j=0; j<m.columns(); j++) {
    180       s << m(i,j).data();
     184      if (m(i,j).weight())
     185        s << m(i,j).data();
     186      else
     187        s << "nan";
    181188      if (j<m.columns()-1)
    182189        s << s.fill();
Note: See TracChangeset for help on using the changeset viewer.