Skip to content

Commit

Permalink
Merge pull request #51 from stemangiola/master
Browse files Browse the repository at this point in the history
rebase
  • Loading branch information
stemangiola authored Jun 12, 2022
2 parents 766349d + e112ed3 commit 1ba467f
Show file tree
Hide file tree
Showing 26 changed files with 1,021 additions and 806 deletions.
6 changes: 5 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
^sccomp\.Rproj$
^\.Rproj\.user$
^\.github
^\.git
^README*
^dev$
^dev*
^dev/*
^rsconnect
model_glm_dirichlet_multinomial.rds
model_glm_dirichlet_multinomial_generate_quantities.rds
model_glm_dirichlet_multinomial_imputation.rds
^sccode_env
^sccomp_draws_files
^glm_multi*
^model_glm*
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Thanks for submitting an issue.

Please add the following information to the issue

1. Describe the issue/bug
2. Print out the input dataset immediately before the bug occurs
3. Paste the code immediately leading to the bug
4. Print out of the output, if any
5. Print out of the complete error/warning message, if any
6. sessionInfo()

Thanks!
436 changes: 137 additions & 299 deletions .github/workflows/check-bioc.yml

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ vignettes/introduction_cache*
sccomp.Rproj
Meta
doc

sccode_env*
src/stanExports*
slurm*
makeflow*

dmbvs-pid-50624.out
dmbvs-pid-39940.out
model_glm_dirichlet_multinomial.rds
model_glm_dirichlet_multinomial_generate_quantities.rds
model_glm_dirichlet_multinomial_imputation.rds
rsconnect

dev/*csv
dev/*rds
dev/*rda
Expand All @@ -37,3 +34,9 @@ dev/benchmark*
dev/*.gz
dev/*csv
dev/reproducible_example_beta_binomial_truncated
glm_multi_beta_binomial_cmdstanr
glm_multi_beta_binomial_cmdstanr.rds
glm_multi_beta_binomial_cmdstanr.stan
glm_multi_beta_binomial_generate_cmdstanr
glm_multi_beta_binomial_generate_cmdstanr.rds
glm_multi_beta_binomial_generate_cmdstanr.stan
13 changes: 8 additions & 5 deletions 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: 0.99.18
Version: 0.99.20
Authors@R: c(person("Stefano", "Mangiola", email = "[email protected]",
role = c("aut", "cre"))
)
Expand All @@ -12,13 +12,13 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
Biarch: true
Depends:
R (>= 4.1.0),
rstan (>= 2.18.1)
R (>= 4.1.0)
Imports:
methods,
Rcpp (>= 0.12.0),
RcppParallel (>= 5.0.1),
rstantools (>= 2.1.1),
rstan (>= 2.18.1),
SeuratObject,
SingleCellExperiment,
parallel,
Expand All @@ -35,14 +35,17 @@ Imports:
utils,
ggplot2,
ggrepel,
patchwork
patchwork,
forcats,
readr,
scales,
stringr
Suggests:
BiocStyle,
testthat (>= 3.0.0),
markdown,
ggplot2,
knitr,
forcats,
tidyseurat,
tidySingleCellExperiment
Enhances:
Expand Down
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ importFrom(dplyr,enquo)
importFrom(dplyr,left_join)
importFrom(dplyr,select)
importFrom(dplyr,with_groups)
importFrom(forcats,fct_reorder)
importFrom(ggrepel,geom_text_repel)
importFrom(magrittr,"%$%")
importFrom(magrittr,divide_by)
Expand All @@ -47,6 +48,7 @@ importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(purrr,pmap)
importFrom(purrr,when)
importFrom(readr,read_file)
importFrom(rlang,":=")
importFrom(rlang,enquo)
importFrom(rlang,ensym)
Expand All @@ -61,12 +63,15 @@ importFrom(rstan,sflist2stanfit)
importFrom(rstan,stan_model)
importFrom(rstan,summary)
importFrom(rstan,vb)
importFrom(scales,trans_new)
importFrom(stats,C)
importFrom(stats,model.matrix)
importFrom(stats,quantile)
importFrom(stats,rnorm)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,terms)
importFrom(stringr,str_replace)
importFrom(tibble,as_tibble)
importFrom(tibble,enframe)
importFrom(tibble,rowid_to_column)
Expand Down
35 changes: 31 additions & 4 deletions R/functions_multi_beta_binomial.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ estimate_multi_beta_binomial_glm = function(.data,
seed = sample(1e5, 1),
verbose = FALSE,
exclude_priors = FALSE,
bimodal_mean_variability_association = bimodal_mean_variability_association,
use_data = use_data,
max_sampling_iterations = 20000
) {
# Prepare column same enquo
Expand Down Expand Up @@ -86,9 +88,15 @@ estimate_multi_beta_binomial_glm = function(.data,
variance_association = variance_association,
truncation_ajustment = 1.1,
approximate_posterior_inference = approximate_posterior_inference == "all",
formula_variability = formula_variability
formula_variability = formula_variability,
bimodal_mean_variability_association = bimodal_mean_variability_association,
use_data = use_data
)

# Print design matrix
message(sprintf("sccomp says: the composition design matrix has columns: %s", data_for_model$X %>% colnames %>% paste(collapse=", ")))
message(sprintf("sccomp says: the variability design matrix has columns: %s", data_for_model$Xa %>% colnames %>% paste(collapse=", ")))

# Pior
data_for_model$prior_prec_intercept = prior_mean_variable_association$intercept
data_for_model$prior_prec_slope = prior_mean_variable_association$slope
Expand Down Expand Up @@ -136,7 +144,9 @@ estimate_multi_beta_binomial_glm = function(.data,
variance_association = FALSE,
truncation_ajustment = 1.1,
approximate_posterior_inference = approximate_posterior_inference %in% c("outlier_detection", "all"),
formula_variability = ~1
formula_variability = ~1,
bimodal_mean_variability_association = bimodal_mean_variability_association,
use_data = use_data
)

# Pior
Expand Down Expand Up @@ -206,7 +216,9 @@ estimate_multi_beta_binomial_glm = function(.data,
variance_association = variance_association,
truncation_ajustment = 1.1,
approximate_posterior_inference = approximate_posterior_inference %in% c("outlier_detection", "all"),
formula_variability = formula_variability
formula_variability = formula_variability,
bimodal_mean_variability_association = bimodal_mean_variability_association,
use_data = use_data
)

# Pior
Expand Down Expand Up @@ -296,6 +308,10 @@ estimate_multi_beta_binomial_glm = function(.data,

message("sccomp says: outlier-free model fitting - step 3/3 [ETA: ~20s]")

# Print design matrix
message(sprintf("sccomp says: the composition design matrix has columns: %s", data_for_model$X %>% colnames %>% paste(collapse=", ")))
message(sprintf("sccomp says: the variability design matrix has columns: %s", data_for_model$Xa %>% colnames %>% paste(collapse=", ")))

fit3 =
data_for_model %>%
# Run the first discovery phase with permissive false discovery rate
Expand Down Expand Up @@ -464,7 +480,14 @@ hypothesis_test_multi_beta_binomial_glm = function( .sample,
),
~ (.)
) %>%
select(parameter = C_name, everything())

# Add easy to understand covariate labels
left_join(
data_for_model$covariate_parameter_dictionary %>%
select(covariate, design_matrix_col),
by = c("C_name" = "design_matrix_col" )
) %>%
select(parameter = C_name, covariate, everything())

}

Expand Down Expand Up @@ -526,6 +549,8 @@ multi_beta_binomial_glm = function(.data,
seed = sample(1e5, 1),
verbose = FALSE,
exclude_priors = FALSE,
bimodal_mean_variability_association = FALSE,
use_data = TRUE,
test_composition_above_logit_fold_change,
max_sampling_iterations = 20000,
pass_fit = TRUE
Expand Down Expand Up @@ -554,6 +579,8 @@ multi_beta_binomial_glm = function(.data,
seed = seed,
verbose = verbose,
exclude_priors = exclude_priors,
bimodal_mean_variability_association = bimodal_mean_variability_association,
use_data = use_data,
max_sampling_iterations = max_sampling_iterations
)

Expand Down
Loading

0 comments on commit 1ba467f

Please sign in to comment.