Browse code

Add on Seurat integration

yuan-yin-truly authored on 24/03/2022 20:59:38
Showing 1 changed files

... ...
@@ -213,7 +213,7 @@ library(Seurat)
213 213
 counts <- Read10X("path/to/file")
214 214
 
215 215
 # Convert count matrix to SingleCellExperiment to run on decontX
216
-sce <- SingleCellExperiment(list(counts = counts)). 
216
+sce <- SingleCellExperiment(list(counts = counts))
217 217
 sce <- decontX(sce)
218 218
 
219 219
 # Retrieve decontaminated matrix, round to integer, and convert to Seurat object
... ...
@@ -222,6 +222,14 @@ decontaminated.counts <- round(decontaminated.matrix)
222 222
 seuratObject <- CreateSeuratObject(decontaminated.counts)
223 223
 ```
224 224
 
225
+Conversely, if you have a Seurat object containing raw count matrix and would like to run decontX, simply retrieve the count matrix, convert to SingleCellExperiment, and run on decontX.
226
+
227
+```{r seuratIntegration2, eval=FALSE}
228
+counts <- seurat@assays$RNA@counts
229
+sce <- SingleCellExperiment(list(counts = counts))
230
+sce <- decontX(sce)
231
+```
232
+
225 233
 
226 234
 To import datasets into SingleCellExperiment object, the [singleCellTK](https://bioconductor.org/packages/release/bioc/html/singleCellTK.html) package has several importing functions for different preprocessing tools including CellRanger, STARsolo, BUStools, Optimus, DropEST, SEQC, and Alevin/Salmon. For example, the following code can be used as a template to read in the filtered and raw matrices for multiple samples processed with CellRanger:
227 235