Skip to content

Commit

Permalink
Merge pull request #52 from bcbio/devel
Browse files Browse the repository at this point in the history
downgrade to warning minor version
  • Loading branch information
lpantano authored Nov 14, 2024
2 parents 3a72be5 + 9181c65 commit d4a969e
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 36 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bcbioR
Type: Package
Title: Templates and functions to guide downstream analysis and data interpretation
Version: 0.3.0
Version: 0.3.1
Authors@R: person("Pantano", "Lorena", , "[email protected]",
role = c("aut", "cre"))
Description: Collaborative code repository at the Harvard Chan Bioinformatics Core.
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(cb_friendly_pal)
export(list_cb_friendly_cols)
export(scale_color_cb_friendly)
export(scale_fill_cb_friendly)
export(use_library)
import(R.utils)
import(fs)
import(usethis)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# bcbioR 0.3.1

- Fix bugs in RNAseq
- Add function to set up library

# bcbioR 0.3.0

* re-structure templates
Expand Down
23 changes: 23 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,29 @@ bcbio_render <- function(path, pipeline, data){
}
}


#' Set custom library to your project
#'
#' This function will create the .Rprofile file in a project path
#' to use a custom library path for future session
#' @param custom_lib_path path with a R library folder
#' @param project_path project path
#' @examples
#' path <- withr::local_tempdir()
#' use_library(.libPaths(), path)
#' @export
use_library <- function(custom_lib_path, project_path="."){
# Path to your project's .Rprofile file
project_path <- fs::path_abs(project_path)
ui_info("Using this project path: {project_path}")
rprofile_path <- file.path(project_path, ".Rprofile")
# Command to set the library path
lib_path_command <- sprintf('.libPaths("%s")\n', custom_lib_path)
# Write the command to .Rprofile
writeLines(lib_path_command, con = rprofile_path)
source(rprofile_path)
}

