singlepp
A C++ library for cell type classification
Loading...
Searching...
No Matches
classify_integrated.hpp
Go to the documentation of this file.
1#ifndef SINGLEPP_CLASSIFY_INTEGRATED_HPP
2#define SINGLEPP_CLASSIFY_INTEGRATED_HPP
3
4#include "defs.hpp"
5
6#include "tatami/tatami.hpp"
7
8#include "annotate_cells_integrated.hpp"
10
11#include <vector>
12#include <unordered_map>
13#include <unordered_set>
14
20namespace singlepp {
21
26template<typename Float_ = DefaultFloat>
33
39
44 bool fine_tune = true;
45
50 int num_threads = 1;
51};
52
58template<typename RefLabel_ = DefaultRefLabel, typename Float_ = DefaultFloat>
65
72 std::vector<Float_*> scores;
73
80};
81
125template<typename Value_, typename Index_, typename Label_, typename RefLabel_, typename Float_>
127 const tatami::Matrix<Value_, Index_>& test,
128 const std::vector<const Label_*>& assigned,
132{
133 internal::annotate_cells_integrated(
134 test,
135 trained,
136 assigned,
137 options.quantile,
138 options.fine_tune,
139 options.fine_tune_threshold,
140 buffers.best,
141 buffers.scores,
142 buffers.delta,
143 options.num_threads
144 );
145}
146
152template<typename RefLabel_ = DefaultRefLabel, typename Float_ = DefaultFloat>
158 scores.reserve(nrefs);
159 for (size_t r = 0; r < nrefs; ++r) {
160 scores.emplace_back(ncells);
161 }
162 }
171 std::vector<RefLabel_> best;
172
178 std::vector<std::vector<Float_> > scores;
179
184 std::vector<Float_> delta;
185};
186
201template<typename RefLabel_ = DefaultRefLabel, typename Value_, typename Index_, typename Label_, typename Float_>
203 const tatami::Matrix<Value_, Index_>& test,
204 const std::vector<const Label_*>& assigned,
207{
210 buffers.best = results.best.data();
211 buffers.delta = results.delta.data();
212 buffers.scores.reserve(results.scores.size());
213 for (auto& s : results.scores) {
214 buffers.scores.emplace_back(s.data());
215 }
217 return results;
218}
219
220}
221
222#endif
Common definitions for singlepp.
Cell type classification using the SingleR algorithm in C++.
Definition classify_single.hpp:19
void classify_integrated(const tatami::Matrix< Value_, Index_ > &test, const std::vector< const Label_ * > &assigned, const TrainedIntegrated< Index_ > &trained, ClassifyIntegratedBuffers< RefLabel_, Float_ > &buffers, const ClassifyIntegratedOptions< Float_ > &options)
Integrate classifications from multiple references.
Definition classify_integrated.hpp:126
std::vector< std::vector< std::vector< Index_ > > > Markers
Definition Markers.hpp:40
Output buffers for classify_single().
Definition classify_integrated.hpp:59
RefLabel_ * best
Definition classify_integrated.hpp:64
Float_ * delta
Definition classify_integrated.hpp:79
std::vector< Float_ * > scores
Definition classify_integrated.hpp:72
Options for classify_integrated().
Definition classify_integrated.hpp:27
bool fine_tune
Definition classify_integrated.hpp:44
int num_threads
Definition classify_integrated.hpp:50
Float_ quantile
Definition classify_integrated.hpp:32
Float_ fine_tune_threshold
Definition classify_integrated.hpp:38
Results of classify_integrated().
Definition classify_integrated.hpp:153
std::vector< std::vector< Float_ > > scores
Definition classify_integrated.hpp:178
std::vector< RefLabel_ > best
Definition classify_integrated.hpp:171
std::vector< Float_ > delta
Definition classify_integrated.hpp:184
Prepare for integrated classification across references.