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