Skip to content

Commit

Permalink
update with new readme info
Browse files Browse the repository at this point in the history
  • Loading branch information
lpantano committed Apr 24, 2024
1 parent 5772680 commit dc66375
Show file tree
Hide file tree
Showing 22 changed files with 172 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.Rhistory
.RData
.Ruserdata
*.Rproj
*.Rproj
test/*
1 change: 1 addition & 0 deletions R/bcbioR-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_PACKAGE"

## usethis namespace: start
#' @importFrom magrittr %>%
#' @importFrom stringr str_replace_all
## usethis namespace: end
#' @import ggplot2
Expand Down
13 changes: 0 additions & 13 deletions inst/rmarkdown/templates/rnaseq/skeleton/README.md

This file was deleted.

Empty file.
Empty file.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ params:
numerator: tumor
denominator: normal
subset_value: NA
params_file: ./inst/rmarkdown/templates/rnaseq/skeleton/params_de.R
params_file: params_de.R
---

```{r load_params, echo = F}
source(params$params_file)
source(params$project_file)
```

```{r load_libraries, cache = FALSE, message = FALSE, warning=FALSE, echo=FALSE,}
Expand Down Expand Up @@ -84,13 +85,13 @@ if (!is.na(params$subset_value)){
contrasts = c(column,params$numerator,params$denominator)
name_expression_fn=file.path(root,
name_expression_fn=file.path(
basedir,
str_interp("${filenames}_expression.csv"))
name_deg_fn=file.path(root,
name_deg_fn=file.path(
basedir,
str_interp("${filenames}_deg.csv"))
name_pathways_fn=file.path(root,
name_pathways_fn=file.path(
basedir,
str_interp("${filenames}_pathways.csv"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# info params
project = "name_hbcXXXXX"
PI = 'person name'
experiment = 'short description'
aim = 'short description'
analyst = 'person in the core'

# project params
root = "../.."
date = "YYYYMMDD"
column = "sample_type"
subset_column = NA
coldata_fn = "https://raw.githubusercontent.com/bcbio/bcbioR-test-data/main/rnaseq/bcbio/coldata.csv"
counts_fn = 'https://raw.githubusercontent.com/bcbio/bcbioR-test-data/main/rnaseq/bcbio/tximport-counts.csv'
se_object=url("https://raw.githubusercontent.com/bcbio/bcbioR-test-data/main/rnaseq/bcbio/bcbio-se.rds")
basedir <- 'results'
basedir <- './'
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ library(rmarkdown)
render_de <- function(numerator, denominator, subset_value = NA,
params_file = '../../params_de.R'){

rmarkdown::render(input = "./inst/rmarkdown/templates/rnaseq/skeleton/reports/DEG/DEG.Rmd",
output_dir = "./inst/rmarkdown/templates/rnaseq/skeleton/reports/DEG/",
rmarkdown::render(input = "DEG.Rmd",
output_dir = "./",
output_format = "html_document",
output_file = ifelse(!is.na(subset_value),
paste0('DE_', subset_value, '_', numerator, '_vs_', denominator, '.html'),
Expand All @@ -16,7 +16,8 @@ render_de <- function(numerator, denominator, subset_value = NA,
subset_value = subset_value,
numerator = numerator,
denominator = denominator,
params_file = params_file
params_file = params_file,
project_file = '../information.R'
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ output:
editor_options:
chunk_output_type: console
params:
params_file: ./inst/rmarkdown/templates/rnaseq/skeleton/params_qc.R
params_file: params_qc.R
project_file: ../information.R
---


```{r source_params, echo = F}
source(params$params_file)
source(params$project_file)
```

```{r load_libraries, cache = FALSE, message = FALSE, warning=FALSE}
Expand Down Expand Up @@ -405,4 +407,4 @@ List and version of tools used for the QC report generation.

```{r}
sessionInfo()
```
```
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# info params
project = "name_hbcXXXXX"
PI = 'person name'
experiment = 'short description'
aim = 'short description'
analyst = 'person in the core'


metadata_fn='https://raw.githubusercontent.com/bcbio/bcbioR-test-data/main/rnaseq/bcbio/coldata.csv'
se_object=url("https://raw.githubusercontent.com/bcbio/bcbioR-test-data/main/rnaseq/bcbio/bcbio-se.rds")
10 changes: 10 additions & 0 deletions inst/rmarkdown/templates/rnaseqv2/skeleton/QC/run_markdown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
library(rmarkdown)

rmarkdown::render("QC.Rmd",
output_dir = "./",
clean = TRUE,
output_format = "html_document",
params = list(
params_file = 'params_qc.R',
project_file = '../information.R')
)
23 changes: 23 additions & 0 deletions inst/rmarkdown/templates/rnaseqv2/skeleton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Guideline for RNAseq downstream analysis

# DropBox

- In `reports/QC`
- [ ] copy `bcbio-se.rds` and `tximport-counts.csv`
- [ ] copy QC `Rmd/R/html/figures`
- In `reports/DE`
- [ ] Normalized counts for all genes x all samples (csv format)
- In `reports/DE`, for *each analysis*:
- **Note** For multiple comparisons/analysis, do a single report/template if possible in the parent folder using parameters whenever possible.
- Create a folder with the comparison names in the files. Numbering by comparison (`01.1_DE_comp1`, `01.2_DE_comp2`, etc.). If you’re running multiple models for the same comparison, append `_M#`. Add the following files under each folder:
- [ ] Normalized count table with the samples used in this analysis/comparison.
- [ ] Full results `DESeq2` for all genes (csv format) with annotation columns appended.
- [ ] Significant genes results file (subset of annotated full results by chosen p-value and LFC). Separate files will be created for each individual contrast.
- [ ] Significant genes results file as described above, but additionally append columns containing normalized count values for each sample.
- Make sure to append the gene symbols to these tables so the researcher can interpret the results.

# GitHub

- [ ] Push all `*Rmd` `*R` files used for the *QC* and *DE* analysis respecting folder structure.

Please, ignore `*html/figures/csv` and any output of the code.
6 changes: 6 additions & 0 deletions inst/rmarkdown/templates/rnaseqv2/skeleton/information.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# info params
project = "name_hbcXXXXX"
PI = 'person name'
experiment = 'short description'
aim = 'short description'
analyst = 'person in the core'
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ output:
editor_options:
chunk_output_type: console
params:
params_file: params_de.R
params_file: information.R
---

```{r echo = F}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: bcbio RNAseq
description: Standard RNAseq down-stream analyses
create_dir: true
create_dir: false
61 changes: 61 additions & 0 deletions inst/rmarkdown/templates/singlecell/skeleton/Integration/helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# some code showing integrating two seurat objects
library(Seurat)
library(tidyverse)
library(harmony)

# We assume exp1 and exp2 has a Group column with naming the sample groups
# We create a batch annotation for each batch
exp1=readRDS("data/exp1.rds")
exp1$batch="n10"
exp2=readRDS("data/exp2.rds")
exp2$batch="n6"

# Normalize ----
exp = SCTransform(exp, verbose = FALSE,conserve.memory=TRUE,
variable.features.n = 3000)
exp <- RunPCA(exp)
ElbowPlot(exp,ndims=40)
end_dimension=35
resolution=0.5

# Clustering for each batch ----
exp <- FindNeighbors(exp, dims = 1:end_dimension, reduction = "pca")
exp <- FindClusters(exp, resolution = resolution, cluster.name = "unintegrated_clusters")
exp <- RunUMAP(exp, dims = 1:end_dimension, reduction = "pca", reduction.name = "umap.unintegrated")
saveRDS(exp, file="data/merged_umap.rds")

## Plot by batch----
DimPlot(exp, reduction = "umap.unintegrated", split.by = c("Group"),
group.by = c("batch"))

# Integration ----
exp <- IntegrateLayers(
object = exp, method = HarmonyIntegration,
orig.reduction = "pca", new.reduction = "harmony",
verbose = FALSE
)
exp[["RNA"]] <- JoinLayers(exp[["RNA"]])
end_dimension=35
resolution=0.5
exp <- FindNeighbors(exp, reduction = "harmony", dims = 1:end_dimension)
exp <- FindClusters(exp, resolution = resolution, cluster.name = "harmony_clusters")
exp <- RunUMAP(exp, reduction = "harmony", dims = 1:end_dimension, reduction.name = "umap.harmony")
saveRDS(exp, file="data/integrated_harmony.rds")

## Plot by Group and Cluster ----
DimPlot(
exp,
reduction = "umap.harmony",
split.by = c("Group"),
group.by = c("batch"),
combine = TRUE, label.size = 2
)

DimPlot(
exp,
reduction = "umap.harmony",
split.by = c("Group"),
group.by = c("ident"),
combine = TRUE, label.size = 2
)

17 changes: 17 additions & 0 deletions inst/rmarkdown/templates/singlecell/skeleton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Tipical steps for scRNAseq downstream analysis

# DropBox

- In `reports/QC`
- [ ] copy QC `Rmd/R/html/figures`
- In `reports/Clusters`
- [ ] the analysis of `SCTransform`, ,`RunPCA` ,`FindNeighbors`, ,`FindClusters`, `RunUMAP`
- [ ] the analysis of `FindMarkers` and `Cell Identification`
- In `reports/DE`, for *each analysis*:
- TBD

# GitHub

- [ ] Push all `*Rmd` `*R` files used for the *QC* and *DE* analysis respecting folder structure.

Please, ignore `*html/figures/csv` and any output of the code.
8 changes: 8 additions & 0 deletions inst/rmarkdown/templates/singlecell/skeleton/information.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# project params
root = "../"
date = "YYYYMMDD"
column = "treatment"
subset_column = 'cell'
metadata_fn = "../meta/samplesheet.csv"
counts_fn = '../data/tximport-counts.csv'
basedir <- 'reports'
25 changes: 25 additions & 0 deletions inst/rmarkdown/templates/singlecell/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: "General Project Information"
author: "Harvard Chan Bioinformatics Core"
date: "`r Sys.Date()`"
output:
html_document:
code_folding: hide
df_print: paged
highlights: pygments
number_sections: true
self_contained: true
theme: default
toc: true
toc_float:
collapsed: true
smooth_scroll: true
editor_options:
chunk_output_type: console
params:
params_file: information.R
---

```{r echo = F}
source(params$params_file)
```
3 changes: 3 additions & 0 deletions inst/rmarkdown/templates/singlecell/template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: bcbio scRNAseq
description: Standard scRNAseq down-stream analyses
create_dir: false

0 comments on commit dc66375

Please sign in to comment.