Browse code

Merge remote-tracking branch 'compbiomed/devel' into devel

Josh Campbell authored on 22/10/2024 01:39:56
Showing 29 changed files

... ...
@@ -17,3 +17,4 @@ exec/png
17 17
 ^\.github$
18 18
 ^vignettes/articles/*
19 19
 ^images
20
+.dockerignore
20 21
\ No newline at end of file
21 22
new file mode 100644
... ...
@@ -0,0 +1,7 @@
1
+.RData
2
+.Rhistory
3
+.git
4
+.gitignore
5
+manifest.json
6
+rsconnect/
7
+.Rproj.user
0 8
\ No newline at end of file
... ...
@@ -118,8 +118,9 @@ Imports:
118 118
     scuttle,
119 119
     utils,
120 120
     stats,
121
-    zellkonverter
122
-RoxygenNote: 7.3.1
121
+    zellkonverter,
122
+    tidyr
123
+RoxygenNote: 7.3.2
123 124
 Suggests:
124 125
     testthat,
125 126
     Rsubread,
... ...
@@ -131,6 +131,13 @@ computeHeatmap <- function(inSCE,
131 131
     features[[i]] <- .convertToHyphen(features[[i]])
132 132
   }
133 133
 
134
+  ## temp fix
135
+  # make sure the cell names are consistent
136
+  # UPDATE THIS IN .convertSCEToSeurat function eventually
137
+  rownames(object@[email protected]) <- 
138
+    unlist(.convertToHyphen(rownames(object@[email protected])))
139
+  ## 
140
+  
134 141
   object <- Seurat::ScaleData(object, features = features.all)
135 142
 
136 143
   # get assay data with only selected features (all dims) and
... ...
@@ -342,6 +342,7 @@
342 342
 #' @seealso \code{\link{runCellQC}}, \code{\link{plotDoubletFinderResults}}
343 343
 #' @examples
344 344
 #' data(scExample, package = "singleCellTK")
345
+#' options(future.globals.maxSize = 786432000)
345 346
 #' sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'")
346 347
 #' sce <- runDoubletFinder(sce)
347 348
 #' @export
... ...
@@ -26,7 +26,7 @@
26 26
 
27 27
 #' @title Identify empty droplets using \link[DropletUtils]{emptyDrops}.
28 28
 #' @description Run \link[DropletUtils]{emptyDrops} on the count matrix in the
29
-#' provided \\linkS4class{SingleCellExperiment} object.
29
+#' provided \linkS4class{SingleCellExperiment} object.
30 30
 #' Distinguish between droplets containing cells and ambient RNA in a
31 31
 #' droplet-based single-cell RNA sequencing experiment.
32 32
 #' @param inSCE A \linkS4class{SingleCellExperiment} object. Must contain a raw 
... ...
@@ -852,11 +852,19 @@ plotSCEScatter <- function(inSCE,
852 852
                       vcolor = "red",
853 853
                       vsize = 1,
854 854
                       vlinetype = 1) {
855
+  
856
+  mult_modules <- FALSE
857
+  
855 858
   if (is.null(groupBy)) {
856
-    groupBy <- rep("Sample", length(y))
859
+    if (length(colnames(y)) > 1){
860
+      mult_modules <- TRUE
861
+      groupBy <- rep(colnames(y), each = dim(y)[1])
862
+      y <- tidyr::pivot_longer(as.data.frame(y), cols = 1:dim(y)[2], cols_vary = "slowest")$value#
863
+    }else{
864
+      groupBy <- rep("Sample", length(y))
865
+    }
857 866
   }
858 867
   
859
-  
860 868
   if(!is.factor(groupBy)){
861 869
     if(is.null(plotOrder)){
862 870
       plotOrder = unique(groupBy)
... ...
@@ -920,6 +928,10 @@ plotSCEScatter <- function(inSCE,
920 928
                             axis.title.x = ggplot2::element_blank())
921 929
   }
922 930
   
931
+  if (mult_modules){
932
+    p <- p + xlab("Modules")
933
+  }
934
+  
923 935
   if (gridLine == TRUE){
924 936
     p <- p + ggplot2::theme(panel.grid.major.y = ggplot2::element_line("grey"))
925 937
   }
... ...
@@ -1417,9 +1429,9 @@ plotSCEViolinAssayData <- function(inSCE,
1417 1429
 #' @param feature Desired name of feature stored in assay of SingleCellExperiment
1418 1430
 #'  object. Only used when "assays" slotName is selected. Default NULL.
1419 1431
 #' @param sample Character vector. Indicates which sample each cell belongs to.
1420
-#' @param dimension Desired dimension stored in the specified reducedDims.
1421
-#'  Either an integer which indicates the column or a character vector specifies
1422
-#'  column name. By default, the 1st dimension/column will be used.
1432
+#' @param dimension Desired dimension(s) stored in the specified reducedDims.
1433
+#'  Either an integer which indicates the column(s) or a character vector specifies
1434
+#'  column name(s). By default, the 1st dimension/column will be used.
1423 1435
 #'  Only used when "reducedDims" slotName is selected. Default NULL.
1424 1436
 #' @param groupBy Groupings for each numeric value. A user may input a vector
1425 1437
 #' equal length to the number of the samples in the SingleCellExperiment
... ...
@@ -1568,7 +1580,11 @@ plotSCEViolin <- function(inSCE,
1568 1580
   samples <- unique(sample)
1569 1581
   plotlist <- lapply(samples, function(x) {
1570 1582
     sampleInd <- which(sample == x)
1571
-    countSub <- counts[sampleInd]
1583
+    if (length(colnames(counts)) > 1){
1584
+      countSub <- counts[sampleInd,]
1585
+    }else{
1586
+      countSub <- counts[sampleInd]
1587
+    }
1572 1588
     if(!is.null(groupBy)){
1573 1589
       groupbySub <- groupBy[sampleInd]
1574 1590
     }else{
... ...
@@ -191,18 +191,18 @@ discreteColorPalette <- function(n, palette = c("random", "ggplot", "celda"),
191 191
 #' Adds '-1', '-2', ... '-i' to multiple duplicated rownames, and in place
192 192
 #' replace the unique rownames, store unique rownames in \code{rowData}, or
193 193
 #' return the unique rownames as character vecetor.
194
-#' @param x A matrix like or /linkS4class{SingleCellExperiment} object, on which
194
+#' @param x A matrix like or \linkS4class{SingleCellExperiment} object, on which
195 195
 #' we can apply \code{rownames()} to and has duplicated rownames.
196 196
 #' @param as.rowData Only applicable when \code{x} is a
197
-#' /linkS4class{SingleCellExperiment} object. When set to \code{TRUE}, will
197
+#' \linkS4class{SingleCellExperiment} object. When set to \code{TRUE}, will
198 198
 #' insert a new column called \code{"rownames.uniq"} to \code{rowData(x)}, with
199 199
 #' the deduplicated rownames.
200 200
 #' @param return.list When set to \code{TRUE}, will return a character vector
201 201
 #' of the deduplicated rownames.
202 202
 #' @export
203
-#' @return By default, a matrix or /linkS4class{SingleCellExperiment} object
203
+#' @return By default, a matrix or \linkS4class{SingleCellExperiment} object
204 204
 #' with rownames deduplicated.
205
-#' When \code{x} is a /linkS4class{SingleCellExperiment} and \code{as.rowData}
205
+#' When \code{x} is a \linkS4class{SingleCellExperiment} and \code{as.rowData}
206 206
 #' is set to \code{TRUE}, will return \code{x} with \code{rowData} updated.
207 207
 #' When \code{return.list} is set to \code{TRUE}, will return a character vector
208 208
 #' with the deduplicated rownames.
... ...
@@ -12,7 +12,7 @@
12 12
 #' @param ylab The y-axis label
13 13
 #' @param colorLow The color to be used for lowest value of mean expression
14 14
 #' @param colorHigh The color to be used for highest value of mean expression
15
-#' @param scale Option to scale the data. Default: /code{FALSE}. Selected assay will not be scaled. 
15
+#' @param scale Option to scale the data. Default: \code{FALSE}. Selected assay will not be scaled. 
16 16
 #' @return A ggplot of the bubble plot.
17 17
 #' @importFrom rlang .data
18 18
 #' @importFrom reshape2 melt
... ...
@@ -670,7 +670,7 @@ integrated = integrated[:, orderIdx]
670 670
 #' variable genes identification. Default \code{"counts"}.
671 671
 #' @param kmeansK An integer vector. Indicating the kmeans' K-value for each
672 672
 #' batch (i.e. how many subclusters in each batch should exist), in order to
673
-#' construct pseudo-replicates. The length of code{kmeansK} needs to be the same
673
+#' construct pseudo-replicates. The length of \code{kmeansK} needs to be the same
674 674
 #' as the number of batches. Default \code{NULL}, and this value will be
675 675
 #' auto-detected by default, depending on \code{cellType}.
676 676
 #' @param cellType A single character. A string indicating a field in
... ...
@@ -7,7 +7,7 @@
7 7
 #' @param featureNames A string or vector of strings with each gene to aggregate.
8 8
 #' @param displayName A string that is the name of the column used for genes.
9 9
 #' @param groupNames The name of a colData entry that can be used as groupNames.
10
-#' @param scale Option to scale the data. Default: /code{FALSE}. Selected assay will not be scaled. 
10
+#' @param scale Option to scale the data. Default: \code{FALSE}. Selected assay will not be scaled. 
11 11
 #' @return A dataframe with mean expression and percent of cells in cluster that 
12 12
 #' express for each cluster.
13 13
 #' @examples
... ...
@@ -76,7 +76,7 @@ runDimReduce <- function(inSCE,
76 76
                        seed = seed, ...)
77 77
   } else if (method == "scaterUMAP") {
78 78
     inSCE <- runUMAP(inSCE = inSCE, useAssay = useAssay, useAltExp = useAltExp,
79
-                     useReducedDim = useReducedDim, initialDims = 25,
79
+                     useReducedDim = useReducedDim,
80 80
                      useFeatureSubset = useFeatureSubset, scale = scale,
81 81
                      reducedDimName = reducedDimName, seed = seed, ...)
82 82
   } else if (method == "scanpyPCA"){
... ...
@@ -30,6 +30,16 @@
30 30
     return(componentNames)
31 31
   }
32 32
 
33
+#' .getSeuratObject
34
+#' Retrieves the Seurat object stored in the input SCE, if exists
35
+#' @param inSCE (sce) object containing the Seurat data, located
36
+#' in inSCE\@\metadata$seurat$obj
37
+#' @return the Seurat object if it exists
38
+#' @noRd
39
+.getSeuratObject <- function(inSCE) { 
40
+  return(metadata(inSCE)$seurat$obj)
41
+}
42
+
33 43
 #' .addSeuratToMetaDataSCE
34 44
 #' Adds the input seurat object to the metadata slot of the input sce object
35 45
 #' (after removing the data matrices)
... ...
@@ -44,25 +54,38 @@
44 54
   seurat.version <- .getSeuratObjectMajorVersion(seuratObject)
45 55
   
46 56
   if(seurat.version >= 5.0){
47
-    inSCE@metadata$seurat$obj$RNA$"var.features" <-
48
-      Seurat::VariableFeatures(object = seuratObject)
49 57
     
50
-    # Determine if slot is called "meta.data" or "meta.features
51
-    if("meta.data" %in% methods::slotNames(inSCE@metadata$seurat$obj$RNA)) {
52
-        inSCE@metadata$seurat$obj$RNA$meta.features  <- seuratObject@[email protected]    
53
-    } else if ("meta.features" %in% methods::slotNames(inSCE@metadata$seurat$obj$RNA)) {
54
-        inSCE@metadata$seurat$obj$RNA$meta.features  <- seuratObject@[email protected]
55
-    }
58
+    seuratObject@assays$RNA@layers$counts <- methods::new("dgCMatrix")
59
+    seuratObject@assays$RNA@layers$data <- methods::new("dgCMatrix")
60
+    seuratObject@assays$RNA@layers$scale.data <- methods::new("dgCMatrix")
61
+    inSCE@metadata$seurat$obj <- seuratObject
62
+    
63
+    # add var features if exists
64
+    #if (!is.null(Seurat::VariableFeatures(seuratObject)) && length(Seurat::VariableFeatures(seuratObject)) > 0) {
65
+    #  inSCE@metadata$seurat$obj@assays$RNA$"var.features" <-
66
+    #    Seurat::VariableFeatures(object = seuratObject)
67
+    #}
56 68
     
57
-    inSCE@metadata$seurat$obj$meta.data <- [email protected]
69
+    #inSCE@metadata$seurat$obj@assays$RNA@layers$counts <- methods::new("dgCMatrix")
70
+    #inSCE@metadata$seurat$obj@assays$RNA@layers$data <- methods::new("dgCMatrix")
71
+    #inSCE@metadata$seurat$obj@assays$RNA@layers$scale.data <- matrix()
72
+    
73
+    # Determine if slot is called "meta.data" or "meta.features"
74
+      if("meta.data" %in% methods::slotNames(seuratObject@assays$RNA)) {
75
+         inSCE@metadata$seurat$obj@[email protected]  <- seuratObject@[email protected]    
76
+      } else if ("meta.features" %in% methods::slotNames(seuratObject@assays$RNA)) {
77
+         inSCE@metadata$seurat$obj@[email protected]  <- seuratObject@[email protected]
78
+      }
58 79
     
59
-    inSCE@metadata$seurat$obj$commands <- seuratObject@commands
80
+    inSCE@[email protected] <- [email protected]
60 81
     
61
-    inSCE@metadata$seurat$obj$reductions$pca <- seuratObject@reductions$pca
62
-    inSCE@metadata$seurat$obj$reductions$ica <- seuratObject@reductions$ica
63
-    inSCE@metadata$seurat$obj$reductions$tsne <- seuratObject@reductions$tsne
64
-    inSCE@metadata$seurat$obj$reductions$umap <- seuratObject@reductions$umap
82
+    inSCE@metadata$seurat$obj@commands <- seuratObject@commands
65 83
     
84
+    inSCE@metadata$seurat$obj@reductions$pca <- seuratObject@reductions$pca
85
+    inSCE@metadata$seurat$obj@reductions$ica <- seuratObject@reductions$ica
86
+    inSCE@metadata$seurat$obj@reductions$tsne <- seuratObject@reductions$tsne
87
+    inSCE@metadata$seurat$obj@reductions$umap <- seuratObject@reductions$umap
88
+
66 89
   }
67 90
   else{
68 91
     seuratObject@assays$RNA@counts <- methods::new("dgCMatrix")
... ...
@@ -541,6 +564,7 @@ runSeuratICA <-
541 564
            verbose = FALSE) {
542 565
     params <- as.list(environment())
543 566
     params$inSCE <- NULL
567
+    
544 568
     if (!isTRUE(scale)) {
545 569
       # If not doing a scaling, put useAssay as scaled as RunPCA need it
546 570
       seuratObject <-
... ...
@@ -618,7 +642,6 @@ runSeuratJackStraw <- function(inSCE,
618 642
                                externalReduction = NULL) {
619 643
   seuratObject <- convertSCEToSeurat(inSCE, normAssay = useAssay)
620 644
   seuratObject <- Seurat::ScaleData(seuratObject)
621
-
622 645
   if (!is.null(externalReduction)) {
623 646
     #convert (_) to (-) as required by Seurat
624 647
 
... ...
@@ -783,7 +806,7 @@ plotSeuratReduction <-
783 806
       if (!is.null([email protected]$seurat_clusters)) {
784 807
         Seurat::Idents(seuratObject) <-
785 808
           [email protected]$seurat_clusters
786
-        [email protected] <- data.frame()
809
+        #[email protected] <- data.frame()
787 810
       }
788 811
     }
789 812
 
... ...
@@ -1065,13 +1088,16 @@ runSeuratUMAP <- function(inSCE,
1065 1088
   seurat.version <- .getSeuratObjectMajorVersion(seuratObject)
1066 1089
   
1067 1090
   if(seurat.version >= 5.0){
1068
-    if (length(seuratObject@assays$RNA@misc$var.features) > 0) {
1069
-      return(seuratObject@assays$RNA@misc$var.features[seq(numberOfFeatures)])
1091
+    if (length(SeuratObject::Features(seuratObject)) > 0) {
1092
+      return(SeuratObject::Features(seuratObject)[seq(numberOfFeatures)])
1070 1093
     }
1094
+    #if (length(seuratObject@assays$RNA@misc$var.features) > 0) {
1095
+    #  return(seuratObject@assays$RNA@misc$var.features[seq(numberOfFeatures)])
1096
+    #}
1071 1097
   }
1072 1098
   else{
1073
-    if (length(seuratObject@[email protected]) > 0) {
1074
-      return(seuratObject@[email protected][seq(numberOfFeatures)])
1099
+    if (length(seuratObject@[email protected]$var.features) > 0) {
1100
+      return(seuratObject@[email protected]$var.features[seq(numberOfFeatures)])
1075 1101
     }
1076 1102
   }
1077 1103
 }
... ...
@@ -1551,46 +1577,57 @@ convertSCEToSeurat <-
1551 1577
     
1552 1578
     if(seurat.version >= 5.0){
1553 1579
       if (!is.null(inSCE@metadata$seurat$obj)) {
1554
-        if (length(inSCE@metadata$seurat$obj$RNA$"var.features") > 0) {
1555
-          seuratObject@assays$RNA@misc$"var.features" <- 
1556
-            inSCE@metadata$seurat$obj$RNA$"var.features"
1580
+        # what is it looking for here? sequence? idk
1581
+
1582
+        if ((nrow(inSCE@metadata$seurat$obj@assays$RNA) > 0 && ncol(inSCE@metadata$seurat$obj@assays$RNA) > 0) && !is.null(inSCE@metadata$seurat$obj@[email protected]$var.features)) {
1583
+          seuratObject@[email protected]$var.features <- 
1584
+            inSCE@metadata$seurat$obj@[email protected]$var.features
1557 1585
         }
1558
-        if (!is.null(inSCE@metadata$seurat$obj$reductions$pca)) {
1586
+        
1587
+        # if no, then set a new matrix to empty
1588
+        # if (is.null(inSCE@metadata$seurat$obj@[email protected]$var.features)) {
1589
+        #   seuratObject@[email protected]$var.features <- 
1590
+        #     data.frame(matrix(NA, nrow = nrow(inSCE@metadata$seurat$obj@assays$RNA), ncol = ncol(inSCE@metadata$seurat$obj@assays$RNA)))
1591
+        # }
1592
+        
1593
+        if (!is.null(inSCE@metadata$seurat$obj@reductions) && !is.null(inSCE@metadata$seurat$obj@reductions$pca)) {
1559 1594
           seuratObject@reductions$pca <-
1560
-            inSCE@metadata$seurat$obj$reductions$pca
1595
+            inSCE@metadata$seurat$obj@reductions$pca
1561 1596
         }
1562
-        if (!is.null(inSCE@metadata$seurat$obj$RNA$meta.features)) {
1597
+        if ((nrow(inSCE@metadata$seurat$obj@assays$RNA) > 0 && ncol(inSCE@metadata$seurat$obj@assays$RNA) > 0) && !is.null(inSCE@metadata$seurat$obj@[email protected])) {
1563 1598
           seuratObject@[email protected] <-
1564
-            inSCE@metadata$seurat$obj$RNA$meta.features
1599
+            inSCE@metadata$seurat$obj@[email protected]
1600
+          #seuratObject <-
1601
+          #  SeuratObject::AddMetaData(seuratObject, inSCE@metadata$seurat$obj@[email protected])
1565 1602
         }
1566
-        if (!is.null(inSCE@metadata$seurat$obj$reductions$ica)) {
1603
+        if (!is.null(inSCE@metadata$seurat$obj@reductions$ica)) {
1567 1604
           seuratObject@reductions$ica <-
1568
-            inSCE@metadata$seurat$obj$reductions$ica
1605
+            inSCE@metadata$seurat$obj@reductions$ica
1569 1606
         }
1570
-        if (!is.null(inSCE@metadata$seurat$obj$reductions$tsne)) {
1607
+        if (!is.null(inSCE@metadata$seurat$obj@reductions$tsne)) {
1571 1608
           seuratObject@reductions$tsne <-
1572
-            inSCE@metadata$seurat$obj$reductions$tsne
1609
+            inSCE@metadata$seurat$obj@reductions$tsne
1573 1610
         }
1574
-        if (!is.null(inSCE@metadata$seurat$obj$reductions$umap)) {
1611
+        if (!is.null(inSCE@metadata$seurat$obj@reductions$umap)) {
1575 1612
           seuratObject@reductions$umap <-
1576
-            inSCE@metadata$seurat$obj$reductions$umap
1613
+            inSCE@metadata$seurat$obj@reductions$umap
1577 1614
         }
1578
-        if (!is.null(inSCE@metadata$seurat$obj$meta.data)) {
1615
+        if (!is.null(inSCE@[email protected])) {
1579 1616
           #[email protected] <- 
1580 1617
             #inSCE@metadata$seurat$obj$meta.data[match(colnames(seuratObject), rownames(inSCE@metadata$seurat$obj$meta.data)),]
1581 1618
           seuratObject <- 
1582
-            SeuratObject::AddMetaData(seuratObject, inSCE@metadata$seurat$obj$meta.data[match(colnames(seuratObject), rownames(inSCE@metadata$seurat$obj$meta.data)),])
1619
+            SeuratObject::AddMetaData(seuratObject, inSCE@[email protected][match(colnames(seuratObject), rownames(inSCE@[email protected])),])
1583 1620
         }
1584
-        if (!is.null(inSCE@metadata$seurat$obj$commands)) {
1585
-          seuratObject@commands <- inSCE@metadata$seurat$obj$commands
1621
+        if (!is.null(inSCE@metadata$seurat$obj@commands)) {
1622
+          seuratObject@commands <- inSCE@metadata$seurat$obj@commands
1586 1623
         }
1587 1624
       }
1588 1625
     }
1589 1626
     else{
1590 1627
       if (!is.null(inSCE@metadata$seurat$obj)) {
1591
-        if (length(inSCE@metadata$seurat$obj@[email protected]) > 0) {
1592
-          seuratObject@[email protected] <-
1593
-            inSCE@metadata$seurat$obj@[email protected]
1628
+        if (length(inSCE@metadata$seurat$obj@[email protected]$var.features) > 0) {
1629
+          seuratObject@[email protected]$var.features <-
1630
+            inSCE@metadata$seurat$obj@[email protected]$var.features
1594 1631
         }
1595 1632
         if (!is.null(inSCE@metadata$seurat$obj@reductions$pca)) {
1596 1633
           seuratObject@reductions$pca <-
... ...
@@ -1613,7 +1650,9 @@ convertSCEToSeurat <-
1613 1650
             inSCE@metadata$seurat$obj@reductions$umap
1614 1651
         }
1615 1652
         if (!is.null(inSCE@[email protected])) {
1616
-          [email protected] <- inSCE@[email protected][match(colnames(seuratObject), rownames(inSCE@[email protected])),]
1653
+          #[email protected] <- inSCE@[email protected][match(colnames(seuratObject), rownames(inSCE@[email protected])),]
1654
+          seuratObject <- 
1655
+            SeuratObject::AddMetaData(seuratObject, inSCE@metadata$seurat$obj$meta.data[match(colnames(seuratObject), rownames(inSCE@metadata$seurat$obj$meta.data)),])
1617 1656
         }
1618 1657
         if (!is.null(inSCE@metadata$seurat$obj@commands)) {
1619 1658
           seuratObject@commands <- inSCE@metadata$seurat$obj@commands
... ...
@@ -1624,6 +1663,7 @@ convertSCEToSeurat <-
1624 1663
     if (!is.null(colData(inSCE)) && copyColData) {
1625 1664
       [email protected] <-
1626 1665
         cbind([email protected], colData(inSCE))
1666
+      #seuratObject <- SeuratObject::AddMetaData(seuratObject, colData(inSCE))
1627 1667
     }
1628 1668
 
1629 1669
     # Set additional reducedDims from inSCE object if required
... ...
@@ -1776,16 +1816,16 @@ runSeuratSCTransform <- function(inSCE,
1776 1816
         #inSCE@metadata$seurat$heatmap_pca <- NULL
1777 1817
       }
1778 1818
       if (PCA) {
1779
-        inSCE@metadata$seurat$obj$reductions$pca <- NULL
1819
+        inSCE@metadata$seurat$obj@reductions$pca <- NULL
1780 1820
       }
1781 1821
       if (ICA) {
1782
-        inSCE@metadata$seurat$obj$reductions$ica <- NULL
1822
+        inSCE@metadata$seurat$obj@reductions$ica <- NULL
1783 1823
       }
1784 1824
       if (tSNE) {
1785
-        inSCE@metadata$seurat$obj$reductions$tsne <- NULL
1825
+        inSCE@metadata$seurat$obj@reductions$tsne <- NULL
1786 1826
       }
1787 1827
       if (UMAP) {
1788
-        inSCE@metadata$seurat$obj$reductions$umap <- NULL
1828
+        inSCE@metadata$seurat$obj@reductions$umap <- NULL
1789 1829
       }
1790 1830
       if (clusters) {
1791 1831
         inSCE@metadata$seurat$obj$meta.data$seurat_clusters <- NULL
... ...
@@ -1793,10 +1833,19 @@ runSeuratSCTransform <- function(inSCE,
1793 1833
     }
1794 1834
     if(methods::is(inSCE@metadata$seurat$obj, "Seurat")) {
1795 1835
       if (varFeatures) {
1796
-        methods::slot(inSCE@metadata$seurat$obj, "assays")[["RNA"]]@var.features <-
1797
-          logical()
1798
-        methods::slot(inSCE@metadata$seurat$obj, "assays")[["RNA"]]@meta.features <-
1836
+        seurat.version <- .getSeuratObjectMajorVersion(inSCE@metadata$seurat$obj)
1837
+        if (seurat.version >= 5.0) {
1838
+          #methods::slot(inSCE@metadata$seurat$obj, "assays")[["RNA"]]@meta.data$var.features <-
1839
+          #  logical()
1840
+          methods::slot(inSCE@metadata$seurat$obj, "assays")[["RNA"]]@meta.data <-
1799 1841
           data.frame(row.names = make.unique(gsub("_", "-", rownames(inSCE))))
1842
+        } 
1843
+        else {
1844
+          methods::slot(inSCE@metadata$seurat$obj, "assays")[["RNA"]]@var.features <-
1845
+            logical()
1846
+          methods::slot(inSCE@metadata$seurat$obj, "assays")[["RNA"]]@meta.features <-
1847
+            data.frame(row.names = make.unique(gsub("_", "-", rownames(inSCE))))
1848
+        }       
1800 1849
         inSCE@metadata$seurat$heatmap_pca <- NULL
1801 1850
       }
1802 1851
       if (PCA) {
1803 1852
Binary files a/docs/articles/ui_screenshots/ui_tutorial/qc_run.png and b/docs/articles/ui_screenshots/ui_tutorial/qc_run.png differ
... ...
@@ -119,7 +119,7 @@ if (is.null(reducedDimName)) {
119 119
 }
120 120
 
121 121
 
122
-### when 'sample' doesnn't exists in colData
122
+### when 'sample' doesn't exists in colData
123 123
 if (is.null(samples)) { samples <- "sample" }
124 124
 
125 125
 ```
... ...
@@ -1242,7 +1242,7 @@ if (skipSoupX_bg) {
1242 1242
   cat(paste0('## ', i, ' \n'))
1243 1243
   plotSoupX_bg <- tryCatch(
1244 1244
     {plotSoupXResults(inSCE = sce.qc, 
1245
-                     soupXSample, 
1245
+                     sceSample, 
1246 1246
                      combinePlot = "none",
1247 1247
                      background = TRUE)},
1248 1248
     error = function(e) {
... ...
@@ -1278,7 +1278,7 @@ for (sample in samples){
1278 1278
   
1279 1279
   cat("#### Soup Fractions {.tabset .tabset-fade} \n\n")
1280 1280
   
1281
-  for (marker in names(plotSoupX$Sample[[sample]])[-1]) {
1281
+  for (marker in names(plotSoupX_bg$Sample[[sample]])[-1]) {
1282 1282
     cat(paste0("##### ", marker, " {.tabset .tabset-fade} \n\n"))
1283 1283
     plot(plotSoupX_bg$Sample[[sample]][[marker]])
1284 1284
     cat("\n\n")
... ...
@@ -91,7 +91,7 @@ if(!showClusterDesc){
91 91
 }
92 92
 ```
93 93
 
94
-```{r, results='asis', warning=FALSE, message=FALSE, eval = !(plotTSNE && !is.null(metadata(data)$seurat$obj@reductions$tsne))}
94
+```{r, results='asis', warning=FALSE, message=FALSE, eval = !(plotTSNE && !is.null(metadata(data)$seurat$obj$reductions$tsne))}
95 95
 data <- runSeuratTSNE(data, useReduction = "pca", dims = significant_PC)
96 96
 ```
97 97
 
... ...
@@ -104,7 +104,6 @@ for(i in 1:(((maxResolution-minResolution)*10)+1)){
104 104
   cat(headingRES, " RES ", j, " {.tabset -} \n\n")
105 105
   cat(headingClust," Clusters {-} \n\n")
106 106
   p <- plotSeuratReduction(data, useReduction = "tsne", groupBy = paste0("Seurat_louvain_Resolution", j), showLegend = TRUE)
107
-  j <- j + 0.1
108 107
   print(p)
109 108
   cat("\n\n")
110 109
   
... ...
@@ -114,9 +113,10 @@ for(i in 1:(((maxResolution-minResolution)*10)+1)){
114 113
   cat("\n\n")
115 114
   
116 115
     cat(headingClust," Samples separated {-} \n\n")
117
-      p <- plotSeuratReduction(data, useReduction = "tsne", splitBy = biological.group, showLegend = TRUE)
116
+      p <- plotSeuratReduction(data, useReduction = "tsne", groupBy = paste0("Seurat_louvain_Resolution", j), splitBy = biological.group, showLegend = TRUE)
118 117
   print(p)
119 118
   cat("\n\n")
119
+  j <- j + 0.1
120 120
   
121 121
   if(!is.null(phenotype.groups)){
122 122
     cat(headingClust," Phenotype variable:", phenotype.groups," {-} \n\n")
... ...
@@ -127,7 +127,7 @@ for(i in 1:(((maxResolution-minResolution)*10)+1)){
127 127
 }
128 128
 ```
129 129
 
130
-```{r, results='asis', warning=FALSE, message=FALSE, eval = !(plotUMAP && !is.null(metadata(data)$seurat$obj@reductions$umap))}
130
+```{r, results='asis', warning=FALSE, message=FALSE, eval = !(plotUMAP && !is.null(metadata(data)$seurat$obj$reductions$umap))}
131 131
 data <- runSeuratUMAP(data, useReduction = "pca", dims = significant_PC)
132 132
 ```
133 133
 
... ...
@@ -140,7 +140,6 @@ for(i in 1:(((maxResolution-minResolution)*10)+1)){
140 140
   cat(headingRES, " RES ", j, " {.tabset -} \n\n")
141 141
   cat(headingClust," Clusters {-} \n\n")
142 142
   p <- plotSeuratReduction(data, useReduction = "umap", groupBy = paste0("Seurat_louvain_Resolution", j), showLegend = TRUE)
143
-  j <- j + 0.1
144 143
   
145 144
   print(p)
146 145
   
... ...
@@ -151,9 +150,10 @@ for(i in 1:(((maxResolution-minResolution)*10)+1)){
151 150
   cat("\n\n")
152 151
   
153 152
     cat(headingClust," Samples separated {-} \n\n")
154
-  p <- plotSeuratReduction(data, useReduction = "umap", splitBy = biological.group, showLegend = TRUE)
153
+  p <- plotSeuratReduction(data, useReduction = "umap", groupBy = paste0("Seurat_louvain_Resolution", j), splitBy = biological.group, showLegend = TRUE)
155 154
   print(p)
156 155
   cat("\n\n")
156
+  j <- j + 0.1
157 157
   
158 158
     if(!is.null(phenotype.groups)){
159 159
       cat(headingClust," Phenotype variable:", phenotype.groups," {-} \n\n")
... ...
@@ -58,7 +58,7 @@ cat(headingDR, " PCA {.tabset .tabset-fade}\n\n")
58 58
 
59 59
 To reduce the adverse effects of the inherent technical noise in single-cell data on downstream clustering, reduced dimensions are computed where each dimension represents a set of correlated features. However, an important task is to select the number of components that should be utilized by the downstream methods. To select the number of principal components that should be used in the downstream analysis, JackStraw and Elbow plot provide convenience in the selection of the significant components that contain most of the variability.  
60 60
 
61
-```{r, results='asis', warning=FALSE, eval = !(runDimRed && !is.null(metadata(data)$seurat$obj@reductions$pca)) || forceRun}
61
+```{r, results='asis', warning=FALSE, eval = !(runDimRed && !is.null(metadata(data)$seurat$obj$reductions$pca)) || forceRun}
62 62
 pcaParams <- list(
63 63
   inSCE = data,
64 64
   nPCs = pc.count,
... ...
@@ -94,8 +94,8 @@ ElbowPlot
94 94
 ```
95 95
 
96 96
 ```{r, echo=FALSE, warning=FALSE, eval= plotJackStraw}
97
-if(!is.null(metadata(data)$seurat$obj@reductions$pca@jackstraw)){
98
-  PC_Matrix <- metadata(data)$seurat$obj@reductions$pca@[email protected]
97
+if(!is.null(metadata(data)$seurat$obj$reductions$pca@jackstraw)){
98
+  PC_Matrix <- metadata(data)$seurat$obj$reductions$pca@jackstraw$overall.p.values
99 99
   
100 100
   significant_PC <- which.min(PC_Matrix[,2] < 0.01) - 1
101 101
 if (!exists("significant_PC") || significant_PC == 0){
... ...
@@ -129,7 +129,7 @@ JackStrawPlot
129 129
 PC.separated.height <- 3.5 * ceiling(pc.count/3)
130 130
 ```
131 131
 
132
-```{r, echo=FALSE, include=TRUE, eval = !(runDimRed && !is.null(metadata(data)$seurat$obj@reductions$pca))}
132
+```{r, echo=FALSE, include=TRUE, eval = !(runDimRed && !is.null(metadata(data)$seurat$obj$reductions$pca))}
133 133
 pcaParams$inSCE <- NULL
134 134
 pcaParams$significant_PC <- significant_PC
135 135
 metadata(data)$seurat$sctk$report$pcaParams <- pcaParams
... ...
@@ -54,7 +54,7 @@ cat(headingFS, " Feature Selection {}\n\n")
54 54
 
55 55
 Generally, a subset of features may represent the biological variation in the overall data and to better capture this true biological signal, it is recommended to identify this subset of features that often exhibit high cell-to-cell variation and use it in the downstream analysis instead of the full set of features. For this purpose, Seurat models the mean-to-variance relationship of the expression data by first computing *log of mean* and *log of variance* using *loess* and then standardizes the values using observed mean and expected variance. The overall variance of each feature is computed from the standardized values by clipping to a maximum value and ordering the features in the order of their variance. Lastly, top genes (by default *2000*) are selected as the top most variable features that represent the highest biological variability and used in the downstream methods.
56 56
 
57
-```{r, results='asis', warning=FALSE, message=FALSE, eval = !((runHVG && length(metadata(data)$seurat$obj@[email protected]) > 0)) || forceRun}
57
+```{r, results='asis', warning=FALSE, message=FALSE, eval = !((runHVG && length(metadata(data)$seurat$obj$RNA$var.features) > 0)) || forceRun}
58 58
 hvgParams <- list(
59 59
   inSCE = data,
60 60
   method = "vst", 
... ...
@@ -76,7 +76,7 @@ Labeled_Variable_data <- plotSeuratHVG(inSCE = data, labelPoints = 10)
76 76
 Labeled_Variable_data
77 77
 ```
78 78
 
79
-```{r, echo=FALSE, warning=FALSE, message=FALSE, include=FALSE, eval=!(runHVG && length(metadata(data)$seurat$obj@[email protected]) > 0)}
79
+```{r, echo=FALSE, warning=FALSE, message=FALSE, include=FALSE, eval=!(runHVG && length(metadata(data)$seurat$obj$RNA$var.features) > 0)}
80 80
 hvgParams$inSCE <- NULL
81 81
 hvgParams$labelPoints <- 10
82 82
 hvgParams$totalFeatures <- variable.features
... ...
@@ -7776,7 +7776,7 @@ shinyServer(function(input, output, session) {
7776 7776
     {
7777 7777
       req(vals$counts)
7778 7778
       message(paste0(date(), " ... Finding High Variable Genes"))
7779
-      if(input$hvg_method == "vst" || packageVersion(pkg = "SeuratObject") >= 5.0){
7779
+      if(input$hvg_method == "vst" || packageVersion(pkg = "SeuratObject") >= "5.0"){
7780 7780
         vals$counts <- runSeuratFindHVG(inSCE = vals$counts,
7781 7781
                                         useAssay = metadata(vals$counts)$sctk$seuratUseAssay,
7782 7782
                                         method = input$hvg_method,
... ...
@@ -7813,12 +7813,13 @@ shinyServer(function(input, output, session) {
7813 7813
   output$hvg_output <- renderText({
7814 7814
     req(vals$counts)
7815 7815
     if (!is.null(vals$counts@metadata$seurat$obj)) {
7816
-      if(packageVersion(pkg = "SeuratObject") >= 5.0){
7817
-        if (length(vals$counts@metadata$seurat$obj$RNA$"var.features") > 0) {
7816
+      if(packageVersion(pkg = "SeuratObject") >= "5.0"){
7817
+        #if (length(vals$counts@metadata$seurat$obj$RNA$"var.features") > 0) {
7818 7818
           isolate({
7819
+            
7819 7820
             singleCellTK:::.seuratGetVariableFeatures(vals$counts, input$hvg_no_features_view)
7820 7821
           })
7821
-        }
7822
+        #}
7822 7823
       }
7823 7824
       else{
7824 7825
         if (length(slot(vals$counts@metadata$seurat$obj, "assays")[["RNA"]]@var.features) > 0) {
... ...
@@ -8113,8 +8114,8 @@ shinyServer(function(input, output, session) {
8113 8114
     msg = "Please wait while clusters are being computed. See console log for progress.",
8114 8115
     {
8115 8116
       req(vals$counts)
8116
-      if(packageVersion(pkg = "SeuratObject") >= 5.0){
8117
-        pathToCluster = vals$counts@metadata$seurat$obj$"reductions"[[input$reduction_clustering_method]]
8117
+      if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8118
+        pathToCluster = vals$counts@metadata$seurat$obj@reductions[[input$reduction_clustering_method]]
8118 8119
       }
8119 8120
       else
8120 8121
         pathToCluster = vals$counts@metadata$seurat$obj@"reductions"[[input$reduction_clustering_method]]
... ...
@@ -8137,8 +8138,8 @@ shinyServer(function(input, output, session) {
8137 8138
         updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "success"))
8138 8139
         message(paste0(date(), " ... Finding Clusters Complete"))
8139 8140
         
8140
-        if(packageVersion(pkg = "SeuratObject") >= 5.0){
8141
-          pathToUMAP = vals$counts@metadata$seurat$obj$"reductions"[["umap"]]
8141
+        if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8142
+          pathToUMAP = vals$counts@metadata$seurat$obj@reductions[["umap"]]
8142 8143
         }
8143 8144
         else
8144 8145
           pathToUMAP = vals$counts@metadata$seurat$obj@"reductions"[["umap"]]
... ...
@@ -8164,8 +8165,8 @@ shinyServer(function(input, output, session) {
8164 8165
             condition = !is.null(pathToUMAP))
8165 8166
         }
8166 8167
         
8167
-        if(packageVersion(pkg = "SeuratObject") >= 5.0){
8168
-          pathToTSNE = vals$counts@metadata$seurat$obj$"reductions"[["tsne"]]
8168
+        if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8169
+          pathToTSNE = vals$counts@metadata$seurat$obj@reductions[["tsne"]]
8169 8170
         }
8170 8171
         else
8171 8172
           pathToTSNE = vals$counts@metadata$seurat$obj@"reductions"[["tsne"]]
... ...
@@ -8192,8 +8193,8 @@ shinyServer(function(input, output, session) {
8192 8193
             condition = !is.null(pathToTSNE))
8193 8194
         }
8194 8195
         
8195
-        if(packageVersion(pkg = "SeuratObject") >= 5.0){
8196
-          pathToPCA = vals$counts@metadata$seurat$obj$"reductions"[["pca"]]
8196
+        if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8197
+          pathToPCA = vals$counts@metadata$seurat$obj@reductions[["pca"]]
8197 8198
         }
8198 8199
         else
8199 8200
           pathToPCA = vals$counts@metadata$seurat$obj@"reductions"[["pca"]]
... ...
@@ -8219,8 +8220,8 @@ shinyServer(function(input, output, session) {
8219 8220
             condition = !is.null(pathToPCA))
8220 8221
         }
8221 8222
         
8222
-        if(packageVersion(pkg = "SeuratObject") >= 5.0){
8223
-          pathToICA = vals$counts@metadata$seurat$obj$"reductions"[["ica"]]
8223
+        if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8224
+          pathToICA = vals$counts@metadata$seurat$obj@reductions[["ica"]]
8224 8225
         }
8225 8226
         else
8226 8227
           pathToICA = vals$counts@metadata$seurat$obj@"reductions"[["ica"]]
... ...
@@ -8255,7 +8256,12 @@ shinyServer(function(input, output, session) {
8255 8256
         shinyjs::enable(selector = "#SeuratUI > div[value='Marker Gene Plots']")
8256 8257
         
8257 8258
         #MARKER SETTINGS
8258
-        geneChoices <- rowData(vals$counts)$Symbol_TENx
8259
+
8260
+        # this doesn't work for the PBMC Seurat data
8261
+
8262
+        #geneChoices <- rowData(vals$counts)$Symbol_TENx
8263
+        geneChoices <- rownames(vals$counts)
8264
+
8259 8265
         updateSelectizeInput(session, "selectGenesMarkerPlots",
8260 8266
                           choices = geneChoices)
8261 8267
         
... ...
@@ -8433,7 +8439,7 @@ shinyServer(function(input, output, session) {
8433 8439
             x = t,
8434 8440
             fixed = TRUE)
8435 8441
         )
8436
-        if(seurat.version >= 5.0){
8442
+        if(seurat.version >= "5.0"){
8437 8443
           Idents(seuratObject, cells = unlist(cells[[i]])) <- groups[i]
8438 8444
           
8439 8445
         }
... ...
@@ -8522,7 +8528,7 @@ shinyServer(function(input, output, session) {
8522 8528
             x = t,
8523 8529
             fixed = TRUE)
8524 8530
         )
8525
-        if(seurat.version >= 5.0){
8531
+        if(seurat.version >= "5.0"){
8526 8532
           cells[[i]] = unlist(cells[[i]])
8527 8533
         }
8528 8534
         Idents(seuratObject, cells = cells[[i]]) <- groups[i]
... ...
@@ -8579,7 +8585,7 @@ shinyServer(function(input, output, session) {
8579 8585
         groupVariable = input$seuratFindMarkerSelectPhenotype,
8580 8586
         ncol = 2,
8581 8587
         combine = TRUE,
8582
-        useReduction = input$seuratFeatureUseReduction
8588
+        #useReduction = input$seuratFeatureUseReduction
8583 8589
       )
8584 8590
     })
8585 8591
     output$findMarkerDotPlot <- renderPlot({
... ...
@@ -8636,8 +8642,8 @@ shinyServer(function(input, output, session) {
8636 8642
     {
8637 8643
       req(vals$counts)
8638 8644
       
8639
-      if(packageVersion(pkg = "SeuratObject") >= 5.0){
8640
-        pathToTSNE = vals$counts@metadata$seurat$obj$"reductions"[[input$reduction_tsne_method]]
8645
+      if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8646
+        pathToTSNE = vals$counts@metadata$seurat$obj@reductions[[input$reduction_tsne_method]]
8641 8647
       }
8642 8648
       else
8643 8649
         pathToTSNE = vals$counts@metadata$seurat$obj@"reductions"[[input$reduction_tsne_method]]
... ...
@@ -8693,8 +8699,9 @@ shinyServer(function(input, output, session) {
8693 8699
     msg = "Please wait while UMAP is being computed. See console log for progress.",
8694 8700
     {
8695 8701
       req(vals$counts)
8696
-      if(packageVersion(pkg = "SeuratObject") >= 5.0){
8697
-        pathToUMAP = vals$counts@metadata$seurat$obj$"reductions"[[input$reduction_umap_method]]
8702
+      if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8703
+        #pathToUMAP = vals$counts@metadata$seurat$obj$"reductions"[[input$reduction_umap_method]]
8704
+        pathToUMAP = vals$counts@metadata$seurat$obj@reductions[[input$reduction_umap_method]]
8698 8705
       }
8699 8706
       else
8700 8707
         pathToUMAP = vals$counts@metadata$seurat$obj@"reductions"[[input$reduction_umap_method]]
... ...
@@ -8817,178 +8824,182 @@ shinyServer(function(input, output, session) {
8817 8824
   
8818 8825
   
8819 8826
   #Disable Seurat tabs & reset collapse panel tabs
8820
-  observe({
8821
-    if(!is.null(vals$counts)){
8822
-      #If data is uploaded in data tab, enable first tab i.e. Normalization tab in Seurat workflow
8823
-      shinyjs::enable(
8824
-        selector = "#SeuratUI > div[value='Normalize Data']")
8825
-      shinyjs::enable(
8826
-        selector = "#ScanpyUI > div[value='Normalize Data']")
8827
-      
8828
-      #Proceed only if sce object has metadata slot
8829
-      if(!is.null(vals$counts@metadata)){
8830
-        if(packageVersion(pkg = "SeuratObject") >= 5.0){
8831
-          #Proceed only if sce object has seurat object stored in metadata slot
8832
-          if(!is.null(vals$counts@metadata$seurat$obj)){
8833
-            #If variableFeatures have been removed from sce object, reset HVG tab and reset/lock next tab
8834
-            if(length(vals$counts@metadata$seurat$obj$RNA$"var.features") <= 0){
8835
-              updateCollapse(session = session, "SeuratUI", style = list("Highly Variable Genes" = "primary"))
8836
-              updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8837
-              shinyjs::disable(selector = "#SeuratUI > div[value='Dimensionality Reduction']")
8838
-            }
8827
+  
8828
+  # Try deleting this chunk of Seurat code and see if the image still runs
8829
+  
8830
+
8831
+  # observe({
8832
+  #   if(!is.null(vals$counts)){
8833
+  #     #If data is uploaded in data tab, enable first tab i.e. Normalization tab in Seurat workflow
8834
+  #     shinyjs::enable(
8835
+  #       selector = "#SeuratUI > div[value='Normalize Data']")
8836
+  #     shinyjs::enable(
8837
+  #       selector = "#ScanpyUI > div[value='Normalize Data']")
8838
+      
8839
+  #     #Proceed only if sce object has metadata slot
8840
+  #     if(!is.null(vals$counts@metadata)){
8841
+  #       if(packageVersion(pkg = "SeuratObject") >= "5.0"){
8842
+  #         #Proceed only if sce object has seurat object stored in metadata slot
8843
+  #         if(!is.null(vals$counts@metadata$seurat$obj)){
8844
+  #           #If variableFeatures have been removed from sce object, reset HVG tab and reset/lock next tab
8845
+  #           if(length(vals$counts@metadata$seurat$obj$RNA$"var.features") <= 0){
8846
+  #             updateCollapse(session = session, "SeuratUI", style = list("Highly Variable Genes" = "primary"))
8847
+  #             updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8848
+  #             shinyjs::disable(selector = "#SeuratUI > div[value='Dimensionality Reduction']")
8849
+  #           }
8839 8850
             
8840
-            #Proceed if reduction slot is present in seurat object in metadata slot
8841
-            if("reductions" %in% names(vals$counts@metadata$seurat$obj)){
8851
+  #           #Proceed if reduction slot is present in seurat object in metadata slot
8852
+  #           if("reductions" %in% names(vals$counts@metadata$seurat$obj)){
8842 8853
               
8843
-              #If PCA and ICA both removed from sce object, reset DR tab and reset/lock next tab
8844
-              if(is.null(vals$counts@metadata$seurat$obj$reductions$pca)
8845
-                 && is.null(vals$counts@metadata$seurat$obj$reductions$ica)){
8846
-                updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8847
-                updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8848
-                shinyjs::disable(selector = "#SeuratUI > div[value='2D-Embedding']")
8849
-              }
8854
+  #             #If PCA and ICA both removed from sce object, reset DR tab and reset/lock next tab
8855
+  #             if(is.null(vals$counts@metadata$seurat$obj@reductions$pca)
8856
+  #                && is.null(vals$counts@metadata$seurat$obj@reductions$ica)){
8857
+  #               updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8858
+  #               updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8859
+  #               shinyjs::disable(selector = "#SeuratUI > div[value='2D-Embedding']")
8860
+  #             }
8850 8861
               
8851
-              #If TSNE and UMAP both removed from sce object, reset 2D-Embedding tab and reset/lock next tab
8852
-              if(is.null(vals$counts@metadata$seurat$obj$reductions$tsne)
8853
-                 && is.null(vals$counts@metadata$seurat$obj$reductions$umap)){
8854
-                updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8855
-                updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8856
-                shinyjs::disable(selector = "#SeuratUI > div[value='Clustering']")
8857
-              }
8862
+  #             #If TSNE and UMAP both removed from sce object, reset 2D-Embedding tab and reset/lock next tab
8863
+  #             if(is.null(vals$counts@metadata$seurat$obj@reductions$tsne)
8864
+  #                && is.null(vals$counts@metadata$seurat$obj@reductions$umap)){
8865
+  #               updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8866
+  #               updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8867
+  #               shinyjs::disable(selector = "#SeuratUI > div[value='Clustering']")
8868
+  #             }
8858 8869
               
8859
-              #If seurat cluster information removed from sce object, reset Clustering tab
8860
-              if(!"seurat_clusters" %in% names(vals$counts@metadata$seurat$obj$meta.data)){
8861
-                updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8862
-                updateCollapse(session = session, "SeuratUI", style = list("Find Markers" = "primary"))
8863
-                shinyjs::disable(selector = "#SeuratUI > div[value='Find Markers']")
8864
-              }
8865
-            }
8870
+  #             #If seurat cluster information removed from sce object, reset Clustering tab
8871
+  #             if(!"seurat_clusters" %in% names(vals$counts@[email protected])){
8872
+  #               updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8873
+  #               updateCollapse(session = session, "SeuratUI", style = list("Find Markers" = "primary"))
8874
+  #               shinyjs::disable(selector = "#SeuratUI > div[value='Find Markers']")
8875
+  #             }
8876
+  #           }
8866 8877
             
8867
-          }
8878
+  #         }
8868 8879
           
8869 8880
           
8870
-        }
8871
-        else{
8872
-          #Proceed only if sce object has seurat object stored in metadata slot
8873
-          if(!is.null(vals$counts@metadata$seurat$obj)){
8874
-            # #If seuratScaledData has been removed from sce object, reset Scale Data tab and reset/lock its next tab
8875
-            # if(!"seuratScaledData" %in% expDataNames(vals$counts)){
8876
-            #   updateCollapse(session = session, "SeuratUI", style = list("Scale Data" = "primary"))
8877
-            #   updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8878
-            #   shinyjs::disable(selector = "div[value='Dimensionality Reduction']")
8879
-            # }
8881
+  #       }
8882
+  #       else{
8883
+  #         #Proceed only if sce object has seurat object stored in metadata slot
8884
+  #         if(!is.null(vals$counts@metadata$seurat$obj)){
8885
+  #           # #If seuratScaledData has been removed from sce object, reset Scale Data tab and reset/lock its next tab
8886
+  #           # if(!"seuratScaledData" %in% expDataNames(vals$counts)){
8887
+  #           #   updateCollapse(session = session, "SeuratUI", style = list("Scale Data" = "primary"))
8888
+  #           #   updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8889
+  #           #   shinyjs::disable(selector = "div[value='Dimensionality Reduction']")
8890
+  #           # }
8880 8891
             
8881
-            #If variableFeatures have been removed from sce object, reset HVG tab and reset/lock next tab
8882
-            if(length(slot(vals$counts@metadata$seurat$obj, "assays")[["RNA"]]@var.features) <= 0){
8883
-              updateCollapse(session = session, "SeuratUI", style = list("Highly Variable Genes" = "primary"))
8884
-              updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8885
-              shinyjs::disable(selector = "#SeuratUI > div[value='Dimensionality Reduction']")
8886
-            }
8892
+  #           #If variableFeatures have been removed from sce object, reset HVG tab and reset/lock next tab
8893
+  #           if(length(slot(vals$counts@metadata$seurat$obj, "assays")[["RNA"]]@var.features) <= 0){
8894
+  #             updateCollapse(session = session, "SeuratUI", style = list("Highly Variable Genes" = "primary"))
8895
+  #             updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8896
+  #             shinyjs::disable(selector = "#SeuratUI > div[value='Dimensionality Reduction']")
8897
+  #           }
8887 8898
             
8888
-            #Proceed if reduction slot is present in seurat object in metadata slot
8889
-            if("reductions" %in% slotNames(vals$counts@metadata$seurat$obj)){
8899
+  #           #Proceed if reduction slot is present in seurat object in metadata slot
8900
+  #           if("reductions" %in% slotNames(vals$counts@metadata$seurat$obj)){
8890 8901
               
8891
-              #If PCA and ICA both removed from sce object, reset DR tab and reset/lock next tab
8892
-              if(is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["pca"]])
8893
-                 && is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["ica"]])){
8894
-                updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8895
-                updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8896
-                shinyjs::disable(selector = "#SeuratUI > div[value='2D-Embedding']")
8897
-              }
8902
+  #             #If PCA and ICA both removed from sce object, reset DR tab and reset/lock next tab
8903
+  #             if(is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["pca"]])
8904
+  #                && is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["ica"]])){
8905
+  #               updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "primary"))
8906
+  #               updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8907
+  #               shinyjs::disable(selector = "#SeuratUI > div[value='2D-Embedding']")
8908
+  #             }
8898 8909
               
8899
-              #If TSNE and UMAP both removed from sce object, reset 2D-Embedding tab and reset/lock next tab
8900
-              if(is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["tsne"]])
8901
-                 && is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["umap"]])){
8902
-                updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8903
-                updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8904
-                shinyjs::disable(selector = "#SeuratUI > div[value='Clustering']")
8905
-              }
8910
+  #             #If TSNE and UMAP both removed from sce object, reset 2D-Embedding tab and reset/lock next tab
8911
+  #             if(is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["tsne"]])
8912
+  #                && is.null(slot(vals$counts@metadata$seurat$obj, "reductions")[["umap"]])){
8913
+  #               updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "primary"))
8914
+  #               updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8915
+  #               shinyjs::disable(selector = "#SeuratUI > div[value='Clustering']")
8916
+  #             }
8906 8917
               
8907
-              #If seurat cluster information removed from sce object, reset Clustering tab
8908
-              if(!"seurat_clusters" %in% names(vals$counts@[email protected])){
8909
-                updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8910
-                updateCollapse(session = session, "SeuratUI", style = list("Find Markers" = "primary"))
8911
-                shinyjs::disable(selector = "#SeuratUI > div[value='Find Markers']")
8912
-              }
8913
-            }
8918
+  #             #If seurat cluster information removed from sce object, reset Clustering tab
8919
+  #             if(!"seurat_clusters" %in% names(vals$counts@[email protected])){
8920
+  #               updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "primary"))
8921
+  #               updateCollapse(session = session, "SeuratUI", style = list("Find Markers" = "primary"))
8922
+  #               shinyjs::disable(selector = "#SeuratUI > div[value='Find Markers']")
8923
+  #             }
8924
+  #           }
8914 8925
             
8915
-          }
8926
+  #         }
8916 8927
           
8917
-        }
8928
+  #       }
8918 8929
         
8919 8930
         
8920 8931
         
8921
-      }
8922
-    }
8923
-    else{
8924
-      #If no data uploaded in data tab, disable all tabs and plots.
8925
-      
8926
-      #Disable tabs
8927
-      shinyjs::disable(
8928
-        selector = "#SeuratUI > div[value='Normalize Data']")
8929
-      shinyjs::disable(
8930
-        selector = "#ScanpyUI > div[value='Normalize Data']")
8931
-      
8932
-      shinyjs::disable(
8933
-        selector = "#SeuratUI > div[value='Highly Variable Genes']")
8934
-      shinyjs::disable(
8935
-        selector = "#ScanpyUI > div[value='Highly Variable Genes']")
8936
-      
8937
-      shinyjs::disable(
8938
-        selector = "#SeuratUI > div[value='Scale Data']")
8939
-      shinyjs::disable(
8940
-        selector = "#SeuratUI > div[value='Dimensionality Reduction']")
8941
-      shinyjs::disable(
8942
-        selector = "#ScanpyUI > div[value='Dimensionality Reduction']")
8943
-      
8944
-      shinyjs::disable(
8945
-        selector = "#SeuratUI > div[value='2D-Embedding']")
8946
-      shinyjs::disable(
8947
-        selector = "#ScanpyUI > div[value='2D-Embedding']")
8948
-      
8949
-      shinyjs::disable(
8950
-        selector = "#SeuratUI > div[value='Clustering']")
8951
-      shinyjs::disable(
8952
-        selector = "#ScanpyUI > div[value='Clustering']")
8953
-      
8954
-      shinyjs::disable(
8955
-        selector = "#SeuratUI > div[value='Marker Gene Plots']")
8956
-      
8957
-      shinyjs::disable(
8958
-        selector = "#SeuratUI > div[value='Scale Data']")
8959
-      shinyjs::disable(
8960
-        selector = "#SeuratUI > div[value='Find Markers']")
8961
-      shinyjs::disable(
8962
-        selector = "#ScanpyUI > div[value='Find Markers']")
8963
-      
8964
-      
8965
-      #Disable plots inside PCA subtab
8966
-      shinyjs::disable(
8967
-        selector = ".seurat_pca_plots a[data-value='PCA Plot']")
8968
-      shinyjs::disable(
8969
-        selector = ".seurat_pca_plots a[data-value='Elbow Plot']")
8970
-      shinyjs::disable(
8971
-        selector = ".seurat_pca_plots a[data-value='JackStraw Plot']")
8972
-      shinyjs::disable(
8973
-        selector = ".seurat_pca_plots a[data-value='Heatmap Plot']")
8974
-      
8975
-      #Disable plots inside ICA subtab
8976
-      shinyjs::disable(
8977
-        selector = ".seurat_ica_plots a[data-value='ICA Plot']")
8978
-      shinyjs::disable(
8979
-        selector = ".seurat_ica_plots a[data-value='Heatmap Plot']")
8980
-      
8981
-      #Disabled plots inside Clustering tab
8982
-      shinyjs::disable(
8983
-        selector = ".seurat_clustering_plots a[data-value='PCA Plot']")
8984
-      shinyjs::disable(
8985
-        selector = ".seurat_clustering_plots a[data-value='ICA Plot']")
8986
-      shinyjs::disable(
8987
-        selector = ".seurat_clustering_plots a[data-value='tSNE Plot']")
8988
-      shinyjs::disable(
8989
-        selector = ".seurat_clustering_plots a[data-value='UMAP Plot']")
8990
-    }
8991
-  })
8932
+  #     }
8933
+  #   }
8934
+  #   else{
8935
+  #     #If no data uploaded in data tab, disable all tabs and plots.
8936
+      
8937
+  #     #Disable tabs
8938
+  #     shinyjs::disable(
8939
+  #       selector = "#SeuratUI > div[value='Normalize Data']")
8940
+  #     shinyjs::disable(
8941
+  #       selector = "#ScanpyUI > div[value='Normalize Data']")
8942
+      
8943
+  #     shinyjs::disable(
8944
+  #       selector = "#SeuratUI > div[value='Highly Variable Genes']")
8945
+  #     shinyjs::disable(
8946
+  #       selector = "#ScanpyUI > div[value='Highly Variable Genes']")
8947
+      
8948
+  #     shinyjs::disable(
8949
+  #       selector = "#SeuratUI > div[value='Scale Data']")
8950
+  #     shinyjs::disable(
8951
+  #       selector = "#SeuratUI > div[value='Dimensionality Reduction']")
8952
+  #     shinyjs::disable(
8953
+  #       selector = "#ScanpyUI > div[value='Dimensionality Reduction']")
8954
+      
8955
+  #     shinyjs::disable(
8956
+  #       selector = "#SeuratUI > div[value='2D-Embedding']")
8957
+  #     shinyjs::disable(
8958
+  #       selector = "#ScanpyUI > div[value='2D-Embedding']")
8959
+      
8960
+  #     shinyjs::disable(
8961
+  #       selector = "#SeuratUI > div[value='Clustering']")
8962
+  #     shinyjs::disable(
8963
+  #       selector = "#ScanpyUI > div[value='Clustering']")
8964
+      
8965
+  #     shinyjs::disable(
8966
+  #       selector = "#SeuratUI > div[value='Marker Gene Plots']")
8967
+      
8968
+  #     shinyjs::disable(
8969
+  #       selector = "#SeuratUI > div[value='Scale Data']")
8970
+  #     shinyjs::disable(
8971
+  #       selector = "#SeuratUI > div[value='Find Markers']")
8972
+  #     shinyjs::disable(
8973
+  #       selector = "#ScanpyUI > div[value='Find Markers']")
8974
+      
8975
+      
8976
+  #     #Disable plots inside PCA subtab
8977
+  #     shinyjs::disable(
8978
+  #       selector = ".seurat_pca_plots a[data-value='PCA Plot']")
8979
+  #     shinyjs::disable(
8980
+  #       selector = ".seurat_pca_plots a[data-value='Elbow Plot']")
8981
+  #     shinyjs::disable(
8982
+  #       selector = ".seurat_pca_plots a[data-value='JackStraw Plot']")
8983
+  #     shinyjs::disable(
8984
+  #       selector = ".seurat_pca_plots a[data-value='Heatmap Plot']")
8985
+      
8986
+  #     #Disable plots inside ICA subtab
8987
+  #     shinyjs::disable(
8988
+  #       selector = ".seurat_ica_plots a[data-value='ICA Plot']")
8989
+  #     shinyjs::disable(
8990
+  #       selector = ".seurat_ica_plots a[data-value='Heatmap Plot']")
8991
+      
8992
+  #     #Disabled plots inside Clustering tab
8993
+  #     shinyjs::disable(
8994
+  #       selector = ".seurat_clustering_plots a[data-value='PCA Plot']")
8995
+  #     shinyjs::disable(
8996
+  #       selector = ".seurat_clustering_plots a[data-value='ICA Plot']")
8997
+  #     shinyjs::disable(
8998
+  #       selector = ".seurat_clustering_plots a[data-value='tSNE Plot']")
8999
+  #     shinyjs::disable(
9000
+  #       selector = ".seurat_clustering_plots a[data-value='UMAP Plot']")
9001
+  #   }
9002
+  # })
8992 9003
   
8993 9004
   #-----------------------------------------------------------------------------
8994 9005
   # Page: Column Annotation (colData) ####
... ...
@@ -301,7 +301,6 @@ shinyPanelSeurat <- fluidPage(
301 301
                               column(12,
302 302
                                      tags$div(class = "seurat_findmarker_plots",
303 303
                                               panel(heading = "",
304
-                                                    HTML("<center><h5><span style='color:red; font-weight:bold; text-align:center;'>Select marker genes above to plot them below!</span></h5></br></center>"),
305 304
                                                     tabsetPanel(id = "seuratFindMarkerPlotTabset", type = "tabs"))
306 305
                                      )
307 306
                               )
... ...
@@ -7,11 +7,11 @@
7 7
 dedupRowNames(x, as.rowData = FALSE, return.list = FALSE)
8 8
 }
9 9
 \arguments{
10
-\item{x}{A matrix like or /linkS4class{SingleCellExperiment} object, on which
10
+\item{x}{A matrix like or \linkS4class{SingleCellExperiment} object, on which
11 11
 we can apply \code{rownames()} to and has duplicated rownames.}
12 12
 
13 13
 \item{as.rowData}{Only applicable when \code{x} is a
14
-/linkS4class{SingleCellExperiment} object. When set to \code{TRUE}, will
14
+\linkS4class{SingleCellExperiment} object. When set to \code{TRUE}, will
15 15
 insert a new column called \code{"rownames.uniq"} to \code{rowData(x)}, with
16 16
 the deduplicated rownames.}
17 17
 
... ...
@@ -19,9 +19,9 @@ the deduplicated rownames.}
19 19
 of the deduplicated rownames.}
20 20
 }
21 21
 \value{
22
-By default, a matrix or /linkS4class{SingleCellExperiment} object
22
+By default, a matrix or \linkS4class{SingleCellExperiment} object
23 23
 with rownames deduplicated.
24
-When \code{x} is a /linkS4class{SingleCellExperiment} and \code{as.rowData}
24
+When \code{x} is a \linkS4class{SingleCellExperiment} and \code{as.rowData}
25 25
 is set to \code{TRUE}, will return \code{x} with \code{rowData} updated.
26 26
 When \code{return.list} is set to \code{TRUE}, will return a character vector
27 27
 with the deduplicated rownames.
... ...
@@ -39,7 +39,7 @@ plotBubble(
39 39
 
40 40
 \item{colorHigh}{The color to be used for highest value of mean expression}
41 41
 
42
-\item{scale}{Option to scale the data. Default: /code{FALSE}. Selected assay will not be scaled.}
42
+\item{scale}{Option to scale the data. Default: \code{FALSE}. Selected assay will not be scaled.}
43 43
 }
44 44
 \value{
45 45
 A ggplot of the bubble plot.
... ...
@@ -53,9 +53,9 @@ object. Only used when "assays" slotName is selected. Default NULL.}
53 53
 
54 54
 \item{sample}{Character vector. Indicates which sample each cell belongs to.}
55 55
 
56
-\item{dimension}{Desired dimension stored in the specified reducedDims.
57
-Either an integer which indicates the column or a character vector specifies
58
-column name. By default, the 1st dimension/column will be used.
56
+\item{dimension}{Desired dimension(s) stored in the specified reducedDims.
57
+Either an integer which indicates the column(s) or a character vector specifies
58
+column name(s). By default, the 1st dimension/column will be used.
59 59
 Only used when "reducedDims" slotName is selected. Default NULL.}
60 60
 
61 61
 \item{groupBy}{Groupings for each numeric value. A user may input a vector
... ...
@@ -24,7 +24,7 @@ runClusterSummaryMetrics(
24 24
 
25 25
 \item{groupNames}{The name of a colData entry that can be used as groupNames.}
26 26
 
27
-\item{scale}{Option to scale the data. Default: /code{FALSE}. Selected assay will not be scaled.}
27
+\item{scale}{Option to scale the data. Default: \code{FALSE}. Selected assay will not be scaled.}
28 28
 }
29 29
 \value{
30 30
 A dataframe with mean expression and percent of cells in cluster that 
... ...
@@ -58,6 +58,7 @@ Uses doubletFinder to determine cells within the dataset
58 58
 }
59 59
 \examples{
60 60
 data(scExample, package = "singleCellTK")
61
+options(future.globals.maxSize = 786432000)
61 62
 sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'")
62 63
 sce <- runDoubletFinder(sce)
63 64
 }
... ...
@@ -63,7 +63,7 @@ details.
63 63
 }
64 64
 \description{
65 65
 Run \link[DropletUtils]{emptyDrops} on the count matrix in the
66
-provided \\linkS4class{SingleCellExperiment} object.
66
+provided \linkS4class{SingleCellExperiment} object.
67 67
 Distinguish between droplets containing cells and ambient RNA in a
68 68
 droplet-based single-cell RNA sequencing experiment.
69 69
 }
... ...
@@ -41,7 +41,7 @@ mouse SEG lists is available with \code{\link[scMerge]{segList}} or
41 41
 
42 42
 \item{kmeansK}{An integer vector. Indicating the kmeans' K-value for each
43 43
 batch (i.e. how many subclusters in each batch should exist), in order to
44
-construct pseudo-replicates. The length of code{kmeansK} needs to be the same
44
+construct pseudo-replicates. The length of \code{kmeansK} needs to be the same
45 45
 as the number of batches. Default \code{NULL}, and this value will be
46 46
 auto-detected by default, depending on \code{cellType}.}
47 47
 
... ...
@@ -8,6 +8,9 @@ sampleVector <- c(rep("Sample1", 100), rep("Sample2", 95))
8 8
 sceres <- runQuickUMAP(inSCE = sce, sample = sampleVector, nNeighbors = 10,
9 9
                 nIterations = 20, alpha = 1, minDist = 0.01, initialDims = 20)
10 10
 
11
+# allow some additional memory over default
12
+options(future.globals.maxSize = 786432000)
13
+
11 14
 test_that(desc = "Testing plotSCEScatter functions", {
12 15
     p1 <- plotSCEScatter(inSCE = sceres, legendTitle = NULL,
13 16
         slot = "assays", annotation = "counts", feature = "ENSG00000251562",
... ...
@@ -4,6 +4,9 @@ library(ggplot2)
4 4
 context("Testing seurat functions")
5 5
 data(scExample, package = "singleCellTK")
6 6
 
7
+# allow some additional memory over default
8
+options(future.globals.maxSize = 786432000)
9
+
7 10
 test_that(desc = "Testing standard seurat workflow", {
8 11
   # Test Normalization Method
9 12
   sce <- runSeuratNormalizeData(sce)