Skip to content

Commit f2ccc25

Browse files
committed
Fix typo on example for registration_wrapper(). Add a bit more about how to explore the results. Actually with k = 2 we can run the pairwise model, so I've re-enabled that. Updating the warning for k = 2 accordingly. Used RStudio's automatic code formatter + styler's addin for styling the active file. Re-ran devtools::document(). Related to #86.
1 parent 9b1c722 commit f2ccc25

File tree

3 files changed

+66
-53
lines changed

3 files changed

+66
-53
lines changed

R/registration_wrapper.R

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@
4747
#' ## Compute all modeling results
4848
#' example_modeling_results <- registration_wrapper(
4949
#' sce,
50-
#' var_regustration ="Cell_Cycle",
51-
#' var_sample_id ="sample_id",
50+
#' var_registration = "Cell_Cycle",
51+
#' var_sample_id = "sample_id",
5252
#' covars = c("age"),
53-
#' gene_ensembl = "ensembl",
54-
#' gene_name = "gene_name",
53+
#' gene_ensembl = "ensembl",
54+
#' gene_name = "gene_name",
5555
#' suffix = "wrapper"
5656
#' )
57+
#'
58+
#' ## Explore the results from registration_wrapper()
59+
#' class(example_modeling_results)
60+
#' length(example_modeling_results)
61+
#' names(example_modeling_results)
62+
#' lapply(example_modeling_results, head)
5763
registration_wrapper <-
5864
function(sce,
5965
var_registration,
@@ -69,7 +75,8 @@ registration_wrapper <-
6975

7076
## Pseudobulk
7177
sce_pseudo <-
72-
registration_pseudobulk(sce,
78+
registration_pseudobulk(
79+
sce,
7380
var_registration = var_registration,
7481
var_sample_id = var_sample_id,
7582
min_ncells = min_ncells,
@@ -81,11 +88,14 @@ registration_wrapper <-
8188

8289
block_cor <-
8390
registration_block_cor(sce_pseudo, registration_model = registration_mod)
84-
91+
8592
## test if registration var has two groups
8693
registration_var_k2 <- length(grep("^registration_variable", colnames(registration_mod))) == 2
8794
if (registration_var_k2) {
88-
warning("You need 'var_registration' to have at least 3 different values to compute an F-statistic, returning Enrichment statistics only", call. = FALSE)
95+
warning(
96+
"You need 'var_registration' to have at least 3 unique values to compute an F-statistic and thus ANOVA modeling results cannot be computed.",
97+
call. = FALSE
98+
)
8999
}
90100

91101
results_enrichment <-
@@ -96,40 +106,36 @@ registration_wrapper <-
96106
gene_ensembl = gene_ensembl,
97107
gene_name = gene_name
98108
)
99-
100-
## with more than 2 groups run ANOVA and pairwise data
101-
if(!registration_var_k2){
102-
results_pairwise <-
109+
110+
results_pairwise <-
103111
registration_stats_pairwise(
104-
sce_pseudo,
105-
registration_model = registration_mod,
106-
block_cor = block_cor,
107-
gene_ensembl = gene_ensembl,
108-
gene_name = gene_name
109-
)
110-
results_anova <-
111-
registration_stats_anova(
112-
sce_pseudo,
113-
block_cor = block_cor,
114-
covars = covars,
115-
gene_ensembl = gene_ensembl,
116-
gene_name = gene_name,
117-
suffix = suffix
112+
sce_pseudo,
113+
registration_model = registration_mod,
114+
block_cor = block_cor,
115+
gene_ensembl = gene_ensembl,
116+
gene_name = gene_name
118117
)
119-
120-
modeling_results <- list(
121-
"anova" = results_anova,
122-
"enrichment" = results_enrichment,
123-
"pairwise" = results_pairwise
124-
)
118+
119+
## with more than 2 groups run ANOVA model
120+
if (!registration_var_k2) {
121+
results_anova <-
122+
registration_stats_anova(
123+
sce_pseudo,
124+
block_cor = block_cor,
125+
covars = covars,
126+
gene_ensembl = gene_ensembl,
127+
gene_name = gene_name,
128+
suffix = suffix
129+
)
125130
} else {
126-
modeling_results <- list(
127-
"anova" = NULL,
128-
"enrichment" = results_enrichment,
129-
"pairwise" = NULL
130-
)
131+
results_anova <- NULL
131132
}
132-
133133

134+
## Bundle results together
135+
modeling_results <- list(
136+
"anova" = NULL,
137+
"enrichment" = results_enrichment,
138+
"pairwise" = results_pairwise
139+
)
134140
return(modeling_results)
135141
}

man/registration_wrapper.Rd

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-registration_wrapper.R

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ rowData(sce)$ensembl <- paste0("ENSG", seq_len(nrow(sce)))
2020
rowData(sce)$gene_name <- paste0("gene", seq_len(nrow(sce)))
2121

2222

23-
test_that("warning for k=2 variable",
24-
example_modeling_results <- expect_warning(
25-
registration_wrapper(
26-
sce,
27-
var_registration ="Treatment",
28-
var_sample_id ="sample_id",
29-
covars = c("age"),
30-
gene_ensembl = "ensembl",
31-
gene_name = "gene_name",
32-
suffix = "wrapper"
33-
)
34-
)
23+
test_that(
24+
"warning for k=2 variable",
25+
example_modeling_results <- expect_warning(
26+
registration_wrapper(
27+
sce,
28+
var_registration = "Treatment",
29+
var_sample_id = "sample_id",
30+
covars = c("age"),
31+
gene_ensembl = "ensembl",
32+
gene_name = "gene_name",
33+
suffix = "wrapper"
34+
)
35+
)
3536
)

0 commit comments

Comments
 (0)