(
csr_matrix: &CsrMatrix<T>,
group_indices: &[usize],
reference_indices: &[usize],
method: TestMethod,
correction_method: CorrectionMethod,
compute_lfc: bool,
pseudocount:
| 527 | |
| 528 | #[allow(clippy::too_many_arguments)] |
| 529 | fn run_tests_for_group<T>( |
| 530 | csr_matrix: &CsrMatrix<T>, |
| 531 | group_indices: &[usize], |
| 532 | reference_indices: &[usize], |
| 533 | method: TestMethod, |
| 534 | correction_method: CorrectionMethod, |
| 535 | compute_lfc: bool, |
| 536 | pseudocount: f64, |
| 537 | n_genes: usize, |
| 538 | var_names: &[String], |
| 539 | ) -> anyhow::Result<GroupTestResults> |
| 540 | where |
| 541 | T: FloatOpsTS, |
| 542 | CsrMatrix<T>: MatrixStatTests<T>, |
| 543 | { |
| 544 | let n_cols = csr_matrix.ncols(); |
| 545 | let n_rows = csr_matrix.nrows(); |
| 546 | |
| 547 | let group_size_f64 = group_indices.len() as f64; |
| 548 | let ref_size_f64 = reference_indices.len() as f64; |
| 549 | |
| 550 | let mut scores: Vec<f64> = Vec::with_capacity(n_cols); |
| 551 | let mut pvals: Vec<f64> = Vec::with_capacity(n_cols); |
| 552 | let mut logfoldchanges: Vec<f64> = Vec::with_capacity(n_cols); |
| 553 | |
| 554 | let mut group_sums_f64 = vec![0.0f64; n_cols]; |
| 555 | let mut ref_sums_f64 = vec![0.0f64; n_cols]; |
| 556 | let mut group_sum_sq_f64 = vec![0.0f64; n_cols]; |
| 557 | let mut ref_sum_sq_f64 = vec![0.0f64; n_cols]; |
| 558 | |
| 559 | let mut is_group = vec![false; n_rows]; |
| 560 | let mut is_ref = vec![false; n_rows]; |
| 561 | |
| 562 | for &idx in group_indices { |
| 563 | is_group[idx] = true; |
| 564 | } |
| 565 | for &idx in reference_indices { |
| 566 | is_ref[idx] = true; |
| 567 | } |
| 568 | |
| 569 | for row in 0..n_rows { |
| 570 | let row_is_group = is_group[row]; |
| 571 | let row_is_ref = is_ref[row]; |
| 572 | |
| 573 | if !row_is_group && !row_is_ref { |
| 574 | continue; |
| 575 | } |
| 576 | |
| 577 | let row_data = csr_matrix.row(row); |
| 578 | for (&col, &value) in row_data.col_indices().iter().zip(row_data.values()) { |
| 579 | let value_f64 = value.to_f64().unwrap_or(0.0); |
| 580 | if row_is_group { |
| 581 | group_sums_f64[col] += value_f64; |
| 582 | group_sum_sq_f64[col] += value_f64 * value_f64; |
| 583 | } |
| 584 | if row_is_ref { |
| 585 | ref_sums_f64[col] += value_f64; |
| 586 | ref_sum_sq_f64[col] += value_f64 * value_f64; |
no test coverage detected