1+ # ' Create random barcode
2+ random_barcode <- function (size = 10 ) {
3+ paste0(sample(c(" A" , " C" , " T" , " G" ), size , replace = TRUE ), collapse = " " )
4+ }
5+
16# ' Create a sparse count_mat
27# '
38# ' @importFrom Matrix rsparsematrix
4- create_count_mat <- function (rows , cols ) {
9+ create_count_mat <- function (rows , cols , valid_barcodes = FALSE ) {
510 mat <- Matrix :: rsparsematrix(rows , cols , 0.5 , rand.x = function (n ) as.integer(100 * runif(n )))
611
712 rownames <- as.character()
@@ -11,15 +16,46 @@ create_count_mat <- function(rows, cols) {
1116
1217 colnames <- as.character()
1318 if (cols > 0 ) {
14- colnames <- paste0(" col" , 1 : cols )
19+ if (valid_barcodes ) {
20+ colnames <- lapply(rep(10 , cols ), random_barcode )
21+ } else {
22+ colnames <- paste0(" col" , 1 : cols )
23+ }
1524 }
1625
1726 dimnames(mat ) <- list (rownames , colnames )
1827 mat
1928}
2029
30+ # ' Create a dimensional reduction (projection) object
31+ create_dim_reduction <- function (count_mat , key ) {
32+ barcode_count <- dim(count_mat )[2 ]
33+
34+ proj <- create_dense_mat(barcode_count , 2 )
35+
36+ rownames(proj ) <- colnames(count_mat )
37+ colnames(proj ) <- c(paste0(key , 1 ), paste0(key , 2 ))
38+
39+ Seurat :: CreateDimReducObject(
40+ embeddings = proj ,
41+ key = paste0(key , " _" ),
42+ assay = " rna" ,
43+ global = TRUE
44+ )
45+ }
46+
2147# ' Create a dense matrix
2248create_dense_mat <- function (rows , cols ) {
2349 count <- rows * cols
2450 matrix (runif(count ), nrow = rows )
2551}
52+
53+ get_executable_path <- function () {
54+ wd <- getwd()
55+ os <- get_system_os()
56+ if (os == " windows" ) {
57+ return (file.path(wd , " mock_louper.bat" ))
58+ } else {
59+ return (file.path(wd , " mock_louper" ))
60+ }
61+ }
0 commit comments