diff scripts/dropletutils.Rscript @ 1:cfe1e6c28d95 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dropletutils/ commit 40d4a92c62d75fe931baba8657cde006a26d84cf"
author iuc
date Mon, 26 Aug 2019 05:06:39 -0400
parents 4cd9f0008d9c
children a8aa294401be
line wrap: on
line diff
--- a/scripts/dropletutils.Rscript	Tue Jun 04 17:19:52 2019 -0400
+++ b/scripts/dropletutils.Rscript	Mon Aug 26 05:06:39 2019 -0400
@@ -6,6 +6,7 @@
 
 suppressWarnings(suppressPackageStartupMessages(require(DropletUtils)))
 suppressWarnings(suppressPackageStartupMessages(require(Matrix)))
+suppressWarnings(suppressPackageStartupMessages(require(scater)))
 
 source(args[1])
 
@@ -34,8 +35,9 @@
 read10xFiles <- function(filein, typein){
     sce <- NULL
     if (typein == "tsv"){
-        dat <- read.table(filein, header = TRUE,  sep='\t', stringsAsFactors=FALSE, quote="", row.names=1)
-        sce <- SingleCellExperiment(assays = list(counts = as.matrix(dat)))
+        ## Exploding memory problems occured here
+        ## - solution is to use the readSparseCounts function from scater
+        sce <- SingleCellExperiment(assays = list(counts = readSparseCounts(filein)))
     }
     else if (typein == "h5ad"){
         sce <- read10xCounts(filein, col.names=T, type="HDF5")   # use barcodes.tsv as column names
@@ -91,7 +93,7 @@
 doDefaultDrops <- function(files, dparams, in.type="directory", out.type="h5ad"){
     sce <- read10xFiles(files$infile, in.type)
 
-    dparams$m = as.matrix(counts(sce))
+    dparams$m = counts(sce)
     called <- do.call(defaultDrops, c(dparams))
     print(table(called))
         
@@ -106,7 +108,7 @@
     sce <- read10xFiles(files$infile, in.type)
 
     bparams$... <- NULL ## hack
-    bparams$m = as.matrix(counts(sce))
+    bparams$m = counts(sce)
 
     br.out <- do.call(barcodeRanks, c(bparams))