1#ifndef SCRAN_CHOOSE_HVGS_HPP
2#define SCRAN_CHOOSE_HVGS_HPP
4#include "../utils/macros.hpp"
34 static constexpr size_t top = 4000;
67 template<
typename V,
typename T>
68 void run(
size_t n,
const V* statistic, T* output)
const {
69 std::vector<size_t> collected(n);
70 std::iota(collected.begin(), collected.end(), 0);
71 std::sort(collected.begin(), collected.end(), [&](
size_t l,
size_t r) ->
bool { return statistic[l] > statistic[r]; });
73 auto limit = std::min(n, top);
74 std::fill(output, output + n,
false);
75 for (
size_t i = 0; i < limit; ++i) {
76 output[collected[i]] =
true;
89 template<
typename T = u
int8_t,
typename V>
90 std::vector<T>
run(
size_t n,
const V* statistic)
const {
91 std::vector<T> output(n);
92 run(n, statistic, output.data());
Choose highly variable genes for downstream analyses.
Definition ChooseHvgs.hpp:25
ChooseHvgs & set_top(size_t t=Defaults::top)
Definition ChooseHvgs.hpp:50
void run(size_t n, const V *statistic, T *output) const
Definition ChooseHvgs.hpp:68
std::vector< T > run(size_t n, const V *statistic) const
Definition ChooseHvgs.hpp:90
Functions for single-cell RNA-seq analyses.
Definition AggregateAcrossCells.hpp:18
Default paramater settings.
Definition ChooseHvgs.hpp:30
static constexpr size_t top
Definition ChooseHvgs.hpp:34