view scripts/generateTestData.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
line wrap: on
line source

##
## conda install bioconductor-dropletutils bioconductor-dnabarcodes
##

suppressWarnings(suppressPackageStartupMessages(library(DropletUtils)))
suppressWarnings(suppressPackageStartupMessages(library(DNABarcodes)))
library(Matrix)

## Matrix with no column barcodes
set.seed(100)
##my.counts <- DropletUtils:::simCounts()
my.counts <- DropletUtils:::simCounts(large.rate=0.01, nlarge=500, nsmall=50, nempty=500)

## Generate barcodes (size=10, edit=3) and set as headers
barcodes <- create.pool(10)
colnames(my.counts) <- barcodes[1:ncol(my.counts)]

sce <- SingleCellExperiment(assays = list(counts = as.matrix(my.counts)))

writeTSV <- function(fileout, obj){
    write.table(as.matrix(obj), file=fileout, col.names=NA, sep='\t', quote=FALSE)
}

writeOut <- function(counts, fileout, typeout){
    if (typeout == "tsv"){
        writeTSV(fileout, counts)
    }
    else if (typeout == "h5ad"){
        write10xCounts(fileout, counts, type="HDF5", overwrite=TRUE)
    }
    else if (typeout == "directory"){
        write10xCounts(fileout, Matrix(counts), type="sparse", overwrite=TRUE)
    }
}

writeOut(Matrix(counts(sce)), "test-data", type="directory")
writeOut(counts(sce), "test-data.h5ad", type="h5ad")
writeOut(counts(sce), "test-data.tsv", type="tsv")