Skip to content

Commit 639d4b0

Browse files
authored
Merge pull request #181 from MangiolaLaboratory/check-for-factor-consistency
fix check for ~ 1 formula
2 parents e137556 + a38ec67 commit 639d4b0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: sccomp
22
Title: Tests differences in cell-type proportion for single-cell data, robust to outliers
3-
Version: 1.99.12
3+
Version: 1.99.13
44
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
55
role = c("aut", "cre"))
66
)

R/utilities.R

+4
Original file line numberDiff line numberDiff line change
@@ -3548,6 +3548,10 @@ check_sample_consistency_of_factors = function(.data, my_formula, .sample, .cell
35483548
# Check that I have one set of covariates per sample
35493549
first_cell_group = .data |> pull(!!.cell_group) |> _[[1]]
35503550

3551+
# If the formula is intercept only -> ~ 1 this test does not apply
3552+
if(my_formula |> parse_formula() |> length() == 0)
3553+
return(TRUE)
3554+
35513555
any_covariate_not_matching_sample_size =
35523556
.data |>
35533557
filter(!!.cell_group == first_cell_group) |>

tests/testthat/test-sccomp_.R

+10
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,16 @@ test_that("sample ID malformed", {
810810
.abundance = count
811811
) |>
812812
expect_no_error()
813+
814+
# For ~ 1 formula do not expect error
815+
model_without_association =
816+
seurat_obj |>
817+
sccomp_estimate(
818+
formula_composition = ~ 1,
819+
.sample = sample,
820+
.cell_group = cell_group
821+
) |>
822+
expect_no_error()
813823

814824
})
815825

0 commit comments

Comments
 (0)