singlepp_loaders
Load pre-processed reference datasets for SingleR
Loading...
Searching...
No Matches
verify.hpp
Go to the documentation of this file.
1#ifndef SINGLEPP_LOADERS_VERIFY_HPP
2#define SINGLEPP_LOADERS_VERIFY_HPP
3
4#include "rankings.hpp"
6
7#include <stdexcept>
8#include <vector>
9
15namespace singlepp_loaders {
16
34template<typename Value_, typename Index_, typename Rank_, typename Label_>
36 size_t NC = rankings.ncol();
37 if (labels.size() != NC) {
38 throw std::runtime_error("number of columns of 'rankings' does not equal length of 'labels'");
39 }
40
41 size_t nlabels = 0;
42 if (NC) {
43 nlabels = static_cast<size_t>(*std::max_element(labels.begin(), labels.end())) + 1;
44 }
45 if (markers.size() != nlabels) {
46 throw std::runtime_error("length of 'markers' does not equal the number of labels in 'labels'");
47 }
48
50 for (const auto& mm : markers) {
51 if (mm.size() != nlabels) {
52 throw std::runtime_error("number of inner vectors in 'markers' does not equal the number of labels in 'labels'");
53 }
54 for (const auto& m : mm) {
55 for (auto x : m) {
56 if (x < 0 || x >= NR) {
57 throw std::runtime_error("gene indices in 'markers' should be non-negative and less than the number of rows in 'rankings'");
58 }
59 }
60 }
61 }
62}
63
64}
65
66#endif
Index_ nrow() const
Index_ ncol() const
Load pre-processed single reference datasets.
Definition labels.hpp:23
tatami::DenseMatrix< Value_, Index_, std::vector< Rank_ > > RankMatrix
Definition rankings.hpp:35
void verify(const RankMatrix< Value_, Index_, Rank_ > &rankings, const std::vector< Label_ > &labels, const singlepp::Markers< Index_ > &markers)
Definition verify.hpp:35
std::vector< std::vector< std::vector< Index_ > > > Markers
Load ranking matrices for singlepp reference datasets.