Skip to content

Commit

Permalink
Merge pull request #352 from biomage-org/fix-manual-spline
Browse files Browse the repository at this point in the history
Fix number of genes vs UMIs manual spline
  • Loading branch information
saracastel authored Jan 16, 2024
2 parents 47aaa32 + dd6ffa0 commit d69ba27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pipeline-runner/R/qc-4-filter_gene_umi_outlier.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ filter_gene_umi_outlier <- function(scdata_list, config, sample_id, cells_id, ta

# get p_level and update in config
# defaults from "gene.vs.molecule.cell.filter" in pagoda2
if (safeTRUE(config$auto))
if (safeTRUE(config$auto) || is.null(config$filterSettings$predictionInterval))
p_level <- min(0.001, 1 / ncol(sample_data))
else
p_level <- 1 - as.numeric(config$filterSettings$predictionInterval)
Expand Down
22 changes: 22 additions & 0 deletions pipeline-runner/tests/testthat/test-qc-4-filter_gene_umi_outlier.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,25 @@ test_that("Gene UMI filter throws error if input is a non float-interpretable st

expect_error(filter_gene_umi_outlier(scdata, config, sample_2_id, cells_id))
})

test_that("Gene UMI filter works with manual settings and default prediction interval value", {
c(scdata_list, sample_1_id, sample_2_id) %<-% mock_scdata()
config <- mock_config()
cells_id <- mock_ids()
type <- "spline"
config$filterSettings$regressionType <- type

config$auto <- TRUE
out_auto <- filter_gene_umi_outlier(scdata_list, config, sample_1_id, cells_id)

config$auto <- FALSE
out_manual <- filter_gene_umi_outlier(scdata_list, config, sample_1_id, cells_id)

expect_null(config$filterSettings$predictionInterval)
expect_equal(
out_auto$config$filterSettings$regressionTypeSettings[[type]]$p.level,
out_manual$config$filterSettings$regressionTypeSettings[[type]]$p.level
)
})


0 comments on commit d69ba27

Please sign in to comment.