Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add perform_celltyping parameter #506

Merged
merged 6 commits into from
Oct 16, 2023
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
12 changes: 8 additions & 4 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,16 @@ workflow {
// Cluster SCE
cluster_sce(post_process_sce.out)

// Perform celltyping, if specified
annotate_celltypes(cluster_sce.out)

if(params.perform_celltyping){
// Perform celltyping, if specified
annotated_celltype_ch = annotate_celltypes(cluster_sce.out)
} else {
annotated_celltype_ch = cluster_sce.out
}

// generate QC reports
sce_qc_report(
annotate_celltypes.out,
annotated_celltype_ch,
report_template_tuple
)

Expand Down
15 changes: 7 additions & 8 deletions modules/qc-report.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ process sce_qc_report{
metadata_json = "${meta.library_id}_metadata.json"
workflow_url = workflow.repository ?: workflow.manifest.homePage
workflow_version = workflow.revision ?: workflow.manifest.version

// names for final output files
unfiltered_out = "${meta.library_id}_unfiltered.rds"
filtered_out = "${meta.library_id}_filtered.rds"
processed_out = "${meta.library_id}_processed.rds"

// check for cell types
// TODO: add `params.perform_celltyping && (...)` when implemented
has_celltypes = (meta.submitter_cell_types_file || meta.singler_model_file || meta.cellassign_reference_file)
// only provide report template if cell typing was performed and either singler or cellassign was used
has_celltypes = params.perform_celltyping && (meta.singler_model_file || meta.cellassign_reference_file)
celltype_report = "${meta.library_id}_celltype-report.html" // rendered HTML
celltype_template_path = "${template_dir}/${celltype_template_file}" // template input

Expand Down Expand Up @@ -69,9 +69,8 @@ process sce_qc_report{
processed_out = "${meta.library_id}_processed.rds"
qc_report = "${meta.library_id}_qc.html"
metadata_json = "${meta.library_id}_metadata.json"

// TODO: add `params.perform_celltyping && (...)` when implemented
has_celltypes = meta.submitter_cell_types_file || meta.singler_model_file || meta.cellassign_reference_file

has_celltypes = params.perform_celltyping && (meta.singler_model_file || meta.cellassign_reference_file)
celltype_report = "${meta.library_id}_celltype-report.html" // rendered HTML

"""
Expand All @@ -80,7 +79,7 @@ process sce_qc_report{
touch ${processed_out}
touch ${qc_report}
${has_celltypes ? "touch ${celltype_report}" : ""}

echo '{"unfiltered_cells": 10, "filtered_cells": 10, "processed_cells": 10}' > ${metadata_json}
"""
}
3 changes: 2 additions & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ params {
skip_genetic_demux = false // skip genetic demultiplexing steps, even if bulk data is present
publish_fry_outs = false // alevin-fry outputs are not published by default. Use `--publish_fry_outs` to publish these files to the `checkpoints` folder.
spliced_only = false // include only spliced reads in counts matrix, by default both unspliced and spliced reads are totaled and found in `counts` asasy of returned SingleCellExperiment object
perform_celltyping = false // specify whether or not to incorporate cell type annotations

seed = 2021 // random number seed for filtering and post-processing (0 means use system seed)

Expand All @@ -54,7 +55,7 @@ params {

// Cell type annotation options
singler_label_name = "label.ont" // celldex reference label used for SingleR reference building

// Docker container images
includeConfig 'config/containers.config'

Expand Down
38 changes: 17 additions & 21 deletions templates/qc_report/celltypes_qc.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -120,58 +120,54 @@ plot_umap <- function(


<!-- Submitter _only_ -->
```{r, eval = has_submitter & !(has_singler | has_cellassign)}
knitr::asis_output(
glue::glue("
```{r, eval = has_submitter & !(has_singler | has_cellassign), results='asis'}
glue::glue("
This section details cell type annotations provided by the original lab (`submitter-provided`) which generated this data.
")
)
```


<!-- At least one cell type annotation method. -->
```{r, eval = has_singler | has_cellassign}
knitr::asis_output(
glue::glue("
```{r, eval = has_singler | has_cellassign, results='asis'}
glue::glue("
This section details results from performing cell type annotation.
The following method(s) were used to perform cell typing:
")
)
```


```{r, eval = has_singler}
knitr::asis_output(
glue::glue(
```{r, eval = has_singler, results='asis'}
glue::glue(
"* [`SingleR`](https://bioconductor.org/packages/release/bioc/html/SingleR.html), which uses a reference-based approach.
The `{metadata(processed_sce)$singler_reference}` reference dataset, obtained from the [`celldex` package](http://bioconductor.org/packages/release/data/experiment/html/celldex.html) package, was used for cell typing."
)
)
```


```{r, eval = has_cellassign}
knitr::asis_output(
glue::glue(
```{r, eval = has_cellassign, results='asis'}
glue::glue(
"* [`CellAssign`](https://github.com/Irrationone/cellassign), which uses a marker-gene based approach.
Marker genes associated with `{metadata(processed_sce)$cellassign_reference}` tissue were obtained from [PanglaoDB](https://panglaodb.se/).
"
)
)
```


<!-- Submitter and at least one inference method -->
```{r, eval = has_submitter & (has_singler | has_cellassign)}
knitr::asis_output(
glue::glue(
```{r, eval = has_submitter & (has_singler | has_cellassign), results='asis'}
glue::glue(
"* Cell type annotations were also provided by the original lab (`submitter-provided`) which generated this data.
"
)
)
```

For additional information about cell typing, including diagnostic plots and/or heatmap comparisons among annotations (if available), please refer to the [supplementary cell type QC report](`r params$celltype_report`).

<!-- At least one cell type annotation method required for the supplemental report -->
```{r, eval = has_singler | has_cellassign, results='asis'}
glue::glue("
For additional information about cell typing, including diagnostic plots and/or heatmap comparisons among annotations (if available), please refer to the [supplementary cell type QC report](`r params$celltype_report`).
")
```


## Statistics
Expand Down
2 changes: 1 addition & 1 deletion templates/qc_report/main_qc_report.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if (has_processed) {
}

# check for celltypes_report if celltypes are present
if (has_celltypes & is.null(params$celltype_report)) {
if ((has_singler | has_cellassign) & is.null(params$celltype_report)) {
stop("Cell type annotations were provided but the parameter specifying the cell type report file is missing.")
}
```
Expand Down