1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Packing a cell's WHOLE observed support, with no context window.
//!
//! The top-K packing ([`super::top_k`]) exists because the per-gene encoder
//! gathers an `H`-wide row per slot: an `[N, K, H]` block whose size forces a
//! cap on `K`, and the cap in turn forces a choice about which genes a cell is
//! read through. Genes outside the window are invisible to the encoder however
//! much they were expressed.
//!
//! A coarse read has no such block. Every observed gene is added into its
//! group, giving an `[N, C]` profile whose width is the group count and not the
//! support size, so the slot dimension never meets `H` and there is nothing to
//! rank. This module is what feeds it: the support, whole, unweighted.
//!
//! No shortlist weights appear here on purpose. Weighting existed to decide
//! what survived the cap; with nothing discarded there is nothing to decide,
//! and applying a weight would silently rescale counts the decoder still
//! scores in raw units.
use IndexedSample;
use CscMatrix;
/// Every stored nonzero of each column, as one [`IndexedSample`] per cell.
///
/// Columns are cells and rows are features, matching
/// [`super::top_k::csc_columns_to_indexed_samples`]. Indices come out in the
/// matrix's own row order, ascending, and values are the stored counts
/// untouched.
///
/// `gene_remap = Some(new_to_train)` renumbers each stored row from a held-out
/// gene axis onto the training axis and drops rows that do not map, for
/// scoring a cohort whose gene set differs. `None` when the matrix is already
/// on the training axis.
/// The widest support in a batch of samples, i.e. the `K` a rectangular pack
/// needs. Returned rather than assumed so a caller pads to the batch it has
/// instead of to a configured constant.