|
18 | 18 | #' @export |
19 | 19 | #' |
20 | 20 | #' @examples |
21 | | -#' \dontrun{ |
22 | | -#' charging <- read_charging_multi(paths) |
23 | | -#' mat <- abundance_count_matrix(charging) |
24 | | -#' } |
| 21 | +#' results <- read_pipeline_results( |
| 22 | +#' clover_example("ecoli/config.yaml"), |
| 23 | +#' types = "charging" |
| 24 | +#' ) |
| 25 | +#' abundance_count_matrix(results$charging) |
25 | 26 | abundance_count_matrix <- function(charging_data, min_count = 10) { |
26 | 27 | abundance <- charging_data |> |
27 | 28 | dplyr::mutate( |
@@ -63,10 +64,11 @@ abundance_count_matrix <- function(charging_data, min_count = 10) { |
63 | 64 | #' @export |
64 | 65 | #' |
65 | 66 | #' @examples |
66 | | -#' \dontrun{ |
67 | | -#' charging <- read_charging_multi(paths) |
68 | | -#' mat <- charging_count_matrix(charging) |
69 | | -#' } |
| 67 | +#' results <- read_pipeline_results( |
| 68 | +#' clover_example("ecoli/config.yaml"), |
| 69 | +#' types = "charging" |
| 70 | +#' ) |
| 71 | +#' charging_count_matrix(results$charging) |
70 | 72 | charging_count_matrix <- function(charging_data, min_count = 10) { |
71 | 73 | long <- charging_data |> |
72 | 74 | dplyr::mutate( |
@@ -115,14 +117,12 @@ charging_count_matrix <- function(charging_data, min_count = 10) { |
115 | 117 | #' @export |
116 | 118 | #' |
117 | 119 | #' @examples |
118 | | -#' \dontrun{ |
119 | | -#' mat <- abundance_count_matrix(charging) |
120 | | -#' sample_info <- data.frame( |
121 | | -#' sample_id = c("wt_1", "wt_2", "mut_1", "mut_2"), |
122 | | -#' condition = c("wt", "wt", "mut", "mut") |
| 120 | +#' results <- read_pipeline_results( |
| 121 | +#' clover_example("ecoli/config.yaml"), |
| 122 | +#' types = "charging" |
123 | 123 | #' ) |
124 | | -#' coldata <- build_coldata(mat, sample_info) |
125 | | -#' } |
| 124 | +#' mat <- abundance_count_matrix(results$charging) |
| 125 | +#' build_coldata(mat) |
126 | 126 | build_coldata <- function(count_matrix, sample_info = NULL) { |
127 | 127 | col_names <- colnames(count_matrix) |
128 | 128 |
|
@@ -181,8 +181,14 @@ build_coldata <- function(count_matrix, sample_info = NULL) { |
181 | 181 | #' @export |
182 | 182 | #' |
183 | 183 | #' @examples |
184 | | -#' \dontrun{ |
185 | | -#' dds <- run_deseq(mat, coldata, design = ~ condition) |
| 184 | +#' \donttest{ |
| 185 | +#' se <- create_clover(clover_example("ecoli/config.yaml")) |
| 186 | +#' counts <- SummarizedExperiment::assay(se, "counts") |
| 187 | +#' coldata <- as.data.frame(SummarizedExperiment::colData(se)) |
| 188 | +#' coldata$condition <- ifelse( |
| 189 | +#' grepl("ctl", coldata$sample_id), "ctl", "inf" |
| 190 | +#' ) |
| 191 | +#' dds <- run_deseq(counts, coldata, design = ~condition) |
186 | 192 | #' } |
187 | 193 | run_deseq <- function(count_matrix, coldata, design, ...) { |
188 | 194 | rlang::check_installed("DESeq2", reason = "to run differential analysis.") |
@@ -214,9 +220,15 @@ run_deseq <- function(count_matrix, coldata, design, ...) { |
214 | 220 | #' @export |
215 | 221 | #' |
216 | 222 | #' @examples |
217 | | -#' \dontrun{ |
218 | | -#' res <- tidy_deseq_results(dds, contrast = c("condition", "mut", "wt")) |
219 | | -#' res |
| 223 | +#' \donttest{ |
| 224 | +#' se <- create_clover(clover_example("ecoli/config.yaml")) |
| 225 | +#' counts <- SummarizedExperiment::assay(se, "counts") |
| 226 | +#' coldata <- as.data.frame(SummarizedExperiment::colData(se)) |
| 227 | +#' coldata$condition <- ifelse( |
| 228 | +#' grepl("ctl", coldata$sample_id), "ctl", "inf" |
| 229 | +#' ) |
| 230 | +#' dds <- run_deseq(counts, coldata, design = ~condition) |
| 231 | +#' tidy_deseq_results(dds, contrast = c("condition", "inf", "ctl")) |
220 | 232 | #' } |
221 | 233 | tidy_deseq_results <- function(dds, contrast, padj_cutoff = 0.05) { |
222 | 234 | rlang::check_installed("DESeq2", reason = "to extract results.") |
|
0 commit comments