comparison scripts/generateTestData.Rscript @ 0:4cd9f0008d9c draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/dropletutils/ commit e66ab3d4fc0c1a72523e8f93447cc07cdd6816b7
author iuc
date Tue, 04 Jun 2019 17:19:52 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4cd9f0008d9c
1 ##
2 ## conda install bioconductor-dropletutils bioconductor-dnabarcodes
3 ##
4
5 suppressWarnings(suppressPackageStartupMessages(library(DropletUtils)))
6 suppressWarnings(suppressPackageStartupMessages(library(DNABarcodes)))
7 library(Matrix)
8
9 ## Matrix with no column barcodes
10 set.seed(100)
11 ##my.counts <- DropletUtils:::simCounts()
12 my.counts <- DropletUtils:::simCounts(large.rate=0.01, nlarge=500, nsmall=50, nempty=500)
13
14 ## Generate barcodes (size=10, edit=3) and set as headers
15 barcodes <- create.pool(10)
16 colnames(my.counts) <- barcodes[1:ncol(my.counts)]
17
18 sce <- SingleCellExperiment(assays = list(counts = as.matrix(my.counts)))
19
20 writeTSV <- function(fileout, obj){
21 write.table(as.matrix(obj), file=fileout, col.names=NA, sep='\t', quote=FALSE)
22 }
23
24 writeOut <- function(counts, fileout, typeout){
25 if (typeout == "tsv"){
26 writeTSV(fileout, counts)
27 }
28 else if (typeout == "h5ad"){
29 write10xCounts(fileout, counts, type="HDF5", overwrite=TRUE)
30 }
31 else if (typeout == "directory"){
32 write10xCounts(fileout, Matrix(counts), type="sparse", overwrite=TRUE)
33 }
34 }
35
36 writeOut(Matrix(counts(sce)), "test-data", type="directory")
37 writeOut(counts(sce), "test-data.h5ad", type="h5ad")
38 writeOut(counts(sce), "test-data.tsv", type="tsv")