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 3 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
19 changes: 11 additions & 8 deletions modules/qc-report.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ 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)
)
allyhawkins marked this conversation as resolved.
Show resolved Hide resolved
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 +71,10 @@ 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)
)
allyhawkins marked this conversation as resolved.
Show resolved Hide resolved
celltype_report = "${meta.library_id}_celltype-report.html" // rendered HTML

"""
Expand All @@ -80,7 +83,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
10 changes: 9 additions & 1 deletion templates/qc_report/celltypes_qc.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ knitr::asis_output(
)
```

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}
knitr::asis_output(
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`).
")
)
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we are wrapping here and above rather than using the chunk options? I think knitr::asis_output() is useful if we have a mix of outputs, but kind of distracting if the entire chunk is asis

Suggested change
```{r, eval = has_singler | has_cellassign}
knitr::asis_output(
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`).
")
)
```
````{r, eval = has_singler | has_cellassign, result = '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`).
")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, the only reason I did it this way was to mirror how the other sections were. But we can change to using result='asis' throughout instead of knitr::asis_output?



## 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