Beispiel #1
0
// Also saves sample information
void writeMDS(const std::string& file_name, const std::vector<Sample>& sample_names, const arma::mat& MDS)
{
   if (MDS.n_rows == sample_names.size())
   {
      MDS.save(file_name, arma::hdf5_binary);

      std::string sample_file_name = file_name + sample_suffix;
      std::ofstream sample_names_file(sample_file_name.c_str());

      // Write out the sample name order
      if (!sample_names_file)
      {
         std::cerr << "Could not write used sample names to " << sample_file_name << std::endl;
      }
      else
      {
         for (auto sample_it = sample_names.begin(); sample_it != sample_names.end(); ++sample_it)
         {
            sample_names_file << sample_it->iid() << std::endl;
         }
      }
   }
   else
   {
      throw std::logic_error("When writing matrix to " + file_name + " the number samples in the .pheno file did not match the number of columns or rows");
   }

}
Beispiel #2
0
bool Vespucci::SaveText(std::string basename, const arma::mat &spectra, const arma::vec &x, const arma::vec &y, const arma::vec &abscissa, arma::file_type type)
{
    std::string extension;
    switch (type){
    case arma::csv_ascii:
        extension = ".csv";
    case arma::raw_ascii: default:
        extension = ".txt";
    }
    bool x_success, y_success, spectra_success, abscissa_success;
    spectra_success = spectra.save(basename + "_spectra" + extension, type);
    abscissa_success = abscissa.save(basename + "_abscissa" + extension, type);
    x_success = x.save(basename + "_x" + extension, type);
    y_success = y.save(basename + "_y" + extension, type);
    return (x_success && y_success && spectra_success && abscissa_success);
}
Beispiel #3
0
void writeDistances(const std::string& file_name, const arma::mat& distances)
{
   distances.save(file_name, arma::csv_ascii);
}