singlepp_loaders
Load pre-processed reference datasets for SingleR
Loading...
Searching...
No Matches
singlepp_loaders
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
"
5
#include "
singlepp/singlepp.hpp
"
6
7
#include <stdexcept>
8
#include <vector>
9
15
namespace
singlepp_loaders
{
16
34
template
<
typename
Value_,
typename
Index_,
typename
Rank_,
typename
Label_>
35
void
verify
(
const
RankMatrix<Value_, Index_, Rank_>
& rankings,
const
std::vector<Label_>& labels,
const
singlepp::Markers<Index_>
& markers) {
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
49
Index_ NR = rankings.
nrow
();
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
tatami::DenseMatrix
tatami::DenseMatrix::nrow
Index_ nrow() const
tatami::DenseMatrix::ncol
Index_ ncol() const
singlepp_loaders
Load pre-processed single reference datasets.
Definition
labels.hpp:23
singlepp_loaders::verify
void verify(const RankMatrix< Value_, Index_, Rank_ > &rankings, const std::vector< Label_ > &labels, const singlepp::Markers< Index_ > &markers)
Definition
verify.hpp:35
singlepp::Markers
std::vector< std::vector< std::vector< Index_ > > > Markers
rankings.hpp
Load ranking matrices for singlepp reference datasets.
singlepp.hpp
Generated by
1.12.0