Changeset 1432 for trunk/yat/normalization/QuantileNormalizer.cc
- Timestamp:
- Aug 25, 2008, 3:54:18 PM (15 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/normalization/QuantileNormalizer.cc
r1430 r1432 4 4 Copyright (C) 2005, 2006 Jari Häkkinen, Markus Ringnér 5 5 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 6 Copyright (C) 2008 Peter Johansson 6 7 7 This file is part of the yat library, http:// trac.thep.lu.se/yat8 This file is part of the yat library, http://dev.thep.lu.se/yat 8 9 9 10 The yat library is free software; you can redistribute it and/or … … 23 24 */ 24 25 25 #include " utility.h"26 #include "QuantileNormalizer.h" 26 27 27 #include "Matrix.h"28 #include "stl_utility.h"29 #include "VectorConstView.h"30 28 #include "yat/statistics/Averager.h" 31 29 32 #include <sstream>33 #include <string>30 #include "yat/utility/Matrix.h" 31 #include "yat/utility/VectorConstView.h" 34 32 35 33 namespace theplu { 36 34 namespace yat { 37 namespace utility{35 namespace normalization { 38 36 39 bool is_double(const std::string& s)37 void QuantileNormalizer::operator()(utility::Matrix& data) const 40 38 { 41 return is<double>(s); 42 } 43 44 45 bool is_equal(std::string s, std::string other) 46 { 47 std::stringstream ss(s); 48 std::string s2; 49 ss >> s2; // to trim surrounding whitespaces 50 to_lower(s2); 51 // Check that nothing is left on stream 52 std::string s3; 53 ss >> s3; 54 if(s3.size()) 55 return false; 56 return (other==s2); 57 } 58 59 60 bool is_float(const std::string& s) 61 { 62 return is<float>(s); 63 } 64 65 66 bool is_int(const std::string& s) 67 { 68 return is<int>(s); 69 } 70 71 bool is_nan(const std::string& s) 72 { 73 return is_equal(s, "nan"); 74 } 75 76 77 void quantile_normalize(Matrix& data) 78 { 79 Matrix data_copy(data); 39 utility::Matrix data_copy(data); 80 40 81 41 // sort columns in copy … … 92 52 for (size_t column=0; column<data.columns(); ++column){ 93 53 std::vector<size_t> index; 94 yat::utility::sort_index(index, data.column_const_view(column));54 utility::sort_index(index, data.column_const_view(column)); 95 55 96 56 for (size_t row=0; row<data.rows(); ++row)
Note: See TracChangeset
for help on using the changeset viewer.