From 0e8667d35305d3cd79d5ee3150ea0afea3de98be Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Sun, 25 Feb 2024 16:40:28 +0100 Subject: [PATCH 1/6] edit of vignettes --- vignettes/articles/Repertoire_Summary.Rmd | 1 + vignettes/articles/Running_Escape.Rmd | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vignettes/articles/Repertoire_Summary.Rmd b/vignettes/articles/Repertoire_Summary.Rmd index 91d724c0..4b246883 100644 --- a/vignettes/articles/Repertoire_Summary.Rmd +++ b/vignettes/articles/Repertoire_Summary.Rmd @@ -69,6 +69,7 @@ positionalEntropy(combined.TCR, chain = "TRB", aa.length = 20) ``` + ## positionalProperty Like ```positionalEntropy()```, we can also examine a series of amino acid properties along the cdr3 sequences using ```positionalProperty()```. Important differences from the above function for ```positionalProperty()``` is dropping NA values as they would void the mean calculation. ```positionalProperty()``` also display a ribbon with the 95% confidence interval surrounding the mean value for the selected properties. diff --git a/vignettes/articles/Running_Escape.Rmd b/vignettes/articles/Running_Escape.Rmd index 368da6c4..32390e7d 100644 --- a/vignettes/articles/Running_Escape.Rmd +++ b/vignettes/articles/Running_Escape.Rmd @@ -297,7 +297,7 @@ Most of the visualizations in *escape* have a defined set of parameters. **scale** * **TRUE** - z-transform the enrichment values. -* **FALSE** - leave raw values (**DEFAULT**). +* **FALSE** - leave raw values (**default**). In addition, ```heatmapEnrichment()``` allows for the reclustering of rows and columns using Euclidean distance of the enrichment scores and the Ward2 methods for clustering using **cluster.rows** and **cluster.columns**. @@ -311,7 +311,7 @@ heatmapEnrichment(scRep_example, cluster.columns = TRUE) ``` -Each visualization has an additional argument called **palette that supplies the coloring scheme to be used - available color palettes can be viewed with ```hcl.pals()```. +Each visualization has an additional argument called **palette** that supplies the coloring scheme to be used - available color palettes can be viewed with ```hcl.pals()```. ```{r} hcl.pals() From 7bfb6bd8daa53b5bb427caf59ee632569c76fb55 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Thu, 29 Feb 2024 09:23:48 -0600 Subject: [PATCH 2/6] clonalOverlay() changes for flexibility #325 add cut.category for variable selection --- DESCRIPTION | 2 +- NEWS.md | 6 + R/clonalOverlay.R | 24 +- man/clonalOverlay.Rd | 14 +- .../startracdiversity-plot.new.svg | 344 +++++++++ .../clonaloverlay-clonalproportion-plot.svg | 654 ++++++++++++++++++ .../clonalOverlay/clonaloverlay-plot.svg | 12 +- ...clonalclonalrarefaction-h2-p3-plot.new.svg | 60 ++ .../clonalsizedistribution-plot.new.svg | 94 +++ tests/testthat/test-clonalOverlay.R | 14 +- vignettes/articles/SC_Visualizations.Rmd | 7 +- vignettes/vignette.Rmd | 9 +- 12 files changed, 1215 insertions(+), 25 deletions(-) create mode 100644 tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg create mode 100644 tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg create mode 100644 tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg create mode 100644 tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg diff --git a/DESCRIPTION b/DESCRIPTION index 019209ad..ad129539 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: scRepertoire Title: A toolkit for single-cell immune receptor profiling -Version: 2.0.0 +Version: 2.0.1 Authors@R: c( person(given = "Nick", family = "Borcherding", role = c("aut", "cre"), email = "ncborch@gmail.com"), person(given = "Qile", family = "Yang", role = c("aut"), email = "qile0317@gmail.com"), diff --git a/NEWS.md b/NEWS.md index 3f587a87..77c23cc4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# scRepertoire VERSION 2.0.1 (2024-02-29) + +## UNDERLYING CHANGES + +*```clonalOverlay()``` arguments now cutpoint and use cut.category to select either clonalPorportion or clonalFrequency + # scRepertoire VERSION 2.0.0 (2024-01-10) diff --git a/R/clonalOverlay.R b/R/clonalOverlay.R index e130e1ea..85043dfd 100644 --- a/R/clonalOverlay.R +++ b/R/clonalOverlay.R @@ -20,13 +20,15 @@ #' #Using clonalOverlay() #' clonalOverlay(scRep_example, #' reduction = "umap", -#' freq.cutpoint = 0.3, +#' cutpoint = 3, #' bins = 5) #' #' @param sc.data The single-cell object after \code{\link{combineExpression}}. -#' @param reduction The dimensional reduction to visualize -#' @param freq.cutpoint The overlay cut point to include, this corresponds to the -#' Frequency variable in the single-cell object +#' @param reduction The dimensional reduction to visualize. +#' @param cut.category Meta data variable of the single-cell object to use for +#' filtering. +#' @param cutpoint The overlay cut point to include, this corresponds to the +#' cut.category variable in the meta data of the single-cell object. #' @param bins The number of contours to the overlay #' @param facet.by meta data variable to facet the comparison #' @@ -40,20 +42,28 @@ clonalOverlay <- function(sc.data, reduction = NULL, - freq.cutpoint = 30, + cut.category = "clonalFrequency", + cutpoint = 30, bins = 25, facet.by = NULL) { .checkSingleObject(sc.data) #Forming the data frame to plot tmp <- data.frame(.grabMeta(sc.data), .get.coord(sc.data, reduction)) + + if(cut.category %!in% colnames(tmp)) { + stop("If filtering the data using a cutpoint, ensure the cut.category correspond to a variable in the meta data.") + } #Add facet variable if present if (!is.null(facet.by)) { facet.by <- tmp[,facet.by] tmp <- data.frame(facet.by, tmp) } - tmp$include <- ifelse(tmp[,"clonalFrequency"] >= freq.cutpoint, "Yes", NA) - tmp2 <- subset(tmp, include == "Yes") + #If using cut.category for filtering + if(!is.null(cut.category) & !is.null(cutpoint)) { + tmp$include <- ifelse(tmp[,cut.category] >= cutpoint, "Yes", NA) + tmp2 <- subset(tmp, include == "Yes") + } #Plotting plot <- ggplot(tmp2, mapping = aes(x = tmp2[,(ncol(tmp2)-2)], diff --git a/man/clonalOverlay.Rd b/man/clonalOverlay.Rd index 285e686e..6e0810dd 100644 --- a/man/clonalOverlay.Rd +++ b/man/clonalOverlay.Rd @@ -7,7 +7,8 @@ clonalOverlay( sc.data, reduction = NULL, - freq.cutpoint = 30, + cut.category = "clonalFrequency", + cutpoint = 30, bins = 25, facet.by = NULL ) @@ -15,10 +16,13 @@ clonalOverlay( \arguments{ \item{sc.data}{The single-cell object after \code{\link{combineExpression}}.} -\item{reduction}{The dimensional reduction to visualize} +\item{reduction}{The dimensional reduction to visualize.} -\item{freq.cutpoint}{The overlay cut point to include, this corresponds to the -Frequency variable in the single-cell object} +\item{cut.category}{Meta data variable of the single-cell object to use for +filtering.} + +\item{cutpoint}{The overlay cut point to include, this corresponds to the +cut.category variable in the meta data of the single-cell object.} \item{bins}{The number of contours to the overlay} @@ -48,7 +52,7 @@ scRep_example <- combineExpression(combined, #Using clonalOverlay() clonalOverlay(scRep_example, reduction = "umap", - freq.cutpoint = 0.3, + cutpoint = 3, bins = 5) } diff --git a/tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg b/tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg new file mode 100644 index 00000000..af181bdd --- /dev/null +++ b/tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +migr + + + + + + + + + + +tran + + + + + + + + + + +expa + + + + + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 + +0.0 +0.1 +0.2 +0.3 + + + + + +0.0 +0.1 +0.2 +0.3 + + + + + +0.0 +0.1 +0.2 +0.3 + + + + +Index Score +StartracDiversity_plot + + diff --git a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg new file mode 100644 index 00000000..e6b07521 --- /dev/null +++ b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg @@ -0,0 +1,654 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +P19 + + + + + + + + + + +P20 + + + + + + + + + + +P17 + + + + + + + + + + +P18 + + + + + + + +-4 +0 +4 +8 + + + + + +-4 +0 +4 +8 + +-5 +0 +5 + + + + +-5 +0 +5 + + + +Dimension 1 +Dimension 2 +clonalOverlay_clonalProportion_plot + + diff --git a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg index 853e7b3e..003cf42d 100644 --- a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg +++ b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg @@ -145,7 +145,7 @@ - + @@ -314,13 +314,13 @@ - + - + @@ -402,7 +402,7 @@ - + @@ -588,9 +588,9 @@ - + - + diff --git a/tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg b/tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg new file mode 100644 index 00000000..33091eda --- /dev/null +++ b/tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +500 +1000 +1500 + + + + + + + + + +0.0 +0.2 +0.4 +0.6 +Sample coverage +Species diversity +clonalclonalRarefaction_h2_p3_plot + + diff --git a/tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg b/tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg new file mode 100644 index 00000000..11e5d3c7 --- /dev/null +++ b/tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +P19B +P20B +P20L +P17L +P19L +P17B +P18B +P18L + + + + + + + + + + + + + + + + + + + +-0.1 +0.0 +0.1 +0.2 +0.3 +0.4 +0.5 +clonalSizeDistribution_plot + + diff --git a/tests/testthat/test-clonalOverlay.R b/tests/testthat/test-clonalOverlay.R index b341a7e4..fbff6c48 100644 --- a/tests/testthat/test-clonalOverlay.R +++ b/tests/testthat/test-clonalOverlay.R @@ -11,10 +11,22 @@ test_that("clonalOverlay works", { "clonalOverlay_plot", clonalOverlay(test_obj, reduction = "umap", - freq.cutpoint = 1, + cutpoint = 1, bins = 10, facet.by = "Patient") + guides(color = "none") ) + set.seed(42) + expect_doppelganger( + "clonalOverlay_clonalProportion_plot", + clonalOverlay(test_obj, + reduction = "umap", + cut.category = "clonalProportion", + cutpoint = 0.2, + bins = 10, + facet.by = "Patient") + + guides(color = "none") + ) + }) diff --git a/vignettes/articles/SC_Visualizations.Rmd b/vignettes/articles/SC_Visualizations.Rmd index 07fac896..23fa8983 100644 --- a/vignettes/articles/SC_Visualizations.Rmd +++ b/vignettes/articles/SC_Visualizations.Rmd @@ -69,10 +69,13 @@ Using the dimensional reduction graphs as a reference, we can also generate an o * The dimensional reduction for the visualization, **(default = "pca")** -**freq.cutpoint** +**cut.category** -* lowest clonal frequency or proportion to generate the contour plot +* Use of "clonalFrequency" or "clonalProportion" to filter the overlay + +**cutpoint** +* lowest clonal frequency or proportion to generate the contour plot **bins** diff --git a/vignettes/vignette.Rmd b/vignettes/vignette.Rmd index 92541694..6a437491 100644 --- a/vignettes/vignette.Rmd +++ b/vignettes/vignette.Rmd @@ -877,10 +877,13 @@ Using the dimensional reduction graphs as a reference, we can also generate an o * The dimensional reduction for the visualization, **(default = "pca")** -**freq.cutpoint** +**cut.category** -* lowest clonal frequency or proportion to generate the contour plot +* Use of "clonalFrequency" or "clonalProportion" to filter the overlay + +**cutpoint** +* lowest clonal frequency or proportion to generate the contour plot **bins** @@ -896,7 +899,7 @@ scRep_example$Patient <- substr(scRep_example$orig.ident, 1,3) clonalOverlay(scRep_example, reduction = "umap", - freq.cutpoint = 1, + cutpoint = 1, bins = 10, facet.by = "Patient") + guides(color = "none") From b1a1aa5e7f0f10fd7a87ae72c5e7584cfb9393e9 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Thu, 29 Feb 2024 09:57:48 -0600 Subject: [PATCH 3/6] Update NEWS.md --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 77c23cc4..a047eb60 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ ## UNDERLYING CHANGES -*```clonalOverlay()``` arguments now cutpoint and use cut.category to select either clonalPorportion or clonalFrequency +*```clonalOverlay()``` arguments now cutpoint and use cut.category to select either clonalProportion or clonalFrequency # scRepertoire VERSION 2.0.0 (2024-01-10) From 25a8137937f2096dacc9681f7190f1aa7a667225 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Wed, 27 Mar 2024 05:44:47 -0500 Subject: [PATCH 4/6] clonalOccupy NA fix --- NEWS.md | 3 ++- R/clonalOccupy.R | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index a047eb60..9f946495 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,9 @@ -# scRepertoire VERSION 2.0.1 (2024-02-29) +# scRepertoire VERSION 2.0.1 ## UNDERLYING CHANGES *```clonalOverlay()``` arguments now cutpoint and use cut.category to select either clonalProportion or clonalFrequency +* ```clonalOccupy()``` allow NA calls # scRepertoire VERSION 2.0.0 (2024-01-10) diff --git a/R/clonalOccupy.R b/R/clonalOccupy.R index 33171d8c..39786601 100644 --- a/R/clonalOccupy.R +++ b/R/clonalOccupy.R @@ -50,7 +50,7 @@ clonalOccupy <- function(sc.data, palette = "inferno") { .checkSingleObject(sc.data) meta <- .grabMeta(sc.data) - meta <- melt(table(meta[!is.na(meta[,"clonalFrequency"]), + meta <- melt(table(meta[(meta[,"clonalFrequency"]), c(x.axis, facet.by, "cloneSize")], useNA = "ifany")) #Check for NAs if (!na.include) { From ced1942215064462692144adab046a19ec4f5ec2 Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Tue, 2 Apr 2024 11:23:36 -0500 Subject: [PATCH 5/6] clonalOccupy NA include argument fix #337 --- DESCRIPTION | 2 +- NEWS.md | 8 +- R/clonalOccupy.R | 25 ++- .../clonaloccupy-default-plot.new.svg | 146 ++++++++++++++++++ .../clonaloccupy-proportion-plot.new.svg | 119 ++++++++++++++ .../clonalOccupy_exportTable.rds | Bin 396 -> 544 bytes vignettes/articles/SC_Visualizations.Rmd | 9 +- vignettes/vignette.Rmd | 6 +- 8 files changed, 296 insertions(+), 19 deletions(-) create mode 100644 tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg create mode 100644 tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg diff --git a/DESCRIPTION b/DESCRIPTION index ad129539..ec7d97d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: scRepertoire Title: A toolkit for single-cell immune receptor profiling -Version: 2.0.1 +Version: 2.0.2 Authors@R: c( person(given = "Nick", family = "Borcherding", role = c("aut", "cre"), email = "ncborch@gmail.com"), person(given = "Qile", family = "Yang", role = c("aut"), email = "qile0317@gmail.com"), diff --git a/NEWS.md b/NEWS.md index 9f946495..78d0f22f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,10 +1,14 @@ +# scRepertoire VERSION 2.0.2 + +## UNDERLYING CHANGES + +*```clonalOccupy()``` rewrite counting and NA handling + # scRepertoire VERSION 2.0.1 ## UNDERLYING CHANGES *```clonalOverlay()``` arguments now cutpoint and use cut.category to select either clonalProportion or clonalFrequency -* ```clonalOccupy()``` allow NA calls - # scRepertoire VERSION 2.0.0 (2024-01-10) diff --git a/R/clonalOccupy.R b/R/clonalOccupy.R index 39786601..13d93419 100644 --- a/R/clonalOccupy.R +++ b/R/clonalOccupy.R @@ -33,7 +33,7 @@ #' environment in addition to the visualization. #' @param palette Colors to use in visualization - input any #' \link[grDevices]{hcl.pals}. -#' @importFrom dplyr %>% group_by mutate +#' @importFrom dplyr %>% group_by mutate count #' @importFrom reshape2 melt #' @import ggplot2 #' @export @@ -50,20 +50,29 @@ clonalOccupy <- function(sc.data, palette = "inferno") { .checkSingleObject(sc.data) meta <- .grabMeta(sc.data) - meta <- melt(table(meta[(meta[,"clonalFrequency"]), - c(x.axis, facet.by, "cloneSize")], useNA = "ifany")) + + meta <- meta %>% + group_by(meta[,x.axis], meta[,facet.by], cloneSize) %>% + count() %>% + as.data.frame() + + colnames(meta)[1] <- x.axis + if(!is.null(facet.by)) { + colnames(meta)[2] <- facet.by + } + #Check for NAs if (!na.include) { meta <- na.omit(meta) } - meta <- meta[meta$value != 0,] + meta <- meta[meta$n != 0,] #Convert to proportion if(proportion) { meta <- meta %>% group_by(meta[,1]) %>% - mutate(total = sum(value), - prop = value/total) + mutate(total = sum(n), + prop = n/total) meta <- as.data.frame(meta) } if (exportTable) { @@ -77,7 +86,7 @@ clonalOccupy <- function(sc.data, lab <- "Proportion of Cells" } else { - plot <- ggplot(meta, aes(x = meta[,x.axis], y = value, fill = cloneSize)) + + plot <- ggplot(meta, aes(x = meta[,x.axis], y = n, fill = cloneSize)) + geom_bar(stat = "identity", color = "black", lwd = 0.25) lab <- "Single Cells" @@ -94,7 +103,7 @@ clonalOccupy <- function(sc.data, } if (label) { plot <- plot + - geom_text(aes(label = value), position = position_stack(vjust = 0.5)) + geom_text(aes(label = n), position = position_stack(vjust = 0.5)) } plot } \ No newline at end of file diff --git a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg new file mode 100644 index 00000000..c04c8b9c --- /dev/null +++ b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +34 +41 +18 +27 +1 +34 +5 +11 +18 +8 +23 +11 +26 +3 +1 +25 +1 +19 +5 +5 +3 +16 +4 +1 +12 +4 +6 +1 +2 + + + +0 +20 +40 +60 + + + + + + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +Single Cells + +cloneSize + + + + + + +Hyperexpanded (0.1 < X <= 1) +Large (0.01 < X <= 0.1) +Medium (0.001 < X <= 0.01) +clonalOccupy_default_plot + + diff --git a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg new file mode 100644 index 00000000..635b1f4a --- /dev/null +++ b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.00 +0.25 +0.50 +0.75 +1.00 + + + + + + + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +Proportion of Cells + +cloneSize + + + + + + +Hyperexpanded (0.1 < X <= 1) +Large (0.01 < X <= 0.1) +Medium (0.001 < X <= 0.01) +clonalOccupy_proportion_plot + + diff --git a/tests/testthat/testdata/seuratFunctions/clonalOccupy_exportTable.rds b/tests/testthat/testdata/seuratFunctions/clonalOccupy_exportTable.rds index 529524e69fccad611b07649ba8ba30c8e6374664..c0d7d65aa523e763a87064ed35c5626eabc81ff3 100644 GIT binary patch literal 544 zcmV+*0^j`~iwFP!000001Fe+bQ`0~Y$FI4x+5)zKfFNqbUqxvrf%3x{e06+KA4F$( zW6tKvWF}3RORC}@?VkYbHM^Iy)AGc_XYSkGP4-8&ciLc#aprP|@hV7G{qg-{=Ll@e zV+Z34a6SPlh=Xto*P@Elkb4&QfjZJa=74!X=Xn4$fmVU*jB~o<_*yJ~$v8vrB3df} ziCq$VBzh$FNgR+kBymLIJqjoAjS7s~HEPeOo>BWo9T;^uQGT@_i;Su_Jq<)ZPZg*u zYtl4bIx92uZE?;N`z&}-YULWMt6_DUpDr(?l7B8l63WnP``y4h_D;Ry4_>g1F>9ZN zI+xn#8z;n(d*h1?qtS5ew*&k#;$$e|*lP!}uehBeW3JeRGV=a|(+-#qGC`4#?OibM=0 zEd@toGm|4F^0R(C%5tePG}rqvw0aW#m9(;34n` z+tFk2uqU3zS?fw**MB4&(-@@sW?GDN_ z?`Fljr+#}k9Y%TSFXyGw-(C6w_BH3Q@+z~hE&HmXYibEsU`@l@0;D3o$VC}AsW#&_!=-I#`Dun^9p8_NFZbt*u}99 zECDh|0o2sGjLxB+2Tb%W11q@C8c+mE3*yb0M~lx^GN}JVTa2zoXX#NcInJhx`(^TOF%sb*`;;13lF{Dqfk?oJ0g)EZ6RtHwcH3o;EmhM|Vg$ zx9m1+I+rQK+_CXUg*+iSTRLO0^e`TQm;^R5l^HIleq2~mZlAirSitBj^#BxXrh=Dr z2$WO*s>~MH1}fOl5;j-CN1$Vqf-WqDgtWm#H9nm3+Q`K;>=(AAJ;Kk*k zA28wLvgvZDyF2(~aqyJ#kY#o>#rUli@A}s}FJn3D@~VMNEOiS@tzj8;jNb$H0Sh<) qj(}s}1ULoG02|9c2QFqwso$9<6g(QxR$oARvJpT0P6RTk0{{Rb7q*oE diff --git a/vignettes/articles/SC_Visualizations.Rmd b/vignettes/articles/SC_Visualizations.Rmd index 23fa8983..d9b8aea0 100644 --- a/vignettes/articles/SC_Visualizations.Rmd +++ b/vignettes/articles/SC_Visualizations.Rmd @@ -88,7 +88,7 @@ This visualization was authored by Dr. Francesco Mazziotta and inspired by Drs. ```{r tidy = FALSE} clonalOverlay(scRep_example, reduction = "umap", - freq.cutpoint = 1, + cutpoint = 1, bins = 10, facet.by = "Patient") + guides(color = "none") @@ -129,7 +129,6 @@ clonalNetwork(scRep_example, filter.clones = NULL, filter.identity = NULL, cloneCall = "aa") - ``` We can look at the clonal relationships relative to a single cluster using the **filter.identity** parameter. @@ -185,9 +184,9 @@ clonalOccupy(scRep_example, x.axis = "seurat_clusters") clonalOccupy(scRep_example, - x.axis = "ident", - proportion = TRUE, - label = FALSE) + x.axis = "ident", + proportion = TRUE, + label = FALSE) ``` ## alluvialClones diff --git a/vignettes/vignette.Rmd b/vignettes/vignette.Rmd index 6a437491..7924c76e 100644 --- a/vignettes/vignette.Rmd +++ b/vignettes/vignette.Rmd @@ -996,9 +996,9 @@ clonalOccupy(scRep_example, x.axis = "seurat_clusters") clonalOccupy(scRep_example, - x.axis = "ident", - proportion = TRUE, - label = FALSE) + x.axis = "ident", + proportion = TRUE, + label = FALSE) ``` ## alluvialClones From cb31601ff1e4e50890bb0659ed42c92914767b0a Mon Sep 17 00:00:00 2001 From: theHumanBorch Date: Tue, 2 Apr 2024 11:46:33 -0500 Subject: [PATCH 6/6] updating testthat --- R/clonalOccupy.R | 1 + .../startracdiversity-plot.new.svg | 344 ------------------ .../clonaloccupy-default-plot.new.svg | 146 -------- .../clonaloccupy-default-plot.svg | 156 ++++---- .../clonaloccupy-proportion-plot.new.svg | 119 ------ .../clonaloccupy-proportion-plot.svg | 98 +++-- .../clonaloverlay-clonalproportion-plot.svg | 16 +- .../clonalOverlay/clonaloverlay-plot.svg | 12 +- ...clonalclonalrarefaction-h2-p3-plot.new.svg | 60 --- .../clonalsizedistribution-plot.new.svg | 94 ----- 10 files changed, 166 insertions(+), 880 deletions(-) delete mode 100644 tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg delete mode 100644 tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg delete mode 100644 tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg delete mode 100644 tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg delete mode 100644 tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg diff --git a/R/clonalOccupy.R b/R/clonalOccupy.R index 13d93419..87000c0e 100644 --- a/R/clonalOccupy.R +++ b/R/clonalOccupy.R @@ -55,6 +55,7 @@ clonalOccupy <- function(sc.data, group_by(meta[,x.axis], meta[,facet.by], cloneSize) %>% count() %>% as.data.frame() + meta[,1] <- as.factor(meta[,1]) colnames(meta)[1] <- x.axis if(!is.null(facet.by)) { diff --git a/tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg b/tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg deleted file mode 100644 index af181bdd..00000000 --- a/tests/testthat/_snaps/StartractDiversity/startracdiversity-plot.new.svg +++ /dev/null @@ -1,344 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -migr - - - - - - - - - - -tran - - - - - - - - - - -expa - - - - - - - - - - - - - - - - - - - - -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 - -0.0 -0.1 -0.2 -0.3 - - - - - -0.0 -0.1 -0.2 -0.3 - - - - - -0.0 -0.1 -0.2 -0.3 - - - - -Index Score -StartracDiversity_plot - - diff --git a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg deleted file mode 100644 index c04c8b9c..00000000 --- a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.new.svg +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -34 -41 -18 -27 -1 -34 -5 -11 -18 -8 -23 -11 -26 -3 -1 -25 -1 -19 -5 -5 -3 -16 -4 -1 -12 -4 -6 -1 -2 - - - -0 -20 -40 -60 - - - - - - - - - - - - - - - - - - - - - -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -Single Cells - -cloneSize - - - - - - -Hyperexpanded (0.1 < X <= 1) -Large (0.01 < X <= 0.1) -Medium (0.001 < X <= 0.01) -clonalOccupy_default_plot - - diff --git a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.svg b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.svg index 3cb0c794..c04c8b9c 100644 --- a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.svg +++ b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-default-plot.svg @@ -27,64 +27,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -1 -11 -1 -3 -34 -18 -34 -18 -23 -26 -25 -19 -5 -16 -4 -1 -12 -4 -6 -1 -41 -27 -5 -8 -11 -3 -1 -5 -2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +34 +41 +18 +27 +1 +34 +5 +11 +18 +8 +23 +11 +26 +3 +1 +25 +1 +19 +5 +5 +3 +16 +4 +1 +12 +4 +6 +1 +2 @@ -97,14 +97,38 @@ - - - - -0 -5 -10 -15 + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 Single Cells cloneSize diff --git a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg deleted file mode 100644 index 635b1f4a..00000000 --- a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.new.svg +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.00 -0.25 -0.50 -0.75 -1.00 - - - - - - - - - - - - - - - - - - - - - - -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -Proportion of Cells - -cloneSize - - - - - - -Hyperexpanded (0.1 < X <= 1) -Large (0.01 < X <= 0.1) -Medium (0.001 < X <= 0.01) -clonalOccupy_proportion_plot - - diff --git a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.svg b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.svg index e1ec1560..635b1f4a 100644 --- a/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.svg +++ b/tests/testthat/_snaps/clonalOccupy/clonaloccupy-proportion-plot.svg @@ -27,35 +27,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -70,14 +70,38 @@ - - - - -0 -5 -10 -15 + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 Proportion of Cells cloneSize diff --git a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg index e6b07521..ff6a0981 100644 --- a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg +++ b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-clonalproportion-plot.svg @@ -140,15 +140,15 @@ - - - - - + + + + - - - + + + + diff --git a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg index 003cf42d..853e7b3e 100644 --- a/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg +++ b/tests/testthat/_snaps/clonalOverlay/clonaloverlay-plot.svg @@ -145,7 +145,7 @@ - + @@ -314,13 +314,13 @@ - + - + @@ -402,7 +402,7 @@ - + @@ -588,9 +588,9 @@ - + - + diff --git a/tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg b/tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg deleted file mode 100644 index 33091eda..00000000 --- a/tests/testthat/_snaps/clonalRarefaction/clonalclonalrarefaction-h2-p3-plot.new.svg +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -500 -1000 -1500 - - - - - - - - - -0.0 -0.2 -0.4 -0.6 -Sample coverage -Species diversity -clonalclonalRarefaction_h2_p3_plot - - diff --git a/tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg b/tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg deleted file mode 100644 index 11e5d3c7..00000000 --- a/tests/testthat/_snaps/clonalSizeDistribution/clonalsizedistribution-plot.new.svg +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -P19B -P20B -P20L -P17L -P19L -P17B -P18B -P18L - - - - - - - - - - - - - - - - - - - --0.1 -0.0 -0.1 -0.2 -0.3 -0.4 -0.5 -clonalSizeDistribution_plot - -