1#ifndef SINGLEPP_TRAIN_SINGLE_HPP
2#define SINGLEPP_TRAIN_SINGLE_HPP
7#include "tatami/tatami.hpp"
9#include "build_indices.hpp"
10#include "subset_to_markers.hpp"
27template<
typename Index_ = DefaultIndex,
typename Float_ = DefaultFloat>
43 std::shared_ptr<knncolle::Builder<knncolle::SimpleMatrix<Index_, Index_, Float_>,
Float_> >
trainer;
57template<
typename Value_,
typename Index_,
typename Label_,
typename Float_>
59 const tatami::Matrix<Value_, Index_>&
ref,
61 const std::vector<Index_>&
subset,
86template<
typename Index_,
typename Float_>
95 std::vector<Index_>
subset,
96 std::vector<internal::PerLabelReference<Index_, Float_> >
references) :
99 my_subset(std::move(
subset)),
109 std::vector<Index_> my_subset;
110 std::vector<internal::PerLabelReference<Index_, Float_> > my_references;
142 return my_references.size();
150 for (
const auto&
ref : my_references) {
151 n +=
ref.ranked.size();
160 return my_references;
190template<
typename Value_,
typename Index_,
typename Label_,
typename Float_>
192 const tatami::Matrix<Value_, Index_>&
ref,
213template<
typename Index_,
typename Float_>
224 std::vector<internal::PerLabelReference<Index_, Float_> >
references) :
226 my_markers(std::move(
markers)),
238 std::vector<Index_> my_test_subset;
239 std::vector<Index_> my_ref_subset;
240 std::vector<internal::PerLabelReference<Index_, Float_> > my_references;
266 return my_test_subset;
275 return my_ref_subset;
282 return my_references.size();
290 for (
const auto&
ref : my_references) {
291 n +=
ref.ranked.size();
300 return my_references;
333template<
typename Index_,
typename Value_,
typename Label_,
typename Float_>
337 const tatami::Matrix<Value_, Index_>&
ref,
351template<
typename Index_,
typename Value_,
typename Label_,
typename Float_>
354 const tatami::Matrix<Value_, Index_>&
ref,
393template<
typename Index_,
typename Id_,
typename Value_,
typename Label_,
typename Float_>
397 const tatami::Matrix<Value_, Index_>&
ref,
Classifier built from an intersection of genes.
Definition train_single.hpp:214
Index_ get_test_nrow() const
Definition train_single.hpp:246
const Markers< Index_ > & get_markers() const
Definition train_single.hpp:256
const std::vector< Index_ > & get_test_subset() const
Definition train_single.hpp:265
const std::vector< Index_ > & get_ref_subset() const
Definition train_single.hpp:274
size_t num_labels() const
Definition train_single.hpp:281
size_t num_profiles() const
Definition train_single.hpp:288
Classifier trained from a single reference.
Definition train_single.hpp:87
const std::vector< Index_ > & get_subset() const
Definition train_single.hpp:134
Index_ get_test_nrow() const
Definition train_single.hpp:116
size_t num_labels() const
Definition train_single.hpp:141
size_t num_profiles() const
Definition train_single.hpp:148
const Markers< Index_ > & get_markers() const
Definition train_single.hpp:126
Common definitions for singlepp.
Cell type classification using the SingleR algorithm in C++.
Definition classify_single.hpp:19
Intersection< Index_ > intersect_genes(Index_ test_nrow, const Id_ *test_id, Index_ ref_nrow, const Id_ *ref_id)
Definition Intersection.hpp:54
std::vector< std::vector< std::vector< Index_ > > > Markers
Definition Markers.hpp:40
TrainedSingleIntersect< Index_, Float_ > train_single_intersect(Index_ test_nrow, const Intersection< Index_ > &intersection, const tatami::Matrix< Value_, Index_ > &ref, const Label_ *labels, Markers< Index_ > markers, const TrainSingleOptions< Index_, Float_ > &options)
Definition train_single.hpp:334
TrainedSingle< Index_, Float_ > train_single(const tatami::Matrix< Value_, Index_ > &ref, const Label_ *labels, Markers< Index_ > markers, const TrainSingleOptions< Index_, Float_ > &options)
Definition train_single.hpp:191
Options for train_single() and friends.
Definition train_single.hpp:28
int num_threads
Definition train_single.hpp:49
std::shared_ptr< knncolle::Builder< knncolle::SimpleMatrix< Index_, Index_, Float_ >, Float_ > > trainer
Definition train_single.hpp:43
int top
Definition train_single.hpp:36