Browse code

Added more unit tests

Yichen Wang authored on 28/06/2022 20:51:30
Showing1 changed files
... ...
@@ -44,7 +44,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
44 44
     } else if (entry$type == "starSolo") {
45 45
       newSce <- importSTARsolo(
46 46
         STARsoloDirs = entry$params$STARsoloDirs,
47
-        samples = entry$params$amples,
47
+        samples = entry$params$samples,
48 48
         delayedArray = delayedArray
49 49
       )
50 50
     } else if (entry$type == "busTools") {
... ...
@@ -96,7 +96,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
96 96
       }
97 97
 
98 98
     }
99
-    
99
+
100 100
     # Begin Set Tags
101 101
     if(entry$type %in% c("cellRanger2", "cellRanger3", "starSolo", "busTools", "seqc", "optimus", "example")){
102 102
       newSce <- expSetDataTag(
... ...
@@ -114,7 +114,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
114 114
             assayType = "raw",
115 115
             assays = "counts")
116 116
         }, silent = TRUE)
117
-        
117
+
118 118
         try({
119 119
           logcounts(newSce)
120 120
           newSce <- expSetDataTag(
... ...
@@ -122,7 +122,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
122 122
             assayType = "transformed",
123 123
             assays = "logcounts")
124 124
         }, silent = TRUE)
125
-        
125
+
126 126
         try({
127 127
           normcounts(newSce)
128 128
           newSce <- expSetDataTag(
... ...
@@ -130,7 +130,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
130 130
             assayType = "transformed",
131 131
             assays = "normcounts")
132 132
         }, silent = TRUE)
133
-        
133
+
134 134
         try({
135 135
           celda::decontXcounts(newSce)
136 136
           newSce <- expSetDataTag(
... ...
@@ -138,21 +138,21 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
138 138
             assayType = "raw",
139 139
             assays = "decontXcounts")
140 140
         }, silent = TRUE)
141
-        
141
+
142 142
         untaggedAssays <- SummarizedExperiment::assayNames(newSce)
143 143
         untaggedAssays <- untaggedAssays[! untaggedAssays %in% c('counts', 'logcounts', 'normcounts', 'decontX')]
144
-        
144
+
145 145
         newSce <- expSetDataTag(
146 146
           inSCE = newSce,
147 147
           assayType = "uncategorized",
148
-          assays = untaggedAssays) 
148
+          assays = untaggedAssays)
149 149
       }
150 150
       # End Set Tags
151 151
     }
152
-    
152
+
153 153
     sceObjs = c(sceObjs, list(newSce))
154 154
   }
155
-  
155
+
156 156
   return(combineSCE(sceList = sceObjs,
157 157
                     by.r = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(rowData(x))})),
158 158
                     by.c = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
Browse code

Fix UI bug: set Ref for cellRangerV2 importing

Yichen Wang authored on 09/11/2021 16:39:22
Showing1 changed files
... ...
@@ -21,7 +21,8 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
21 21
           cellRangerDirs = entry$params$cellRangerDirs,
22 22
           sampleDirs = entry$params$sampleDirs,
23 23
           sampleNames = entry$params$sampleNames,
24
-          delayedArray = delayedArray
24
+          delayedArray = delayedArray,
25
+          reference = entry$params$reference
25 26
         )
26 27
       }
27 28
 
Browse code

BiocCheck fixing errors/warnings!

Irzam Sarfraz authored on 14/10/2021 10:24:48
Showing1 changed files
... ...
@@ -105,7 +105,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
105 105
     }
