From 2518f0e66515813ac1bd280d83d5cdbce2654628 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 18 Oct 2023 14:18:58 -0400 Subject: [PATCH 01/12] Update delta median plot itself --- .../celltypes_supplemental_report.rmd | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 2c9b1e27..ed32b2ac 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -36,7 +36,7 @@ theme_set( ) ``` - + ```{r, child='utils/celltype_functions.rmd'} ``` @@ -84,7 +84,7 @@ The red overlayed boxes represent the median ± interquartile range (IQR), speci ``` -```{r, eval = has_singler, warning=FALSE, message=FALSE,fig.height = 6, fig.width = 8} +```{r, eval = has_singler, warning=FALSE, message=FALSE, fig.height = 8, fig.width = 6} # Prepare SingleR scores for plot # extract scores into matrix @@ -98,7 +98,10 @@ delta_median_df <- tibble::tibble( # if pruned.labels are NA ==> low confidence # so, negate for this variable: confident = !is.na(metadata(processed_sce)$singler_result$pruned.labels) -) +) |> + dplyr::mutate(confident = + ifelse(confident, "Confident", "Not confident") + ) # If ontologies were used for `full_labels`, we'll need to map back to cell type names # for the plot itself. @@ -130,49 +133,66 @@ if (any(delta_median_df$celltype == "Unknown cell type")) { # add column with ordered levels with wrapped labels for visualization delta_median_df$annotation_wrapped <- factor( delta_median_df$celltype, - levels = levels(delta_median_df$celltype), - labels = stringr::str_wrap(levels(delta_median_df$celltype), 30) + # rev() so large groups are at the TOP of the plot + levels = rev(levels(delta_median_df$celltype)), + labels = rev(stringr::str_wrap(levels(delta_median_df$celltype), 30)) ) # Subset the data to just confident points for median+/-IQR delta_median_confident_df <- delta_median_df |> - dplyr::filter(confident) + dplyr::filter(confident == "Confident") # Plot delta_median across celltypes colored by pruning ggplot(delta_median_df) + aes( - x = annotation_wrapped, - y = delta_median, - color = confident + x = delta_median, + y = annotation_wrapped, + shape = confident, + alpha = confident ) + ggforce::geom_sina( size = 0.75, alpha = 0.5, - # Keep red points mostly in line with black - position = position_dodge(width = 0.05) + color = "black", # will get applied to all confident points and non-confident outline + fill = "white", # will apply to non-confident fill only + position = position_dodge(width = 0.05) # Keep both types of points mostly in line ) + + # Handle points aesthetics: + # confident are closed black with alpha = 0.5 + # not confident are open black with alpha = 1 + scale_shape_manual(values = c(19, 21)) + + scale_alpha_manual(values = c(0.5, 1)) + labs( x = "Cell type annotation", y = "Delta median statistic", - color = "Confident cell type assignment" + shape = "Confidence in cell type assignment" ) + - scale_color_manual(values = c("blue", "black")) + - # add median/IQR - geom_boxplot( - data = delta_median_confident_df, # only use black points for median + # add median diamond for confident points only + stat_summary( + data = delta_median_confident_df, color = "red", - width = 0.2, - size = 0.3, - alpha = 0, - # remove whiskers, outliers - outlier.shape = 0, - coef = 0 + geom = "point", + fun = "median", + shape = 18, + size = 2, + alpha = 0.9 ) + + # add median/IQR + #geom_boxplot( + # data = delta_median_confident_df, # only use black points for median + # color = "red", + # width = 0.2, + # size = 0.3, + # alpha = 0, + # # remove whiskers, outliers + # outlier.shape = 0, + # coef = 0 + #) + guides( - color = guide_legend(override.aes = list(size = 1, alpha = 0.9)) + alpha = FALSE ) + theme( - axis.text.x = element_text(angle = 55, hjust = 1, size = rel(0.85)), + axis.text.y = element_text(size = rel(0.85)), legend.title = element_text(size = rel(0.75)), legend.text = element_text(size = rel(0.75)), legend.position = "bottom" From 0f63dcacb210204182dd58de92e9a741f5027f21 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Wed, 18 Oct 2023 14:39:06 -0400 Subject: [PATCH 02/12] update delta median text --- .../celltypes_supplemental_report.rmd | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index ed32b2ac..8d28cdc9 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -70,21 +70,26 @@ In this section, we assess the reliability of cell type annotations using diagno knitr::asis_output(" ### `SingleR` assessment -`SingleR` assigns cell type scores based on Spearman correlations across features in the reference dataset. -We evaluate the reliability of cell type annotations using the per-cell _delta median_ statistic, which is the difference between the score for the cell's assigned label and the median score of all labels for the given cell. -Higher _delta median_ values indicate more confidence in the cell type annotation, although there is no specific threshold for calling absolute high vs. low confidence. -For more information, refer to the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). +Here, we evaluate the quality of `SingleR` cell type annotations by comparing the scores for the assigned cell type to the median score of all other cell type labels. +- This quantity is the _delta median_ statistic. +- _Delta median_ is calculated for each cell by subtracting the median score of all other cell type labels from the score of the assigned cell type label. +- Higher _delta median_ values indicate more confidence in the cell type annotation. + - However, there is no universal threshold for calling absolute high vs. low confidence, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). -In the plot below, each point is the _delta median_ statistic of a given cell with the given cell type annotation. -Points (cells) are colored by `SingleR`'s internal confidence assessment: High-quality cell annotations are shown in black, and low-quality cell annotations are shown in blue. -All blue points correspond to cells labeled as `Unknown cell type` in the `SingleR` result table in the previous section. -The red overlayed boxes represent the median ± interquartile range (IQR), specifically for high-quality annotations. +You can interpret this plot as follows: + +- Each point represents the _delta median_ statistic of a given cell whose final `SingleR` annotation is shown on the y-axis. +- Points are colored by `SingleR`'s internal confidence assessment: + - High-confidence cell annotations are shown as closed points. + - Low-confidence cell annotations are shown as open points. + In other sections of this report, these cells are referred to as `Unknown cell types`. +- Red diamonds represent the median _delta median_ statistic among high-confidence points for the given annotation. ") ``` -```{r, eval = has_singler, warning=FALSE, message=FALSE, fig.height = 8, fig.width = 6} +```{r, eval = has_singler, warning=FALSE, message=FALSE, fig.height = 7, fig.width = 6.5} # Prepare SingleR scores for plot # extract scores into matrix From 6537f07ca39d3eb9f393baa879281824c71f19ba Mon Sep 17 00:00:00 2001 From: Stephanie Spielman Date: Wed, 18 Oct 2023 15:41:10 -0400 Subject: [PATCH 03/12] Update templates/qc_report/celltypes_supplemental_report.rmd Co-authored-by: Joshua Shapiro --- templates/qc_report/celltypes_supplemental_report.rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 8d28cdc9..7a415e6e 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -168,8 +168,8 @@ ggplot(delta_median_df) + scale_shape_manual(values = c(19, 21)) + scale_alpha_manual(values = c(0.5, 1)) + labs( - x = "Cell type annotation", - y = "Delta median statistic", + x = "Delta median statistic", + y = "Cell type annotation", shape = "Confidence in cell type assignment" ) + # add median diamond for confident points only From c40897635a68ade9a3b936eefea58d1ecfdd4abd Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 19 Oct 2023 11:15:51 -0400 Subject: [PATCH 04/12] respond to reviews --- .../celltypes_supplemental_report.rmd | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 7a415e6e..bb38feb1 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -84,12 +84,13 @@ You can interpret this plot as follows: - High-confidence cell annotations are shown as closed points. - Low-confidence cell annotations are shown as open points. In other sections of this report, these cells are referred to as `Unknown cell types`. + - For more information on `SingleR's` confident assessment, please refer to [this `SingleR` documentation](https://rdrr.io/bioc/SingleR/man/pruneScores.html). - Red diamonds represent the median _delta median_ statistic among high-confidence points for the given annotation. ") ``` -```{r, eval = has_singler, warning=FALSE, message=FALSE, fig.height = 7, fig.width = 6.5} +```{r, eval = has_singler, warning=FALSE, message=FALSE} # Prepare SingleR scores for plot # extract scores into matrix @@ -147,6 +148,11 @@ delta_median_df$annotation_wrapped <- factor( delta_median_confident_df <- delta_median_df |> dplyr::filter(confident == "Confident") +# Determine height for plot area based on number of cells +plot_height <- length(unique(delta_median_df$celltype))/2.5 +``` + +```{r, eval = has_singler, warning=FALSE, message=FALSE, fig.height = plot_height, fig.width = 6.5} # Plot delta_median across celltypes colored by pruning ggplot(delta_median_df) + aes( @@ -156,8 +162,8 @@ ggplot(delta_median_df) + alpha = confident ) + ggforce::geom_sina( - size = 0.75, - alpha = 0.5, + size = 0.8, + alpha = 0.55, color = "black", # will get applied to all confident points and non-confident outline fill = "white", # will apply to non-confident fill only position = position_dodge(width = 0.05) # Keep both types of points mostly in line @@ -179,27 +185,14 @@ ggplot(delta_median_df) + geom = "point", fun = "median", shape = 18, - size = 2, + size = 2.25, alpha = 0.9 ) + - # add median/IQR - #geom_boxplot( - # data = delta_median_confident_df, # only use black points for median - # color = "red", - # width = 0.2, - # size = 0.3, - # alpha = 0, - # # remove whiskers, outliers - # outlier.shape = 0, - # coef = 0 - #) + guides( - alpha = FALSE + alpha = FALSE, + shape = guide_legend(override.aes = list(size = 1.5, alpha = 0.7)) ) + theme( - axis.text.y = element_text(size = rel(0.85)), - legend.title = element_text(size = rel(0.75)), - legend.text = element_text(size = rel(0.75)), legend.position = "bottom" ) ``` From dc4d932714adde189ea72d6c5c90a463fe9e88a1 Mon Sep 17 00:00:00 2001 From: Stephanie Spielman Date: Thu, 19 Oct 2023 13:08:18 -0400 Subject: [PATCH 05/12] Apply suggestions from code review Co-authored-by: Ally Hawkins <54039191+allyhawkins@users.noreply.github.com> --- templates/qc_report/celltypes_supplemental_report.rmd | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index bb38feb1..c5dd3338 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -163,7 +163,6 @@ ggplot(delta_median_df) + ) + ggforce::geom_sina( size = 0.8, - alpha = 0.55, color = "black", # will get applied to all confident points and non-confident outline fill = "white", # will apply to non-confident fill only position = position_dodge(width = 0.05) # Keep both types of points mostly in line From d0d7093ccd0d6f492e7226478854a29a296951e1 Mon Sep 17 00:00:00 2001 From: Stephanie Spielman Date: Thu, 19 Oct 2023 13:09:45 -0400 Subject: [PATCH 06/12] Apply suggestions from code review Co-authored-by: Ally Hawkins <54039191+allyhawkins@users.noreply.github.com> --- templates/qc_report/celltypes_supplemental_report.rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index c5dd3338..847d172e 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -80,7 +80,7 @@ Here, we evaluate the quality of `SingleR` cell type annotations by comparing th You can interpret this plot as follows: - Each point represents the _delta median_ statistic of a given cell whose final `SingleR` annotation is shown on the y-axis. -- Points are colored by `SingleR`'s internal confidence assessment: +- The color of the points indicates how confident `SingleR` is in the cell type assignment: - High-confidence cell annotations are shown as closed points. - Low-confidence cell annotations are shown as open points. In other sections of this report, these cells are referred to as `Unknown cell types`. From 4079f55b4806c08e3a55dc27ad78bf5991f3f82c Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 19 Oct 2023 13:15:53 -0400 Subject: [PATCH 07/12] use quality, not confidence, terminology to match singler docs. tweak legend alpha. --- .../celltypes_supplemental_report.rmd | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 847d172e..bee630c8 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -74,18 +74,18 @@ Here, we evaluate the quality of `SingleR` cell type annotations by comparing th - This quantity is the _delta median_ statistic. - _Delta median_ is calculated for each cell by subtracting the median score of all other cell type labels from the score of the assigned cell type label. -- Higher _delta median_ values indicate more confidence in the cell type annotation. - - However, there is no universal threshold for calling absolute high vs. low confidence, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). +- Higher _delta median_ values indicate higher quality cell type annotations. + - However, there is no universal threshold for calling absolute high vs. low quality, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). You can interpret this plot as follows: - Each point represents the _delta median_ statistic of a given cell whose final `SingleR` annotation is shown on the y-axis. -- The color of the points indicates how confident `SingleR` is in the cell type assignment: - - High-confidence cell annotations are shown as closed points. - - Low-confidence cell annotations are shown as open points. +- The color of the points indicates how confident `SingleR` is in the cell type annotation: + - High-quality cell annotations are shown as closed points. + - Low-quality cell annotations are shown as open points. In other sections of this report, these cells are referred to as `Unknown cell types`. - - For more information on `SingleR's` confident assessment, please refer to [this `SingleR` documentation](https://rdrr.io/bioc/SingleR/man/pruneScores.html). -- Red diamonds represent the median _delta median_ statistic among high-confidence points for the given annotation. + - For more information on how `SingleR` calculates annotation quality, please refer to [this `SingleR` documentation](https://rdrr.io/bioc/SingleR/man/pruneScores.html). +- Red diamonds represent the median _delta median_ statistic among high-quality points for the given annotation. ") ``` @@ -106,7 +106,7 @@ delta_median_df <- tibble::tibble( confident = !is.na(metadata(processed_sce)$singler_result$pruned.labels) ) |> dplyr::mutate(confident = - ifelse(confident, "Confident", "Not confident") + ifelse(confident, "High-quality", "Low-quality") ) # If ontologies were used for `full_labels`, we'll need to map back to cell type names @@ -146,7 +146,7 @@ delta_median_df$annotation_wrapped <- factor( # Subset the data to just confident points for median+/-IQR delta_median_confident_df <- delta_median_df |> - dplyr::filter(confident == "Confident") + dplyr::filter(confident == "High-quality") # Determine height for plot area based on number of cells plot_height <- length(unique(delta_median_df$celltype))/2.5 @@ -175,7 +175,7 @@ ggplot(delta_median_df) + labs( x = "Delta median statistic", y = "Cell type annotation", - shape = "Confidence in cell type assignment" + shape = "Cell type annotation quality" ) + # add median diamond for confident points only stat_summary( @@ -189,7 +189,7 @@ ggplot(delta_median_df) + ) + guides( alpha = FALSE, - shape = guide_legend(override.aes = list(size = 1.5, alpha = 0.7)) + shape = guide_legend(override.aes = list(size = 1.5, alpha = 0.55)) ) + theme( legend.position = "bottom" From 3c0b65c349a5365f14bbf39f28ec3076082f0f74 Mon Sep 17 00:00:00 2001 From: Stephanie Spielman Date: Thu, 19 Oct 2023 13:49:10 -0400 Subject: [PATCH 08/12] Apply suggestions from code review Co-authored-by: Joshua Shapiro --- templates/qc_report/celltypes_supplemental_report.rmd | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index bee630c8..956bf37b 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -70,22 +70,21 @@ In this section, we assess the reliability of cell type annotations using diagno knitr::asis_output(" ### `SingleR` assessment -Here, we evaluate the quality of `SingleR` cell type annotations by comparing the scores for the assigned cell type to the median score of all other cell type labels. +To assess the quality of the `SingleR`-assigned cell types, we use the _delta median_ statistic. -- This quantity is the _delta median_ statistic. -- _Delta median_ is calculated for each cell by subtracting the median score of all other cell type labels from the score of the assigned cell type label. +- _Delta median_ is calculated for each cell as the difference between the score of the assigned cell type label and the median score of the other cell type labels in the model. - Higher _delta median_ values indicate higher quality cell type annotations. - However, there is no universal threshold for calling absolute high vs. low quality, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). You can interpret this plot as follows: -- Each point represents the _delta median_ statistic of a given cell whose final `SingleR` annotation is shown on the y-axis. +- Each point represents the _delta median_ statistic of a given cell whose assigned `SingleR` annotation is shown on the y-axis. - The color of the points indicates how confident `SingleR` is in the cell type annotation: - High-quality cell annotations are shown as closed points. - Low-quality cell annotations are shown as open points. In other sections of this report, these cells are referred to as `Unknown cell types`. - For more information on how `SingleR` calculates annotation quality, please refer to [this `SingleR` documentation](https://rdrr.io/bioc/SingleR/man/pruneScores.html). -- Red diamonds represent the median _delta median_ statistic among high-quality points for the given annotation. +- Red diamonds represent the median _delta median_ statistic among high-quality annotations for the given cell type label. ") ``` From fc03ace8853cc63c06552a36790955b81211d44d Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 19 Oct 2023 14:42:40 -0400 Subject: [PATCH 09/12] range 0-1 --- templates/qc_report/celltypes_supplemental_report.rmd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 956bf37b..8244a924 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -74,7 +74,8 @@ To assess the quality of the `SingleR`-assigned cell types, we use the _delta me - _Delta median_ is calculated for each cell as the difference between the score of the assigned cell type label and the median score of the other cell type labels in the model. - Higher _delta median_ values indicate higher quality cell type annotations. - - However, there is no universal threshold for calling absolute high vs. low quality, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). + - Values can range from 0-1. + - Note that there is no universal threshold for calling absolute high vs. low quality, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). You can interpret this plot as follows: From df363014315279dfa5a20f7b78f171c2714831ea Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 19 Oct 2023 14:44:44 -0400 Subject: [PATCH 10/12] some wording - scores are from singler, remove extra space, reference dataset not model. --- templates/qc_report/celltypes_supplemental_report.rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 8244a924..2a2351d8 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -72,7 +72,7 @@ knitr::asis_output(" To assess the quality of the `SingleR`-assigned cell types, we use the _delta median_ statistic. -- _Delta median_ is calculated for each cell as the difference between the score of the assigned cell type label and the median score of the other cell type labels in the model. +- _Delta median_ is calculated for each cell as the difference between the `SingleR` score of the assigned cell type label and the median score of the other cell type labels in the reference dataset. - Higher _delta median_ values indicate higher quality cell type annotations. - Values can range from 0-1. - Note that there is no universal threshold for calling absolute high vs. low quality, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). From 1bd11cd0668a784ba475a4acc47424908f6590d9 Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 19 Oct 2023 16:45:44 -0400 Subject: [PATCH 11/12] use my sentence but also make it active --- .../celltypes_supplemental_report.rmd | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 2a2351d8..1f9b0b96 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -74,15 +74,15 @@ To assess the quality of the `SingleR`-assigned cell types, we use the _delta me - _Delta median_ is calculated for each cell as the difference between the `SingleR` score of the assigned cell type label and the median score of the other cell type labels in the reference dataset. - Higher _delta median_ values indicate higher quality cell type annotations. - - Values can range from 0-1. + - Values can range from 0-1. - Note that there is no universal threshold for calling absolute high vs. low quality, as described in the [`SingleR` book section on 'Annotation diagnostics'](https://bioconductor.org/books/release/SingleRBook/annotation-diagnostics.html#annotation-diagnostics). You can interpret this plot as follows: - Each point represents the _delta median_ statistic of a given cell whose assigned `SingleR` annotation is shown on the y-axis. -- The color of the points indicates how confident `SingleR` is in the cell type annotation: +- The point color indicates `SingleR`'s quality assessment of the annotation:: - High-quality cell annotations are shown as closed points. - - Low-quality cell annotations are shown as open points. + - Low-quality cell annotations are shown as open points. In other sections of this report, these cells are referred to as `Unknown cell types`. - For more information on how `SingleR` calculates annotation quality, please refer to [this `SingleR` documentation](https://rdrr.io/bioc/SingleR/man/pruneScores.html). - Red diamonds represent the median _delta median_ statistic among high-quality annotations for the given cell type label. @@ -105,7 +105,7 @@ delta_median_df <- tibble::tibble( # so, negate for this variable: confident = !is.na(metadata(processed_sce)$singler_result$pruned.labels) ) |> - dplyr::mutate(confident = + dplyr::mutate(confident = ifelse(confident, "High-quality", "Low-quality") ) @@ -158,7 +158,7 @@ ggplot(delta_median_df) + aes( x = delta_median, y = annotation_wrapped, - shape = confident, + shape = confident, alpha = confident ) + ggforce::geom_sina( @@ -167,7 +167,7 @@ ggplot(delta_median_df) + fill = "white", # will apply to non-confident fill only position = position_dodge(width = 0.05) # Keep both types of points mostly in line ) + - # Handle points aesthetics: + # Handle points aesthetics: # confident are closed black with alpha = 0.5 # not confident are open black with alpha = 1 scale_shape_manual(values = c(19, 21)) + @@ -179,16 +179,16 @@ ggplot(delta_median_df) + ) + # add median diamond for confident points only stat_summary( - data = delta_median_confident_df, + data = delta_median_confident_df, color = "red", - geom = "point", - fun = "median", - shape = 18, - size = 2.25, + geom = "point", + fun = "median", + shape = 18, + size = 2.25, alpha = 0.9 ) + guides( - alpha = FALSE, + alpha = FALSE, shape = guide_legend(override.aes = list(size = 1.5, alpha = 0.55)) ) + theme( From 5e66ceca129d33c871d0ceaeb0795f49846174be Mon Sep 17 00:00:00 2001 From: Stephanie Spielman Date: Thu, 19 Oct 2023 16:46:44 -0400 Subject: [PATCH 12/12] Update templates/qc_report/celltypes_supplemental_report.rmd remove extra colon i introduced --- templates/qc_report/celltypes_supplemental_report.rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/qc_report/celltypes_supplemental_report.rmd b/templates/qc_report/celltypes_supplemental_report.rmd index 1f9b0b96..72a3932c 100644 --- a/templates/qc_report/celltypes_supplemental_report.rmd +++ b/templates/qc_report/celltypes_supplemental_report.rmd @@ -80,7 +80,7 @@ To assess the quality of the `SingleR`-assigned cell types, we use the _delta me You can interpret this plot as follows: - Each point represents the _delta median_ statistic of a given cell whose assigned `SingleR` annotation is shown on the y-axis. -- The point color indicates `SingleR`'s quality assessment of the annotation:: +- The point color indicates `SingleR`'s quality assessment of the annotation: - High-quality cell annotations are shown as closed points. - Low-quality cell annotations are shown as open points. In other sections of this report, these cells are referred to as `Unknown cell types`.