Changeset 1224 for plugins/base2/net.sf.basedb.normalizers/trunk
- Timestamp:
- May 3, 2010, 10:18:46 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.normalizers/trunk/src/c++/bin/qQN.cc
r1220 r1224 59 59 60 60 61 void create_matrix_until_183_fixed(MatrixWeighted**, const MatrixWeighted&,62 const std::string&);63 61 void create_target(std::vector<double>&, const MatrixWeighted&, bool use_median); 64 62 void create_target(std::vector<double>&, const MatrixWeighted&, … … 123 121 } 124 122 125 // The BASE core API deprecated exportPlainMatrix method of the 126 // deprecated BioAssaySetExporter does not behave well when 127 // exporting bioassaysets where assays have been filtered out in 128 // some filter step. Variables and functions with 183 in their name 129 // should be removed when http://baseplugins.thep.lu.se/ticket/183 130 // is fixed. 131 132 // m is a pointer below, should be changed to a normal variable when 133 // http://baseplugins.thep.lu.se/ticket/183 is fixed. 134 135 // Change to m when http://baseplugins.thep.lu.se/ticket/183 fixed. 136 MatrixWeighted m_tmp_until_183_fixed(std::cin,'\t'); 123 MatrixWeighted m(std::cin,'\t'); 137 124 if (indata.present()) { 138 125 std::cin.rdbuf(cin_buffer); // restore old input buffer … … 140 127 delete infile; 141 128 } 142 // Remove until HERE below when 143 // http://baseplugins.thep.lu.se/ticket/183 fixed. 144 MatrixWeighted* m=NULL; 145 if (assay.present()) 146 create_matrix_until_183_fixed(&m, m_tmp_until_183_fixed, assay.value()); 147 else 148 m = &m_tmp_until_183_fixed; 149 // HERE remove until here. 150 151 std::transform(m->begin(), m->end(), m->begin(), CleanUpMatrix()); 129 130 std::transform(m.begin(), m.end(), m.begin(), CleanUpMatrix()); 152 131 std::vector<double> target; 153 132 ( assay.present() ? 154 create_target(target, *m, assay.value(), target_median.value()) :155 create_target(target, *m, target_median.value()) );133 create_target(target, m, assay.value(), target_median.value()) : 134 create_target(target, m, target_median.value()) ); 156 135 std::transform(target.begin(), target.end(), 157 136 target.begin(), theplu::yat::utility::Log<double>()); 158 std::transform(data_iterator(m ->begin()), data_iterator(m->end()),159 data_iterator(m ->begin()), theplu::yat::utility::Log<double>());137 std::transform(data_iterator(m.begin()), data_iterator(m.end()), 138 data_iterator(m.begin()), theplu::yat::utility::Log<double>()); 160 139 // q = min(100,target_size/10) but no smaller than 10 161 140 unsigned int q=target.size()/10; … … 163 142 qQuantileNormalizer qqn(target.begin(), target.end(), q); 164 143 ColumnNormalizer<qQuantileNormalizer> cn(qqn); 165 MatrixWeighted result(m ->rows(),m->columns());166 cn( *m,result);144 MatrixWeighted result(m.rows(),m.columns()); 145 cn(m,result); 167 146 std::transform(data_iterator(result.begin()), data_iterator(result.end()), 168 147 data_iterator(result.begin()), theplu::yat::utility::Exp<double>()); … … 182 161 } 183 162 184 // clean up until http://baseplugins.thep.lu.se/ticket/183 fixed.185 if (assay.present())186 delete m;187 188 163 return EXIT_SUCCESS; 189 }190 191 192 void create_matrix_until_183_fixed(MatrixWeighted** m,193 const MatrixWeighted& m_tmp_183,194 const std::string& assay)195 {196 std::ifstream is(assay.c_str());197 std::vector<size_t> idx;198 while (is.good()) {199 size_t i;200 is >> i;201 if (is.good()) idx.push_back(i);202 std::string line;203 getline(is, line);204 if (idx.size()>m_tmp_183.columns())205 throw std::runtime_error(std::string("183_tmp: Too many annotation ") +206 "columns wrt data matrix");207 }208 209 if (*m) delete *m;210 size_t rows=m_tmp_183.rows();211 size_t cols=idx.size();212 *m=new MatrixWeighted(rows,cols);213 for (size_t i=0; i<rows; ++i)214 for (size_t j=0; j<cols; ++j)215 (**m)(i,j)=m_tmp_183(i,idx[j]-1);216 164 } 217 165
Note: See TracChangeset
for help on using the changeset viewer.