diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e20ef2..85f2aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ ## SINCLAIR development version - Set main job memory to 2 GB for slurm mode. (#205, @kelly-sovacool) +- Improvements to R Markdown reports: (#216, @kelly-sovacool) + - Link to function documentation websites. + - Use code folding to include code in output, but set it to 'hide' by default. + - Hide R messages by default. ## SINCLAIR 0.3.5 diff --git a/bin/batch_correction_cca.Rmd b/bin/batch_correction_cca.Rmd index 93ce5fc..a21ea7f 100755 --- a/bin/batch_correction_cca.Rmd +++ b/bin/batch_correction_cca.Rmd @@ -1,8 +1,12 @@ --- title: "Batch Correction: CCA" -author: "Samantha Sevilla" +author: "CCR Collaborative Bioinformatics Resource" date: "`r Sys.Date()`" -output: html_document +output: + html_document: + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -17,9 +21,14 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` - -```{r, prep_args, message=FALSE} +```{r, prep_args} # set up params species <- params$species gid <- params$gid @@ -38,7 +47,7 @@ testing <- params$testing scRNA_functions <- params$scRNA_functions ``` -```{r, handle_pkg, message=FALSE} +```{r, handle_pkg} # source functions source(scRNA_functions) @@ -62,7 +71,7 @@ scRNA_handle_packages(pkg_df) options(future.globals.maxSize = 96000 * 1024^2) ``` -```{r, processing, message=FALSE} +```{r, processing} # read in merged object so <- readRDS(mergedObj) @@ -78,7 +87,7 @@ so_corrected <- MAIN_BATCH_CORRECTION(so, npcs, species, resolution, ) ``` -```{r saveoutputs, message=FALSE, include=FALSE, echo=FALSE} +```{r saveoutputs include=FALSE} fpath <- paste0(gid, "_batch_correction_cca.rds") saveRDS(so_corrected, fpath) ``` diff --git a/bin/batch_correction_harmony.Rmd b/bin/batch_correction_harmony.Rmd index e2b8753..215efba 100755 --- a/bin/batch_correction_harmony.Rmd +++ b/bin/batch_correction_harmony.Rmd @@ -1,8 +1,12 @@ --- title: "Batch Correction: Harmony" -author: "Samantha Sevilla" +author: "CCR Collaborative Bioinformatics Resource" date: "`r Sys.Date()`" -output: html_document +output: + html_document: + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -17,8 +21,13 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- - -```{r, prep_args, message=FALSE, echo=FALSE, include=FALSE} +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` +```{r, prep_args, include=FALSE} # set up params species <- params$species gid <- params$gid @@ -36,7 +45,7 @@ Rpkg_config <- params$Rpkg_config scRNA_functions <- params$scRNA_functions ``` -```{r, handle_pkg, message=FALSE} +```{r, handle_pkg} # source functions source(scRNA_functions) @@ -60,7 +69,7 @@ scRNA_handle_packages(pkg_df) options(future.globals.maxSize = 96000 * 1024^2) ``` -```{r, processing, message=FALSE} +```{r, processing} # read in merged object so <- readRDS(mergedObj) @@ -76,7 +85,7 @@ so_corrected <- MAIN_BATCH_CORRECTION(so, npcs, species, resolution, ) ``` -```{r saveoutputs, message=FALSE, include=FALSE, echo=FALSE} +```{r saveoutputs include=FALSE} fpath <- paste0(gid, "_batch_correction_harmony.rds") saveRDS(so_corrected, fpath) ``` diff --git a/bin/batch_correction_integration.Rmd b/bin/batch_correction_integration.Rmd index d96a7ad..7b0f6d7 100755 --- a/bin/batch_correction_integration.Rmd +++ b/bin/batch_correction_integration.Rmd @@ -1,8 +1,12 @@ --- title: "Batch Correction Analysis" -author: "CCBR" -date: '`r format(Sys.time(), "%a %b %d %Y - %X")`' -output: html_document +author: "CCR Collaborative Bioinformatics Resource" +date: "`r Sys.Date()`" +output: + html_document: + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console always_allow_html: true @@ -23,8 +27,13 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- - -```{r, prep_args, message=FALSE, echo=FALSE, include=FALSE} +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` +```{r, prep_args, include=FALSE} # set up params # species= params$species gid <- params$gid @@ -51,7 +60,7 @@ unlink(tmp_images, recursive = TRUE) dir.create(file.path("tmp_images"), showWarnings = FALSE) ``` -```{r, handle_pkg, message=FALSE, echo=FALSE, include=FALSE} +```{r, handle_pkg include=FALSE} # source functions source(scRNA_functions) @@ -71,7 +80,7 @@ pkg_df scRNA_handle_packages(pkg_df) ``` -```{r, processing, message=FALSE, echo=FALSE, include=FALSE} +```{r, processing include=FALSE} # read in merged objects so_merged <- readRDS(mergedObj) so_rpca <- readRDS(rpcaObj) @@ -89,7 +98,7 @@ objList <- c("merged", "rpca", "integrated", "harmony", "liger") ### Samples -```{r sampleBatchCorrection, echo=FALSE, fig.width=15, fig.height=15} +```{r sampleBatchCorrection, fig.width=15, fig.height=15} # plot plot_list_s <- list() @@ -123,7 +132,7 @@ annotate_figure(p, ### Groups -```{r groupBatchCorrection, echo=FALSE, fig.width=15, fig.height=15} +```{r groupBatchCorrection, fig.width=15, fig.height=15} plot_list_g <- list() for (i in 1:length(objList)) { obj <- OBJECT_SELECT(objList[i]) @@ -150,7 +159,7 @@ annotate_figure(p, ### Cell type annotations -```{r annotationBatchCorrection, echo=FALSE, fig.width=15, fig.height=15} +```{r annotationBatchCorrection, fig.width=15, fig.height=15} plot_list_annot <- list() for (i in 1:length(objList)) { obj <- OBJECT_SELECT(objList[i]) @@ -187,7 +196,7 @@ DT::datatable( ### RPCA -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "rpca" files <- list.files( path = tmp_images, @@ -203,7 +212,7 @@ if (length(files) > 0) { ### ccaIntegrated -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "int" files <- list.files( path = tmp_images, @@ -219,7 +228,7 @@ if (length(files) > 0) { ### Harmony -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "harmony" files <- list.files( path = tmp_images, @@ -237,7 +246,7 @@ if (length(files) > 0) { ### scvi -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "scvi" files <- list.files( path = tmp_images, @@ -255,7 +264,7 @@ if (length(files) > 0) { ### liger -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "liger" files <- list.files( path = tmp_images, @@ -271,7 +280,7 @@ if (length(files) > 0) { ## Silhouette scores {.tabset} -```{r silhouetteImages, message=FALSE, echo=FALSE, include=FALSE} +```{r silhouetteImages, , include=FALSE} # create matrix resSil_merged <- matrix(ncol = 2, nrow = length(resolution)) resSil_merged[] <- 0 @@ -412,7 +421,7 @@ for (i in 1:length(objList)) { ### RPCA -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "rpca" files <- list.files( path = tmp_images, @@ -428,7 +437,7 @@ if (length(files) > 0) { ### ccaIntegrated -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "int" files <- list.files( path = tmp_images, @@ -444,7 +453,7 @@ if (length(files) > 0) { ### Harmony -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "harmony" files <- list.files( path = tmp_images, @@ -462,7 +471,7 @@ if (length(files) > 0) { ### scvi -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "scvi" files <- list.files( path = tmp_images, @@ -480,7 +489,7 @@ if (length(files) > 0) { ### liger -```{r, echo=FALSE,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} +```{r,out.width="49%", out.height="20%",fig.show='hold',fig.align='center'} method <- "liger" files <- list.files( path = tmp_images, diff --git a/bin/batch_correction_liger.Rmd b/bin/batch_correction_liger.Rmd index 7df5d5d..efb1ff8 100755 --- a/bin/batch_correction_liger.Rmd +++ b/bin/batch_correction_liger.Rmd @@ -1,8 +1,12 @@ --- title: 'Batch Correction: LIGER' -author: "Samantha Sevilla" +author: "CCR Collaborative Bioinformatics Resource" date: "`r Sys.Date()`" -output: html_document +output: + html_document: + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -17,9 +21,14 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` - -```{r, prep_args, message=FALSE} +```{r, prep_args} # set up params species <- params$species gid <- params$gid @@ -38,7 +47,7 @@ testing <- params$testing scRNA_functions <- params$scRNA_functions ``` -```{r, handle_pkg, message=FALSE} +```{r, handle_pkg} # source functions source(scRNA_functions) @@ -62,7 +71,7 @@ scRNA_handle_packages(pkg_df) options(future.globals.maxSize = 96000 * 1024^2) ``` -```{r, processing, message=FALSE} +```{r, processing} # read in merged object so <- readRDS(mergedObj) @@ -78,7 +87,7 @@ so_corrected <- MAIN_BATCH_CORRECTION(so, npcs, species, resolution, ) ``` -```{r saveoutputs, message=FALSE, include=FALSE, echo=FALSE} +```{r saveoutputs include=FALSE} fpath <- paste0(gid, "_batch_correction_liger.rds") saveRDS(so_corrected, fpath) ``` diff --git a/bin/batch_correction_rpca.Rmd b/bin/batch_correction_rpca.Rmd index 7d15127..89b9503 100755 --- a/bin/batch_correction_rpca.Rmd +++ b/bin/batch_correction_rpca.Rmd @@ -1,8 +1,12 @@ --- title: "Batch Correction: rpca" -author: "Samantha Sevilla" +author: "CCR Collaborative Bioinformatics Resource" date: "`r Sys.Date()`" -output: html_document +output: + html_document: + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -17,8 +21,13 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- - -```{r, prep_args, message=FALSE, echo=FALSE, include=FALSE} +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` +```{r, prep_args, include=FALSE} # set up params species <- params$species gid <- params$gid @@ -36,7 +45,7 @@ Rpkg_config <- params$Rpkg_config scRNA_functions <- params$scRNA_functions ``` -```{r, handle_pkg, message=FALSE} +```{r, handle_pkg} # source functions source(scRNA_functions) @@ -60,7 +69,7 @@ scRNA_handle_packages(pkg_df) options(future.globals.maxSize = 96000 * 1024^2) ``` -```{r, processing, message=FALSE} +```{r, processing} # read in merged object so <- readRDS(mergedObj) @@ -76,7 +85,7 @@ so_corrected <- MAIN_BATCH_CORRECTION(so, npcs, species, resolution, ) ``` -```{r saveoutputs, message=FALSE, include=FALSE, echo=FALSE} +```{r saveoutputs include=FALSE} fpath <- paste0(gid, "_batch_correction_rpca.rds") saveRDS(so_corrected, fpath) ``` diff --git a/bin/batch_correction_scvi.Rmd b/bin/batch_correction_scvi.Rmd index d1e4a31..0f4c727 100755 --- a/bin/batch_correction_scvi.Rmd +++ b/bin/batch_correction_scvi.Rmd @@ -1,8 +1,12 @@ --- title: "Batch Correction: scvi" -author: "Samantha Sevilla" +author: "CCR Collaborative Bioinformatics Resource" date: "`r Sys.Date()`" -output: html_document +output: + html_document: + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -19,8 +23,13 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- - -```{r, prep_args, message=FALSE, echo=FALSE, include=FALSE} +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` +```{r, prep_args, include=FALSE} # set up params species <- params$species gid <- params$gid @@ -40,7 +49,7 @@ Rpkg_config <- params$Rpkg_config scRNA_functions <- params$scRNA_functions ``` -```{r, handle_pkg, message=FALSE, echo=FALSE, include=FALSE} +```{r, handle_pkg include=FALSE} # source functions source(scRNA_functions) @@ -66,7 +75,7 @@ reticulate::use_python(python_path) options(future.globals.maxSize = 96000 * 1024^2) ``` -```{r, processing, message=FALSE, echo=FALSE, include=FALSE} +```{r, processing, include=FALSE} # read in merged object so <- readRDS(mergedObj) @@ -84,7 +93,7 @@ so_corrected <- MAIN_BATCH_CORRECTION(so, npcs, species, resolution, so_corrected ``` -```{r saveoutputs, message=FALSE, include=FALSE, echo=FALSE} +```{r saveoutputs include=FALSE} fpath <- paste0(gid, "_batch_correction_scvi.rds") saveRDS(so_corrected, fpath) ``` diff --git a/bin/seurat_merge.Rmd b/bin/seurat_merge.Rmd index 49e5212..fe06ddb 100755 --- a/bin/seurat_merge.Rmd +++ b/bin/seurat_merge.Rmd @@ -1,8 +1,12 @@ --- title: "merge Notebook" +author: "CCR Collaborative Bioinformatics Resource" +date: "`r Sys.Date()`" output: html_document: - toc: yes + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -17,8 +21,13 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "Y" --- - -```{r, prep_args, message=FALSE, include=FALSE} +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` +```{r, prep_args, include=FALSE} # set up params species <- params$species vars_to_regress <- params$vars_to_regress @@ -43,7 +52,7 @@ print(paste0("vars_to_regress_list:", vars_to_regress_list)) print(paste0("gid:", gid)) ``` -```{r, handle_pkg, message=FALSE, include=FALSE} +```{r, handle_pkg include=FALSE} # set library dir, load this and remove any other dirs to avoid confusion # between personally created pkgs and the pipeline package ## saving old path "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library" @@ -88,7 +97,7 @@ source(scRNA_functions) options(future.globals.maxSize = 1e12) ``` -```{r, processing, message=FALSE} +```{r, processing} # print group info print(paste0("This merged object includes groups: ", gid)) @@ -117,7 +126,7 @@ for (p in readObj) { # TODO use map instead of a for loop } ``` -```{r merge_objs, message=FALSE} +```{r merge_objs} # create ref list reference.list <- combinedObj.list[unlist(readObj)] @@ -132,7 +141,7 @@ combinedObj.integratedRNA <- merge(reference.list[[1]], reference.list[2:length( VariableFeatures(combinedObj.integratedRNA) <- selectFeatures ``` -```{r mergedObjDims, message=FALSE, echo=FALSE} +```{r mergedObjDims } # vars.to.regress is NULL by default so_merged <- SCTransform(combinedObj.integratedRNA, vars.to.regress = vars_to_regress_list, assay = "RNA") diff --git a/bin/seurat_preprocess.Rmd b/bin/seurat_preprocess.Rmd index 76fdd91..4feac39 100755 --- a/bin/seurat_preprocess.Rmd +++ b/bin/seurat_preprocess.Rmd @@ -1,8 +1,12 @@ --- title: "scRNA Notebook" +author: "CCR Collaborative Bioinformatics Resource" +date: "`r Sys.Date()`" output: html_document: - toc: yes + toc: true + code_folding: hide + downlit_highlight: true editor_options: chunk_output_type: console params: @@ -23,8 +27,14 @@ params: scRNA_functions: "/data/CCBR_Pipeliner/Pipelines/SINCLAIR/dev/bin/scRNA_functions.R" testing: "N" --- +```{r, setup, include=FALSE} +knitr::opts_chunk$set( + message = FALSE, + echo = TRUE +) +``` -```{r, prep_args, message=FALSE} +```{r, prep_args} # set up params species <- params$species sampleid <- params$sampleid @@ -47,7 +57,7 @@ scRNA_functions <- params$scRNA_functions testing <- params$testing ``` -```{r, handle_pkg, message=FALSE} +```{r, handle_pkg} # set library dir, load this and remove any other dirs to avoid confusion # between personally created pkgs and the pipeline package ## saving old path "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library" @@ -91,7 +101,7 @@ source(scRNA_functions) # tinytex::install_tinytex(force = TRUE) ``` -```{r, pre-processing, message=FALSE} +```{r, pre-processing} # read in h5 file rnaCounts <- Read10X_h5(h5) @@ -116,7 +126,7 @@ FeatureScatter(so, feature1 = "nFeature_RNA", feature2 = "percent.mt") VlnPlot(so, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3) ``` -```{r, QC, message=FALSE} +```{r, QC} # subset so_filt <- subset(so, subset = nFeature_RNA > 200) so_filt @@ -132,7 +142,7 @@ so_qc <- RunMiQC(so_filt, # ggplot2::scale_color_gradient(low = "grey", high = "purple") ``` -```{r qc2, message=FALSE} +```{r qc2} # define feature info nCount_out <- outliers_mad(so_qc$nCount_RNA, threshold = 3)$LL_CI_MAD nFeature_out <- outliers_mad(so_qc$nFeature_RNA, threshold = 3)$LL_CI_MAD @@ -169,7 +179,7 @@ so_labeled <- MAIN_SINGLER(so_processed, species) so_doublet <- MAIN_DOUBLETS(so_labeled, run_doublet_finder) ``` -```{r, save, message=FALSE} +```{r, save} # clean final object so_output <- UpdateSeuratObject(so_doublet) so_output