Skip to content
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
4 changes: 2 additions & 2 deletions R/deseq-related-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ get_results_from_dds <- function(dds = dds,
res_df <- get_all_results(dds)
} else {
lapply(seq_len(nrow(df)), function(i) {
get_single_result(dds = dds, comp_df = df[1, ])
get_single_result(dds = dds, comp_df = df[i, ])
}) %>%
do.call("rbind", .) -> res_df
}
Expand Down Expand Up @@ -180,6 +180,6 @@ save_results <- function(res_df, op_dir, thresh = 0.05) {
dplyr::filter(padj <= thresh) |>
readr::write_delim(ofn_sig, delim = "\t")
} else {
message("No significant gene detected for the comparison ", ofn_prefix)
message(paste("No significant gene detected for the comparison ", ofn_prefix))
}
}
6 changes: 3 additions & 3 deletions R/plot-deseq.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,16 @@ make_upset_df <- function(dds, meta_df, contrasts_df = NULL, thresh = 0.05) {
make_upset_plot <- function(upset_df) {
upset_df |>
ggplot2::ggplot(ggplot2::aes(x = comp_updown)) +
ggplot2::geom_bar() +
ggplot2::geom_bar(fill = "#5A5A5A") +
ggplot2::geom_text(stat = "count",
ggplot2::aes(label = ggplot2::after_stat(count)),
vjust = 1.1, color = "#F0F0F0", size = 2) +
vjust = 1.1, color = "#010101", size = 3) +
ggplot2::labs(title = "Combined Gene Visualization",
x = "Comparison and Up/Down Status",
y = "Frequency (No. of Significant Genes)") +
ggplot2::theme_minimal() +
my_rnaseq_theme() +
ggupset::scale_x_upset(order_by = "degree") +
ggupset::scale_x_upset(order_by = "freq") +
ggupset::theme_combmatrix(
combmatrix.panel.point.color.empty = "grey90",
combmatrix.panel.striped_background.color.one = "darkgrey",
Expand Down
25 changes: 17 additions & 8 deletions R/qmd_template_parts.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @param title Title for the report
#' @param author Author for the report
#' @param email Email of the author for the report
#' @param ... Other parameters to set the yaml header
#'
#' @return opening_yaml string to be used to construct the report qmd
#' @export
Expand All @@ -13,7 +14,8 @@
#' }
template_yaml <- function(title = "RNA-Seq Report",
author = "Sameet",
email = "sameet.mehta@yale.edu") {
email = "sameet.mehta@yale.edu",
...) {
opening_yaml <- stringr::str_glue("
---
title: \"{title}\"
Expand All @@ -34,11 +36,11 @@ execute:
message: false
echo: true
params:
counts: \"gene_count_matrix.csv\"
meta_fn: \"sample-sheet.txt\"
counts: \"{count_fn}\"
meta_fn: \"{sample_fn}\"
contrasts_fn: null
metrics: null
outputs: \"report_output_dir\"
outputs: \"{outputdir}\"
use_threshold: 0.05
---
")
Expand Down Expand Up @@ -301,7 +303,7 @@ downreg_rows <- which(use_sig_df_{comp_n}$log2FoldChange < 0)

use_sig_df_{comp_n} |>
kableExtra::kbl(booktabs = TRUE) |>
kableExtra::kable_stying(bootstrap_options = c(\"condensed\"),
kableExtra::kable_styling(bootstrap_options = c(\"condensed\"),
latex_options = c(\"striped\"),
font_size = 8
) |>
Expand Down Expand Up @@ -337,7 +339,7 @@ all_plot_{comp_n}$bp_s
```
```{{r}}
#| label: fig-hm_{comp_n}
#| fig-cap: Heatmp for all significant genes for {comparison_name}. There are total `r nrow(sig_df)` significant genes.
#| fig-cap: Heatmp for all significant genes for {comparison_name}. There are total {sig_genes} significant genes.

ggplotify::as.ggplot(all_plot_{comp_n}$hm)
```
Expand Down Expand Up @@ -366,7 +368,11 @@ PCA plot is a potent dimensionality reduction method that can show the discrimin
pca_p_l <- make_pca_plot_l(dds = dds, vs_data = vs_data, contrasts_df = contrasts_df, thresh = params$use_threshold)
patchwork::wrap_plots(pca_p_l, nrow = 2, byrow = TRUE) +
patchwork::plot_layout(guides = \"collect\") +
patchwork::plot_annotation(tag_levels = \"A\")
patchwork::plot_annotation(tag_levels = \"A\") -> pca_plot

ofn_pca <- file.path(params$outputs, \"all-pca-plot.pdf\")
ggplot2::ggsave(filename = ofn_pca, device = \"pdf\", plot = pca_plot)
pca_plot
```
PCA plot for the data in this report is given in @fig-pca.

Expand All @@ -386,7 +392,10 @@ Upset plot for the data in this analysis is given in @fig_upset

upset_df <- make_upset_df(dds = dds, meta_df = meta_df,
contrasts_df = contrasts_df, thresh = params$use_threshold)
upset_plot <- make_upset_plot(uset_df)
upset_plot <- make_upset_plot(upset_df)
ofn_upset <- file.path(params$outputs, \"upset-plot.pdf\")
ggplot2::ggsave(filname = ofn_upset, device = \"pdf\", plot = upset_plot)
upset_plot
```
In @fig_upset the number in the bars denotes number of genes satisfying that condition.
")
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,5 @@ contrasts_df <- get_contrasts(fn = "path/to/contrasts/file.txt")
meta_df <- read_meta_data("path/to/sample-sheet.txt")
compose_qmd(ofn = "path/to/output/directory/where/the/qmd_is_saved.qmd",
contrasts_df = contrasts_df)
# As long as the object dds is available this compose_qmd call will work.
```
149 changes: 149 additions & 0 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@
"Repository": "RSPM",
"Hash": "b7d8d8ee39869c18d8846a184dd8a1af"
},
"brio": {
"Package": "brio",
"Version": "1.1.3",
"Source": "Repository",
"Repository": "RSPM",
"Hash": "976cf154dfb043c012d87cddd8bca363"
},
"bslib": {
"Package": "bslib",
"Version": "0.5.1",
Expand Down Expand Up @@ -561,6 +568,35 @@
],
"Hash": "511bacbfa153a15251166b463b4da4f9"
},
"desc": {
"Package": "desc",
"Version": "1.4.2",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"R6",
"cli",
"rprojroot",
"utils"
],
"Hash": "6b9602c7ebbe87101a9c8edb6e8b6d21"
},
"diffobj": {
"Package": "diffobj",
"Version": "0.3.5",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"crayon",
"methods",
"stats",
"tools",
"utils"
],
"Hash": "bcaa8b95f8d7d01a5dedfd959ce88ab8"
},
"digest": {
"Package": "digest",
"Version": "0.6.33",
Expand Down Expand Up @@ -1172,6 +1208,24 @@
],
"Hash": "15da5a8412f317beeee6175fbc76f4bb"
},
"pkgbuild": {
"Package": "pkgbuild",
"Version": "1.4.2",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"R6",
"callr",
"cli",
"crayon",
"desc",
"prettyunits",
"processx",
"rprojroot"
],
"Hash": "beb25b32a957a22a5c301a9e441190b3"
},
"pkgconfig": {
"Package": "pkgconfig",
"Version": "2.0.3",
Expand All @@ -1182,6 +1236,34 @@
],
"Hash": "01f28d4278f15c76cddbea05899c5d6f"
},
"pkgload": {
"Package": "pkgload",
"Version": "1.3.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"cli",
"crayon",
"desc",
"fs",
"glue",
"methods",
"pkgbuild",
"rlang",
"rprojroot",
"utils",
"withr"
],
"Hash": "903d68319ae9923fb2e2ee7fa8230b91"
},
"praise": {
"Package": "praise",
"Version": "1.0.0",
"Source": "Repository",
"Repository": "RSPM",
"Hash": "a555924add98c99d2f411e37e7d25e9f"
},
"prettyunits": {
"Package": "prettyunits",
"Version": "1.2.0",
Expand Down Expand Up @@ -1277,6 +1359,16 @@
],
"Hash": "b5047343b3825f37ad9d3b5d89aa1078"
},
"rematch2": {
"Package": "rematch2",
"Version": "2.1.2",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"tibble"
],
"Hash": "76c9e04c712a05848ae7a23d2f170a40"
},
"renv": {
"Package": "renv",
"Version": "1.0.3",
Expand Down Expand Up @@ -1322,6 +1414,16 @@
],
"Hash": "d65e35823c817f09f4de424fcdfa812a"
},
"rprojroot": {
"Package": "rprojroot",
"Version": "2.0.3",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R"
],
"Hash": "1de7ab598047a87bba48434ba35d497d"
},
"rstudioapi": {
"Package": "rstudioapi",
"Version": "0.15.0",
Expand Down Expand Up @@ -1465,6 +1567,36 @@
],
"Hash": "90b28393209827327de889f49935140a"
},
"testthat": {
"Package": "testthat",
"Version": "3.1.10",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"R",
"R6",
"brio",
"callr",
"cli",
"desc",
"digest",
"ellipsis",
"evaluate",
"jsonlite",
"lifecycle",
"magrittr",
"methods",
"pkgload",
"praise",
"processx",
"ps",
"rlang",
"utils",
"waldo",
"withr"
],
"Hash": "6f403dc49295610a3a67ea1a9ca64346"
},
"tibble": {
"Package": "tibble",
"Version": "3.2.1",
Expand Down Expand Up @@ -1604,6 +1736,23 @@
],
"Hash": "8318e64ffb3a70e652494017ec455561"
},
"waldo": {
"Package": "waldo",
"Version": "0.5.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"cli",
"diffobj",
"fansi",
"glue",
"methods",
"rematch2",
"rlang",
"tibble"
],
"Hash": "2c993415154cdb94649d99ae138ff5e5"
},
"webshot": {
"Package": "webshot",
"Version": "0.5.5",
Expand Down