Skip to content

Commit

Permalink
Updated logic of calc_variance() for data with no replicates to consi…
Browse files Browse the repository at this point in the history
…der expression_value
  • Loading branch information
ruthkr committed Mar 11, 2024
1 parent b063da5 commit 43ffccf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/utils-calcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ calc_variance <- function(all_data, exp_sd = NA) {

# Set variance for data with no replicates
if (nrow(all_data_no_reps) > 0) {
all_data_no_reps[, var := 0.01]
all_data_no_reps[, var := pmax(expression_value / 10, 0.25), by = .(gene_id, accession, timepoint)]
}

# Combine data
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils-calcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ test_that("calc_variance works", {

# Expected outputs
expect_gt(length(unique(var_with_reps$var)), 1)
expect_equal(length(unique(var_with_no_reps$var)), 1)
expect_true(all(var_with_no_reps$var >= 0.25))
})

0 comments on commit 43ffccf

Please sign in to comment.