Skip to content

Fix boxplot with no significance #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sccomp
Title: Robust Outlier-aware Estimation of Composition and Heterogeneity for Single-cell Data
Version: 1.9.3
Version: 1.9.5
Authors@R: c(person("Stefano", "Mangiola", email = "mangiolastefano@gmail.com",
role = c("aut", "cre"))
)
Expand Down
16 changes: 8 additions & 8 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ fit_model = function(
# Fit
mod = load_model(model_name, threads = cores)

# Avoid 0 proportions
if(data_for_model$is_proportion && min(data_for_model$y_proportion)==0){
warning("sccomp says: your proportion values include 0. Assuming that 0s derive from a precision threshold (e.g. deconvolution), 0s are converted to the smaller non 0 proportion value.")
data_for_model$y_proportion[data_for_model$y_proportion==0] =
min(data_for_model$y_proportion[data_for_model$y_proportion>0])
}

if(inference_method == "hmc"){

Expand Down Expand Up @@ -1318,11 +1324,6 @@ data_spread_to_model_input =
y_proportion = y[0,,drop = FALSE]
}

if(is_proportion && min(y_proportion)==0){
warning("sccomp says: your proportion values include 0. Assuming that 0s derive from a precision threshold (e.g. deconvolution), 0s are converted to the smaller non 0 proportion value.")
y_proportion[y_proportion==0] = min(y_proportion[y_proportion>0])
}


data_for_model =
list(
Expand Down Expand Up @@ -2118,7 +2119,7 @@ plot_boxplot = function(
)
}

if(nrow(significance_colors) == 0 |
if(nrow(significance_colors) == 0 ||
length(intersect(
significance_colors |> pull(!!as.symbol(factor_of_interest)),
data_proportion |> pull(!!as.symbol(factor_of_interest))
Expand All @@ -2133,8 +2134,7 @@ plot_boxplot = function(
outlier.shape = NA, outlier.color = NA,outlier.size = 0,
data =
data_proportion |>
mutate(!!as.symbol(factor_of_interest) := as.character(!!as.symbol(factor_of_interest))) %>%
left_join(significance_colors, by = c(quo_name(.cell_group), factor_of_interest)),
mutate(!!as.symbol(factor_of_interest) := as.character(!!as.symbol(factor_of_interest))) ,
fatten = 0.5,
lwd=0.5,
)
Expand Down
Binary file added data/no_significance_df.rda
Binary file not shown.
21 changes: 21 additions & 0 deletions tests/testthat/test-sccomp_.R
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,27 @@ test_that("sccomp_proportional_fold_change",{

})

test_that("plotting for no significance",{

skip_cmdstan()


no_significance_df |>
mutate(count = count |> as.integer()) |>
sccomp_estimate(formula_composition = ~ condition,
.sample = sample,
.cell_group = cell_group,.abundance = count,
bimodal_mean_variability_association = TRUE,
cores = 1
) |>
sccomp_test() |>
sccomp_boxplot("condition") |>
expect_no_error()




})

# fit =
# seurat_obj |>
Expand Down
Loading