Skip to content

Commit 393f1a5

Browse files
committed
rebase
Merge branch 'master' into cmdstanr # Conflicts: # .Rbuildignore # .gitignore # NAMESPACE # R/functions_dirichlet_multinomial.R # R/functions_multi_beta.R # R/utilities.R # README.md # inst/figures/unnamed-chunk-10-1.png # inst/figures/unnamed-chunk-11-1.png # inst/figures/unnamed-chunk-12-1.png
2 parents 7dfe52d + ff735d7 commit 393f1a5

16 files changed

+644
-237
lines changed

.Rbuildignore

+13
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,16 @@
1414
sccomp_draws_files*
1515
src/stanExport*
1616
src/Rcpp*
17+
^\.git
18+
^README*
19+
^dev
20+
^rsconnect
21+
model_glm_dirichlet_multinomial.rds
22+
model_glm_dirichlet_multinomial_generate_quantities.rds
23+
model_glm_dirichlet_multinomial_imputation.rds
24+
#inst/stan/glm_multi_beta_binomial
25+
#inst/stan/glm_multi_beta_binomial_generate_date
26+
^doc$
27+
^Meta$
28+
sccomp_draws_files
29+

.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,42 @@
55
.Rapp.history
66
inst/doc
77
sccomp.Rproj
8+
Meta
9+
doc
10+
sccode_env*
11+
#src/stanExports*
12+
slurm*
13+
makeflow*
14+
dmbvs-pid-50624.out
15+
dmbvs-pid-39940.out
16+
model_glm_dirichlet_multinomial.rds
17+
model_glm_dirichlet_multinomial_generate_quantities.rds
18+
model_glm_dirichlet_multinomial_imputation.rds
19+
rsconnect
20+
dev/*csv
21+
dev/*rds
22+
dev/*rda
23+
dev/*pdf
24+
dev/dplyr-master/*
25+
#dev/bench_pipeline*
26+
#dev/article_figures*
27+
dev/metagenomics*
28+
dev/rlm_robust*
29+
dev/scCODA*
30+
dev/cytof*
31+
dev/qq_plot_simulations*
32+
dev/study_of_association*
33+
dev/*.gz
34+
dev/*csv
35+
dev/reproducible_example_beta_binomial_truncated
36+
glm_multi_beta_binomial_cmdstanr
37+
glm_multi_beta_binomial_cmdstanr.rds
38+
glm_multi_beta_binomial_cmdstanr.stan
39+
glm_multi_beta_binomial_generate_cmdstanr
40+
glm_multi_beta_binomial_generate_cmdstanr.rds
41+
glm_multi_beta_binomial_generate_cmdstanr.stan
42+
._*
43+
Rplot.pdf
44+
/doc/
45+
/Meta/
46+
sccomp_draws_files

R/functions_multi_beta_binomial.R

+6
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ sccomp_glm_data_frame_counts = function(.data,
335335

336336
#' @importFrom stats model.matrix
337337
get_mean_precision = function(fit, data_for_model){
338+
339+
# Define the variables as NULL to avoid CRAN NOTES
340+
M <- NULL
341+
`2.5%` <- NULL
342+
`97.5%` <- NULL
343+
338344
fit %>%
339345
summary_to_tibble("alpha", "C", "M") %>%
340346

R/methods.R

+23-7
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,9 @@ sccomp_test.sccomp_tbl = function(.data,
10271027
add_attr(.data |> attr("fit") , "fit")
10281028

10291029
result |>
1030+
1031+
add_attr(test_composition_above_logit_fold_change, "test_composition_above_logit_fold_change") |>
1032+
10301033
# Attach association mean concentration
10311034
add_attr(.data |> attr("model_input") , "model_input") |>
10321035
add_attr(.data |> attr("truncation_df2"), "truncation_df2") |>
@@ -1501,6 +1504,7 @@ simulate_data.tbl = function(.data,
15011504
#' @param .data A tibble including a cell_group name column | sample name column | read counts column | factor columns | Pvalue column | a significance column
15021505
#' @param factor A character string for a factor of interest included in the model
15031506
#' @param significance_threshold A real. FDR threshold for labelling significant cell-groups.
1507+
#' @param test_composition_above_logit_fold_change A positive integer. It is the effect threshold used for the hypothesis test. A value of 0.2 correspond to a change in cell proportion of 10% for a cell type with baseline proportion of 50%. That is, a cell type goes from 45% to 50%. When the baseline proportion is closer to 0 or 1 this effect thrshold has consistent value in the logit uncontrained scale.
15041508
#'
15051509
#' @return A `ggplot`
15061510
#'
@@ -1519,13 +1523,18 @@ simulate_data.tbl = function(.data,
15191523
#' sccomp_test()
15201524
#'
15211525
#' # estimate |> sccomp_boxplot()
1522-
sccomp_boxplot = function(.data, factor, significance_threshold = 0.025){
1526+
sccomp_boxplot = function(.data, factor, significance_threshold = 0.05, test_composition_above_logit_fold_change = .data |> attr("test_composition_above_logit_fold_change")){
15231527

15241528

15251529
.cell_group = attr(.data, ".cell_group")
15261530
.count = attr(.data, ".count")
15271531
.sample = attr(.data, ".sample")
15281532

1533+
# Check if test have been done
1534+
if(.data |> select(ends_with("FDR")) |> ncol() |> equals(0))
1535+
stop("sccomp says: to produce plots, you need to run the function sccomp_test() on your estimates.")
1536+
1537+
15291538
data_proportion =
15301539
.data %>%
15311540

@@ -1566,7 +1575,9 @@ sccomp_boxplot = function(.data, factor, significance_threshold = 0.025){
15661575
#' @importFrom magrittr equals
15671576
#'
15681577
#' @param x A tibble including a cell_group name column | sample name column | read counts column | factor columns | Pvalue column | a significance column
1569-
#' @param ... parameters like significance_threshold A real. FDR threshold for labelling significant cell-groups.
1578+
#' @param significance_threshold Numeric value specifying the significance threshold for highlighting differences. Default is 0.025.
1579+
#' @param test_composition_above_logit_fold_change A positive integer. It is the effect threshold used for the hypothesis test. A value of 0.2 correspond to a change in cell proportion of 10% for a cell type with baseline proportion of 50%. That is, a cell type goes from 45% to 50%. When the baseline proportion is closer to 0 or 1 this effect thrshold has consistent value in the logit uncontrained scale.
1580+
#' @param ... For internal use
15701581
#'
15711582
#' @return A `ggplot`
15721583
#'
@@ -1585,8 +1596,13 @@ sccomp_boxplot = function(.data, factor, significance_threshold = 0.025){
15851596
#'
15861597
#' # estimate |> plot()
15871598
#'
1588-
plot.sccomp_tbl <- function(x, ...) {
1599+
plot.sccomp_tbl <- function(x, significance_threshold = 0.05, test_composition_above_logit_fold_change = .data |> attr("test_composition_above_logit_fold_change"), ...) {
15891600

1601+
# Define the variables as NULL to avoid CRAN NOTES
1602+
parameter <- NULL
1603+
count_data <- NULL
1604+
v_effect <- NULL
1605+
15901606
.cell_group = attr(x, ".cell_group")
15911607
.count = attr(x, ".count")
15921608
.sample = attr(x, ".sample")
@@ -1638,7 +1654,7 @@ else {
16381654
.cell_group = !!.cell_group,
16391655
.sample = !!.sample,
16401656
my_theme = multipanel_theme,
1641-
...
1657+
significance_threshold = significance_threshold
16421658
)
16431659

16441660
# If discrete
@@ -1651,7 +1667,7 @@ else {
16511667
.cell_group = !!.cell_group,
16521668
.sample = !!.sample,
16531669
my_theme = multipanel_theme,
1654-
...
1670+
significance_threshold = significance_threshold
16551671
)
16561672

16571673
# Return
@@ -1662,10 +1678,10 @@ else {
16621678
}
16631679

16641680
# 1D intervals
1665-
plots$credible_intervals_1D = plot_1d_intervals(.data = x, .cell_group = !!.cell_group, my_theme = multipanel_theme, ...)
1681+
plots$credible_intervals_1D = plot_1D_intervals(.data = x, significance_threshold = significance_threshold)
16661682

16671683
# 2D intervals
1668-
if("v_effect" %in% colnames(x) && (x |> filter(!is.na(v_effect)) |> nrow()) > 0) plots$credible_intervals_2D = plot_2d_intervals(.data = x, .cell_group = !!.cell_group, my_theme = multipanel_theme, ...)
1684+
if("v_effect" %in% colnames(x) && (x |> filter(!is.na(v_effect)) |> nrow()) > 0) plots$credible_intervals_2D = plot_2D_intervals(.data = x, significance_threshold = significance_threshold)
16691685

16701686
plots
16711687

0 commit comments

Comments
 (0)