Repository 'dropletutils'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/dropletutils

Changeset 3:f0de368eabca (2019-10-15)
Previous changeset 2:a8aa294401be (2019-09-06) Next changeset 4:1797cbe967d1 (2019-12-05)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dropletutils/ commit a4cee4cac5097029188d836d5b904b605dbb943d"
modified:
dropletutils.xml
scripts/dropletutils.Rscript
b
diff -r a8aa294401be -r f0de368eabca dropletutils.xml
--- a/dropletutils.xml Fri Sep 06 10:56:16 2019 -0400
+++ b/dropletutils.xml Tue Oct 15 09:03:56 2019 -0400
b
@@ -3,15 +3,15 @@
     <description>Utilities for handling droplet-based single-cell RNA-seq data</description>
     <macros>
         <token name="@PACKAGE_VERSION@" >1.2.1</token>
-        <token name="@GALAXY_VERSION@" >3</token>
+        <token name="@GALAXY_VERSION@" >4</token>
         <token name="@TXIN@">tenx.input</token>
         <token name="@TXOUT@">tenx.output</token>
         <xml name="test_dirin" >
             <conditional name="tenx_format">
                 <param name="use" value="directory" />
                 <param name="input" value="in_matrix.mtx" />
+                <param name="input_barcodes" value="in_barcodes.tsv" />
                 <param name="input_genes" value="in_genes.tsv" />
-                <param name="input_barcodes" value="in_barcodes.tsv" />
             </conditional>
         </xml>
     </macros>
b
diff -r a8aa294401be -r f0de368eabca scripts/dropletutils.Rscript
--- a/scripts/dropletutils.Rscript Fri Sep 06 10:56:16 2019 -0400
+++ b/scripts/dropletutils.Rscript Tue Oct 15 09:03:56 2019 -0400
[
@@ -19,19 +19,35 @@
     write.table(as.matrix(obj), file=fileout, col.names=NA, sep='\t', quote=FALSE)
 }
 
-writeOut <- function(counts, fileout, typeout){
+determineGeneIDs <- function(object){
+    if (!is.null(rowData(object)$Symbol)){
+        return(rowData(object)$Symbol)
+    }
+    return(rownames(object))
+}
+
+getCounts <- function(object){
+    return(Matrix(counts(object), sparse=TRUE))
+}
+
+writeOut <- function(object, fileout, typeout){
     if (typeout == "tsv"){
-        writeTSV(fileout, counts)
+        writeTSV(fileout, getCounts(object))
     }
     else if (typeout == "h5ad"){
-        write10xCounts(fileout, counts, type="HDF5", overwrite=TRUE)
+        write10xCounts(fileout, getCounts(object),
+                       type="HDF5",
+                       gene.symbol=determineGeneIDs(object),
+                       overwrite=TRUE)
     }
     else if (typeout == "directory"){
-        write10xCounts(fileout, counts, type="sparse", overwrite=TRUE)
+        write10xCounts(fileout, getCounts(object),
+                       type="sparse",
+                       gene.symbol=determineGeneIDs(object),
+                       overwrite=TRUE)
     }
 }
 
-
 read10xFiles <- function(filein, typein){
     sce <- NULL
     if (typein == "tsv"){
@@ -92,7 +108,7 @@
     called[is.na(called)] <- FALSE    # replace NA's with FALSE
     sce.filtered <- sce[,called]
 
-    writeOut(counts(sce.filtered), files$out, out.type)
+    writeOut(sce.filtered, files$out, out.type)
 
     message(paste("Cells:", sum(na.omit(e.out$is.Cell))))
     message(paste("Cells and Limited:", sum(na.omit(e.out$is.CellAndLimited))))
@@ -108,7 +124,7 @@
     # Filtered
     sce.filtered <- sce[,called]
 
-    writeOut(Matrix(counts(sce.filtered),sparse=TRUE), files$out, out.type)
+    writeOut(sce.filtered, files$out, out.type)
 
     message(paste("Cells:", sum(called)))
 }