# help with bcbio analysis setup
use_bcbio_analysis <- function(path, pipeline, copy=TRUE, metadata=NULL){

Expand Down
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# bcbioR

<!-- badges: start -->

[![R-CMD-check](https://github.com/bcbio/bcbioR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bcbio/bcbioR/actions/workflows/R-CMD-check.yaml)

<!-- badges: end -->

The goal of `bcbioR` is to create guidelines for NGS data interpretation based on the experience of the Harvard Chan Bioinformatics Core and everybody who contributes to this package.

## Installation
Expand All @@ -24,13 +20,13 @@ devtools::install_github("bcbio/bcbioR",ref = "devel")

use `setwd()` to set your current directory to the place where you want to work. The bcbioR functions will automatically write to whatever directory you have set.

```
```
setwd("/path/to/analysis/folder")
```

The following code will pop up a Rmd template will populate that folder with HCBC data structure guidelines

```
```
path="/path/to/analysis/folder"
bcbio_templates(type="base", outpath=path)
bcbio_templates(type="rnaseq", outpath=path)
Expand All @@ -41,10 +37,27 @@ bcbio_templates(type="singlecell", outpath=path)

This code will populate the folder with HCBC data structure guidelines and Rmd code: **You do not need to create a reports folder prior to running this code. This will create and populate the reports folder.**

```
```
bcbio_templates(type="rnaseq", outpath="/path/to/analysis/folder/reports")
```

## Supported analyses

- base/reports/example.Rmd: ![](https://img.shields.io/badge/status-stable-green)
- rnaseq/DE/Intersections.Rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- rnaseq/DE/GSVA.Rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- rnaseq/DE/DEG.Rmd: ![](https://img.shields.io/badge/status-stable-green)
- rnaseq/DE/Cross-comparison-analysis.Rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- rnaseq/QC/QC_nf-core.Rmd: ![](https://img.shields.io/badge/status-stable-green)
- singlecell/Integration/norm_integration.rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- singlecell/QC/QC.rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- singlecell_delux/CellToCell/cellchat.Rmd: ![](https://img.shields.io/badge/status-draft-grey)
- chipseq/diffbind/diffbind.Rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- chipseq/QC/QC.Rmd: ![](https://img.shields.io/badge/status-alpha-yellow)
- spatial/cosmx/QC/QC.Rmd: ![](https://img.shields.io/badge/status-draft-grey)
- methylation/QC/QC.Rmd: ![](https://img.shields.io/badge/status-draft-grey)
- multiomics/teaseq/QC/QC.Rmd: ![](https://img.shields.io/badge/status-draft-grey)

### Discover more…

Go to the vignette to know more `vignette("bcbioR_quick_start", package="bcbioR")`
Expand Down
10 changes: 9 additions & 1 deletion inst/templates/base/reports/example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down Expand Up @@ -76,3 +76,11 @@ opts_chunk[["set"]](
- PI: `r PI`
- Analyst: `r analyst`
- Experiment: `r experiment`

# R session

List and version of tools used for the QC report generation.

```{r}
sessionInfo()
```
2 changes: 1 addition & 1 deletion inst/templates/chipseq/QC/QC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")>=0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down
2 changes: 1 addition & 1 deletion inst/templates/chipseq/diffbind/diffbind.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")>=0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down
2 changes: 1 addition & 1 deletion inst/templates/methylation/QC/QC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(BiocManager::version(), "3.18")>=0)
```

Expand Down
4 changes: 2 additions & 2 deletions inst/templates/rnaseq/DE/Cross-comparison-analysis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down Expand Up @@ -178,7 +178,7 @@ ggplot(lfc, aes(x=comp1, y=comp2, color=col)) + geom_point() +
```


## Compare ajusted P-values
## Compare adjusted P-values

We plot adjusted P-values for our contrasts and color points by whether or not they are significant in our contrasts. The black line is 1:1.

Expand Down
31 changes: 16 additions & 15 deletions inst/templates/rnaseq/DE/DEG.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ params:
# numerator: tumor
# denominator: normal
column: "sample_type"
contrasts: !r list(c("sample_type", "tumor", "normal"))
contrasts: !r list(c("sample_type", "tumor", "normal"),c("sample_type", "normal", "tumor"))
subset_column: null
subset_value: null
genome: hg38
ruv: true
ruv: false
combatseq: false
params_file: params_de-example.R
project_file: ../information.R
Expand All @@ -41,7 +41,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand All @@ -58,9 +58,10 @@ map(list.files(params$functions_file,pattern = "*.R$",full.names = T), source) %
# IMPORTANT set these values if you are not using the parameters in the header (lines 22-31)
genome=params$genome
column=params$column
# use contrast to set up multiple comparisons
# this is set up in the top as well, but you can change it here:
# example would be: list(c("sample_type", "tumor", "normal"))
contrasts=params$contrasts
# numerator=params$numerator
# denominator=params$denominator
subset_column=params$subset_column
subset_value=params$subset_value
run_ruv=params$ruv
Expand Down Expand Up @@ -197,7 +198,7 @@ pca <- degPCA(norm_matrix, metrics,
pca$plot + ggtitle(paste0("All samples", "\nPCA using ", nrow(vsd_before), " genes")) +
theme(plot.title=element_text(hjust=0.5)) +
geom_mark_ellipse(aes(color = sample_type)) + scale_color_cb_friendly()
geom_mark_ellipse(aes(color = .data[[column]])) + scale_color_cb_friendly()
```

## Analysis of the variance by group
Expand Down Expand Up @@ -417,6 +418,7 @@ de_list=lapply(contrasts, function(contrast){
## MA plot {.tabset}

This plot can help to:

- Identify Differential Expression: Genes that show a significant log-fold change (M value away from 0) indicate changes in expression between conditions.
- Assess Data Quality: The plot can help in identifying biases or systematic errors in the data. Ideally, most points should scatter around the M=0 line, indicating that there is no significant systematic difference between the conditions.
- Visualize data dispersion: The distribution of points along the A-axis gives a sense of the spread of expression levels and any patterns or anomalies in the dataset.
Expand Down Expand Up @@ -537,7 +539,6 @@ for (contrast in names(de_list)){
From the set of differentially expressed genes and using publicly available information about gene sets involved in biological processes and functions, we can calculate which biological processes and functions are significantly perturbed as a result of the treatment.

```{r}
all_in_life=get_databases()
all_in_life=get_databases_v2()
```

Expand Down Expand Up @@ -571,7 +572,7 @@ fa_gsea_list=lapply(de_list,function(contrast){
# multiple times
dt_list=list()
for (contrast in names(de_list)){
res_sig=fa_gsea_list[[contrast]]
res_sig=fa_gsea_list[[contrast]] %>% filter(padj < 0.05)
dt_list=c(dt_list,
list(h3(contrast)),
list(sanitize_datatable(res_sig)))
Expand Down Expand Up @@ -622,7 +623,7 @@ fa_list=lapply(de_list,function(contrast){
# multiple times
dt_list=list()
for (contrast in names(de_list)){
res_sig=fa_list[[contrast]][["all"]]
res_sig=fa_list[[contrast]][["all"]] %>% filter(padj < 0.05)
dt_list=c(dt_list,
list(h3(contrast)),
list(sanitize_datatable(res_sig)))
Expand All @@ -636,7 +637,7 @@ tagList(dt_list)
```{r, results='asis'}
dt_list=list()
for (contrast in names(de_list)){
res_sig=fa_list[[contrast]][["down"]]
res_sig=fa_list[[contrast]][["down"]] %>% filter(padj < 0.05)
dt_list=c(dt_list,
list(h3(contrast)),
list(sanitize_datatable(res_sig)))
Expand All @@ -650,7 +651,7 @@ tagList(dt_list)
```{r, results='asis'}
dt_list=list()
for (contrast in names(de_list)){
res_sig=fa_list[[contrast]][["up"]]
res_sig=fa_list[[contrast]][["up"]] %>% filter(padj < 0.05)
dt_list=c(dt_list,
list(h3(contrast)),
list(sanitize_datatable(res_sig)))
Expand All @@ -668,18 +669,18 @@ if (!is.null(subset_value) & !is.null(subset_value)){
filenames = "full"
}
for (contrast in names(contrasts)){
filenames = paste0(filenames, "_", contrast)
filename = paste0(filenames, "_", contrast)
name_expression_fn=file.path(
basedir,
str_interp("${filenames}_expression.csv"))
str_interp("${filename}_expression.csv"))
name_deg_fn=file.path(
basedir,
str_interp("${filenames}_deg.csv"))
str_interp("${filename}_deg.csv"))
name_pathways_fn=file.path(
basedir,
str_interp("${filenames}_pathways.csv"))
str_interp("${filename}_pathways.csv"))
counts_norm=norm_matrix %>% as.data.frame() %>%
rownames_to_column("gene_id") %>%
Expand Down
2 changes: 1 addition & 1 deletion inst/templates/rnaseq/DE/GSVA.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down
2 changes: 1 addition & 1 deletion inst/templates/rnaseq/DE/Intersections.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down
2 changes: 1 addition & 1 deletion inst/templates/rnaseq/QC/QC_nf-core.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
```

Expand Down
4 changes: 2 additions & 2 deletions inst/templates/singlecell/Integration/norm_integration.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
stopifnot(compareVersion(as.character(packageVersion("Seurat")), "5.0.0")>=0)
```
Expand Down Expand Up @@ -591,7 +591,7 @@ We take a look at how the clusters look at resolutions 0.1, 0.2,0.4, and 0.6
### 0.1

```{r umap_0.1}
cluster_res <- 0.2
cluster_res <- 0.1
Idents(object = seurat_clust) <- paste0(prefix_clu, cluster_res)
DimPlot(seurat_clust,
reduction = show_this,
Expand Down
2 changes: 1 addition & 1 deletion inst/templates/singlecell/QC/QC.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(as.character(BiocManager::version()), "3.18")>=0)
stopifnot(compareVersion(as.character(packageVersion("Seurat")), "5.0.0")>=0)
```
Expand Down
2 changes: 1 addition & 1 deletion inst/templates/spatial/cosmx/QC/QC.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ setwd(fs::path_dir(getSourceEditorContext()$path))
# NOTE: This code will check version, this is our recommendation, it may work
#. other versions
stopifnot(R.version$major>= 4) # requires R4
stopifnot(compareVersion(R.version$minor,"3.3")==0) # requires >=4.3.3
if (compareVersion(R.version$minor,"3.1")<0) warning("We recommend >= R4.3.1")
stopifnot(compareVersion(BiocManager::version(), "3.18")>=0)
stopifnot(compareVersion(package.version("Seurat"), "5.0.0")>=0)
```
Expand Down
21 changes: 21 additions & 0 deletions man/use_library.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d4a969e

Please sign in to comment.