Post-process dispersion statistics for Seurat method to handle edge cases. Handles bins with single genes where standard deviation cannot be computed. Following the original Seurat implementation, single-gene bins get special treatment to ensure they can still contribute to HVG selection. ## Parameters `bin_means` - Mean dispersion values for each bin `bin_stds` - Standard deviation of dispersio
(
bin_means: &mut [f64],
bin_stds: &mut [f64],
)
| 182 | /// - Sets std = mean and mean = 0 |
| 183 | /// - This results in normalized dispersion = 1 for these genes |
| 184 | fn postprocess_seurat_dispersions( |
| 185 | bin_means: &mut [f64], |
| 186 | bin_stds: &mut [f64], |
| 187 | ) -> anyhow::Result<()> { |
| 188 | // This matches Python's _postprocess_dispersions_seurat |
| 189 | for i in 0..bin_means.len() { |
| 190 | if bin_stds[i].is_nan() { |
| 191 | // For single-gene bins, set std = mean and mean = 0 |
| 192 | // This effectively sets normalized dispersion to 1 |
| 193 | bin_stds[i] = bin_means[i]; |
| 194 | bin_means[i] = 0.0; |
| 195 | } |
| 196 | } |
| 197 | Ok(()) |
| 198 | } |
| 199 | |
| 200 | /// Create equal-width bins for gene expression levels. |
| 201 | /// |
no outgoing calls
no test coverage detected