106 106
     else if(entry$type %in% c("rds", "files")){
107 107
       # Check if tags already stored in uploaded rds/files
108
-      if(is.null(metadata(newSce)$assayType)){
108
+      if(is.null(S4Vectors::metadata(newSce)$assayType)){
109 109
         try({
110 110
           counts(newSce)
111 111
           newSce <- expSetDataTag(
Browse code

Introducing bioc error to test if bioccheck breaks!

Irzam Sarfraz authored on 14/10/2021 10:12:03
Showing1 changed files
... ...
@@ -105,7 +105,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
105 105
     }
106 106
     else if(entry$type %in% c("rds", "files")){
107 107
       # Check if tags already stored in uploaded rds/files
108
-      if(is.null(S4Vectors::metadata(newSce)$assayType)){
108
+      if(is.null(metadata(newSce)$assayType)){
109 109
         try({
110 110
           counts(newSce)
111 111
           newSce <- expSetDataTag(
Browse code

Fixed BioC errors & warnings

Irzam Sarfraz authored on 13/10/2021 17:56:28
Showing1 changed files
... ...
@@ -101,11 +101,11 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
101 101
       newSce <- expSetDataTag(
102 102
         inSCE = newSce,
103 103
         assayType = "raw",
104
-        assays = assayNames(newSce))
104
+        assays = SummarizedExperiment::assayNames(newSce))
105 105
     }
106 106
     else if(entry$type %in% c("rds", "files")){
107 107
       # Check if tags already stored in uploaded rds/files
108
-      if(is.null(metadata(newSce)$assayType)){
108
+      if(is.null(S4Vectors::metadata(newSce)$assayType)){
109 109
         try({
110 110
           counts(newSce)
111 111
           newSce <- expSetDataTag(
... ...
@@ -131,14 +131,14 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
131 131
         }, silent = TRUE)
132 132
         
133 133
         try({
134
-          decontXcounts(newSce)
134
+          celda::decontXcounts(newSce)
135 135
           newSce <- expSetDataTag(
136 136
             inSCE = newSce,
137 137
             assayType = "raw",
138 138
             assays = "decontXcounts")
139 139
         }, silent = TRUE)
140 140
         
141
-        untaggedAssays <- assayNames(newSce)
141
+        untaggedAssays <- SummarizedExperiment::assayNames(newSce)
142 142
         untaggedAssays <- untaggedAssays[! untaggedAssays %in% c('counts', 'logcounts', 'normcounts', 'decontX')]
143 143
         
144 144
         newSce <- expSetDataTag(
Browse code

Updated tags

Irzam Sarfraz authored on 09/10/2021 21:13:47
Showing1 changed files
... ...
@@ -95,8 +95,63 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
95 95
       }
96 96
 
97 97
     }
98
+    
99
+    # Begin Set Tags
100
+    if(entry$type %in% c("cellRanger2", "cellRanger3", "starSolo", "busTools", "seqc", "optimus", "example")){
101
+      newSce <- expSetDataTag(
102
+        inSCE = newSce,
103
+        assayType = "raw",
104
+        assays = assayNames(newSce))
105
+    }
106
+    else if(entry$type %in% c("rds", "files")){
107
+      # Check if tags already stored in uploaded rds/files
108
+      if(is.null(metadata(newSce)$assayType)){
109
+        try({
110
+          counts(newSce)
111
+          newSce <- expSetDataTag(
112
+            inSCE = newSce,
113
+            assayType = "raw",
114
+            assays = "counts")
115
+        }, silent = TRUE)
116
+        
117
+        try({
118
+          logcounts(newSce)
119
+          newSce <- expSetDataTag(
120
+            inSCE = newSce,
121
+            assayType = "transformed",
122
+            assays = "logcounts")
123
+        }, silent = TRUE)
124
+        
125
+        try({
126
+          normcounts(newSce)
127
+          newSce <- expSetDataTag(
128
+            inSCE = newSce,
129
+            assayType = "transformed",
130
+            assays = "normcounts")
131
+        }, silent = TRUE)
132
+        
133
+        try({
134
+          decontXcounts(newSce)
135
+          newSce <- expSetDataTag(
136
+            inSCE = newSce,
137
+            assayType = "raw",
138
+            assays = "decontXcounts")
139
+        }, silent = TRUE)
140
+        
141
+        untaggedAssays <- assayNames(newSce)
142
+        untaggedAssays <- untaggedAssays[! untaggedAssays %in% c('counts', 'logcounts', 'normcounts', 'decontX')]
143
+        
144
+        newSce <- expSetDataTag(
145
+          inSCE = newSce,
146
+          assayType = "uncategorized",
147
+          assays = untaggedAssays) 
148
+      }
149
+      # End Set Tags
150
+    }
151
+    
98 152
     sceObjs = c(sceObjs, list(newSce))
99 153
   }
154
+  
100 155
   return(combineSCE(sceList = sceObjs,
101 156
                     by.r = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(rowData(x))})),
102 157
                     by.c = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
Browse code

UI update for previous related DE function update; plus many minor bug fixes

Yichen Wang authored on 17/03/2021 16:51:52
Showing1 changed files
... ...
@@ -24,7 +24,7 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
24 24
           delayedArray = delayedArray
25 25
         )
26 26
       }
27
-      
27
+
28 28
     } else if (entry$type == "cellRanger3") {
29 29
       if (is.null(entry$params$cellRangerDirs)) {
30 30
         newSce <- importCellRangerV3Sample(
... ...
@@ -93,11 +93,10 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
93 93
           SummarizedExperiment::assay(newSce, assay) <- DelayedArray::DelayedArray(SummarizedExperiment::assay(newSce, assay))
94 94
         }
95 95
       }
96
-      
96
+
97 97
     }
98 98
     sceObjs = c(sceObjs, list(newSce))
99 99
   }
100
-  
101 100
   return(combineSCE(sceList = sceObjs,
102 101
                     by.r = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(rowData(x))})),
103 102
                     by.c = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
Browse code

Update importMitoGeneSet function. Change delayedArray=False for all import function. Minor fixs in QC HTML report

rz2333 authored on 30/12/2020 17:40:20
Showing1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 #' Imports samples from different sources and compiles them into a list of SCE objects
3 3
 #' @param allImportEntries object containing the sources and parameters of all the samples being imported (from the UI)
4 4
 #' @param delayedArray Boolean. Whether to read the expression matrix as
5
-#'  \link{DelayedArray} object or not. Default \code{TRUE}.
5
+#'  \link{DelayedArray} object or not. Default \code{FALSE}.
6 6
 #' @return A list of \link[SingleCellExperiment]{SingleCellExperiment} object containing
7 7
 #' the droplet or cell data or both,depending on the dataType that users provided.
8 8
 #' @export
Browse code

Edit links to documentation

unknown authored on 22/10/2020 03:39:09
Showing1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 #' Imports samples from different sources and compiles them into a list of SCE objects
3 3
 #' @param allImportEntries object containing the sources and parameters of all the samples being imported (from the UI)
4 4
 #' @param delayedArray Boolean. Whether to read the expression matrix as
5
-#'  \link[DelayedArray]{DelayedArray} object or not. Default \code{TRUE}.
5
+#'  \link{DelayedArray} object or not. Default \code{TRUE}.
6 6
 #' @return A list of \link[SingleCellExperiment]{SingleCellExperiment} object containing
7 7
 #' the droplet or cell data or both,depending on the dataType that users provided.
8 8
 #' @export
Browse code

Fix bugs in importMultipleSources.R. Update QC documentation

rz2333 authored on 19/10/2020 02:08:45
Showing1 changed files
... ...
@@ -85,12 +85,12 @@ importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
85 85
       }
86 86
 
87 87
       for(assay in SummarizedExperiment::assayNames(newSce)) {
88
-        if(!base::inherits(SummarizedExperiment::assay(sce, assay), "dgCMatrix") && !isTRUE(delayedArray)) {
89
-          SummarizedExperiment::assay(sce, assay) <- .convertToMatrix(SummarizedExperiment::assay(sce, assay))
88
+        if(!base::inherits(SummarizedExperiment::assay(newSce, assay), "dgCMatrix") && !isTRUE(delayedArray)) {
89
+          SummarizedExperiment::assay(newSce, assay) <- .convertToMatrix(SummarizedExperiment::assay(newSce, assay))
90 90
         }
91 91
 
92
-        if(!base::inherits(SummarizedExperiment::assay(sce, assay), "DelayedArray") && isTRUE(delayedArray)) {
93
-          SummarizedExperiment::assay(sce, assay) <- DelayedArray::DelayedArray(SummarizedExperiment::assay(sce, assay))
92
+        if(!base::inherits(SummarizedExperiment::assay(newSce, assay), "DelayedArray") && isTRUE(delayedArray)) {
93
+          SummarizedExperiment::assay(newSce, assay) <- DelayedArray::DelayedArray(SummarizedExperiment::assay(newSce, assay))
94 94
         }
95 95
       }
96 96
       
Browse code

merge master into sctk_qc

rz2333 authored on 15/10/2020 20:55:34
Showing0 changed files
Browse code

Update SCTK_QC, importAnnData and sce2adata.R

rz2333 authored on 15/10/2020 16:02:58
Showing1 changed files
... ...
@@ -4,7 +4,7 @@
4 4
 #' @return A list of \link[SingleCellExperiment]{SingleCellExperiment} object containing
5 5
 #' the droplet or cell data or both,depending on the dataType that users provided.
6 6
 #' @export
7
-importMultipleSources <- function(allImportEntries) {
7
+importMultipleSources <- function(allImportEntries, delayedArray = FALSE) {
8 8
   sceObjs <- list()
9 9
   for (entry in allImportEntries$samples) {
10 10
     if (entry$type == "cellRanger2") {
... ...
@@ -12,12 +12,14 @@ importMultipleSources <- function(allImportEntries) {
12 12
         newSce <- importCellRangerV2Sample(
13 13
           dataDir = entry$params$dataDir,
14 14
           sampleName = entry$params$sampleName,
15
+          delayedArray = delayedArray
15 16
         )
16 17
       } else {
17 18
         newSce <- importCellRangerV2(
18 19
           cellRangerDirs = entry$params$cellRangerDirs,
19 20
           sampleDirs = entry$params$sampleDirs,
20 21
           sampleNames = entry$params$sampleNames,
22
+          delayedArray = delayedArray
21 23
         )
22 24
       }
23 25
       
... ...
@@ -26,42 +28,50 @@ importMultipleSources <- function(allImportEntries) {
26 28
         newSce <- importCellRangerV3Sample(
27 29
           dataDir = entry$params$dataDir,
28 30
           sampleName = entry$params$sampleName,
31
+          delayedArray = delayedArray
29 32
         )
30 33
       } else {
31 34
         newSce <- importCellRangerV3(
32 35
           cellRangerDirs = entry$params$cellRangerDirs,
33 36
           sampleDirs = entry$params$sampleDirs,
34 37
           sampleNames = entry$params$sampleNames,
38
+          delayedArray = delayedArray
35 39
         )
36 40
       }
37 41
     } else if (entry$type == "starSolo") {
38 42
       newSce <- importSTARsolo(
39 43
         STARsoloDirs = entry$params$STARsoloDirs,
40
-        samples = entry$params$amples
44
+        samples = entry$params$amples,
45
+        delayedArray = delayedArray
41 46
       )
42 47
     } else if (entry$type == "busTools") {
43 48
       newSce <- importBUStools(
44 49
         BUStoolsDirs = entry$params$BUStoolsDirs,
45 50
         samples = entry$params$samples,
51
+        delayedArray = delayedArray
46 52
       )
47 53
     } else if (entry$type == "seqc") {
48 54
       newSce <- importSEQC(
49 55
         seqcDirs = entry$params$seqcDirs,
50 56
         samples = entry$params$samples,
51 57
         prefix = entry$params$prefix,
58
+        delayedArray = delayedArray
52 59
       )
53 60
     } else if (entry$type == "optimus") {
54 61
       newSce <- importOptimus(
55 62
         OptimusDirs = entry$params$OptimusDirs,
56
-        samples = entry$params$samples
63
+        samples = entry$params$samples,
64
+        delayedArray = delayedArray
57 65
       )
58 66
     } else if (entry$type == "files") {
59 67
       newSce <- importFromFiles(assayFile = entry$params$assayFile,
60 68
                                 annotFile = entry$params$annotFile,
61 69
                                 featureFile = entry$params$featureFile,
62
-                                assayName = entry$params$assayName)
70
+                                assayName = entry$params$assayName,
71
+                                delayedArray = delayedArray)
63 72
     } else if (entry$type == "example") {
64
-      newSce <- importExampleData(dataset = entry$params$dataset)
73
+      newSce <- importExampleData(dataset = entry$params$dataset,
74
+                                  delayedArray = delayedArray)
65 75
     } else if (entry$type == "rds") {
66 76
       importedrds <- readRDS(entry$params$rdsFile)
67 77
       if (base::inherits(importedrds, "SummarizedExperiment")) {
... ...
@@ -71,13 +81,24 @@ importMultipleSources <- function(allImportEntries) {
71 81
       } else {
72 82
         stop("The '.rds' file should contain a 'SingleCellExperiment' or 'Seurat' object.")
73 83
       }
84
+
85
+      for(assay in SummarizedExperiment::assayNames(newSce)) {
86
+        if(!base::inherits(SummarizedExperiment::assay(sce, assay), "dgCMatrix") && !isTRUE(delayedArray)) {
87
+          SummarizedExperiment::assay(sce, assay) <- .convertToMatrix(SummarizedExperiment::assay(sce, assay))
88
+        }
89
+
90
+        if(!base::inherits(SummarizedExperiment::assay(sce, assay), "DelayedArray") && isTRUE(delayedArray)) {
91
+          SummarizedExperiment::assay(sce, assay) <- DelayedArray::DelayedArray(SummarizedExperiment::assay(sce, assay))
92
+        }
93
+      }
94
+      
74 95
     }
75 96
     sceObjs = c(sceObjs, list(newSce))
76 97
   }
77 98
   
78 99
   return(combineSCE(sceList = sceObjs,
79
-                    by.r = NULL,
80
-                    by.c = Reduce(intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
100
+                    by.r = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(rowData(x))})),
101
+                    by.c = Reduce(base::intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
81 102
                     combined = TRUE)
82 103
   )
83 104
 }
Browse code

Changed all T/F to TRUE/FALSE

Joshua D. Campbell authored on 13/10/2020 02:45:44
Showing1 changed files
... ...
@@ -78,7 +78,7 @@ importMultipleSources <- function(allImportEntries) {
78 78
   return(combineSCE(sceList = sceObjs,
79 79
                     by.r = NULL,
80 80
                     by.c = Reduce(intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
81
-                    combined = T)
81
+                    combined = TRUE)
82 82
   )
83 83
 }
84 84
 
Browse code

Updated description in DESCRIPTION. Moved importMultipleSources to its own file and removed some shiny code. Updated docs.

Joshua D. Campbell authored on 12/10/2020 18:25:27
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,84 @@
1
+
2
+#' Imports samples from different sources and compiles them into a list of SCE objects
3
+#' @param allImportEntries object containing the sources and parameters of all the samples being imported (from the UI)
4
+#' @return A list of \link[SingleCellExperiment]{SingleCellExperiment} object containing
5
+#' the droplet or cell data or both,depending on the dataType that users provided.
6
+#' @export
7
+importMultipleSources <- function(allImportEntries) {
8
+  sceObjs <- list()
9
+  for (entry in allImportEntries$samples) {
10
+    if (entry$type == "cellRanger2") {
11
+      if (is.null(entry$params$cellRangerDirs)) {
12
+        newSce <- importCellRangerV2Sample(
13
+          dataDir = entry$params$dataDir,
14
+          sampleName = entry$params$sampleName,
15
+        )
16
+      } else {
17
+        newSce <- importCellRangerV2(
18
+          cellRangerDirs = entry$params$cellRangerDirs,
19
+          sampleDirs = entry$params$sampleDirs,
20
+          sampleNames = entry$params$sampleNames,
21
+        )
22
+      }
23
+      
24
+    } else if (entry$type == "cellRanger3") {
25
+      if (is.null(entry$params$cellRangerDirs)) {
26
+        newSce <- importCellRangerV3Sample(
27
+          dataDir = entry$params$dataDir,
28
+          sampleName = entry$params$sampleName,
29
+        )
30
+      } else {
31
+        newSce <- importCellRangerV3(
32
+          cellRangerDirs = entry$params$cellRangerDirs,
33
+          sampleDirs = entry$params$sampleDirs,
34
+          sampleNames = entry$params$sampleNames,
35
+        )
36
+      }
37
+    } else if (entry$type == "starSolo") {
38
+      newSce <- importSTARsolo(
39
+        STARsoloDirs = entry$params$STARsoloDirs,
40
+        samples = entry$params$amples
41
+      )
42
+    } else if (entry$type == "busTools") {
43
+      newSce <- importBUStools(
44
+        BUStoolsDirs = entry$params$BUStoolsDirs,
45
+        samples = entry$params$samples,
46
+      )
47
+    } else if (entry$type == "seqc") {
48
+      newSce <- importSEQC(
49
+        seqcDirs = entry$params$seqcDirs,
50
+        samples = entry$params$samples,
51
+        prefix = entry$params$prefix,
52
+      )
53
+    } else if (entry$type == "optimus") {
54
+      newSce <- importOptimus(
55
+        OptimusDirs = entry$params$OptimusDirs,
56
+        samples = entry$params$samples
57
+      )
58
+    } else if (entry$type == "files") {
59
+      newSce <- importFromFiles(assayFile = entry$params$assayFile,
60
+                                annotFile = entry$params$annotFile,
61
+                                featureFile = entry$params$featureFile,
62
+                                assayName = entry$params$assayName)
63
+    } else if (entry$type == "example") {
64
+      newSce <- importExampleData(dataset = entry$params$dataset)
65
+    } else if (entry$type == "rds") {
66
+      importedrds <- readRDS(entry$params$rdsFile)
67
+      if (base::inherits(importedrds, "SummarizedExperiment")) {
68
+        newSce <- importedrds
69
+      } else if (base::inherits(importedrds, "Seurat")) {
70
+        newSce <- convertSeuratToSCE(importedrds)
71
+      } else {
72
+        stop("The '.rds' file should contain a 'SingleCellExperiment' or 'Seurat' object.")
73
+      }
74
+    }
75
+    sceObjs = c(sceObjs, list(newSce))
76
+  }
77
+  
78
+  return(combineSCE(sceList = sceObjs,
79
+                    by.r = NULL,
80
+                    by.c = Reduce(intersect, lapply(sceObjs, function(x) { colnames(colData(x))})),
81
+                    combined = T)
82
+  )
83
+}
84
+