Merge multiple 10x mtx file sets into one set

rcpp_mmutil_merge_file_sets(
  r_headers = NULL,
  r_batches = NULL,
  r_mtx_files = NULL,
  r_row_files = NULL,
  r_col_files = NULL,
  r_fixed_rows = NULL,
  output = "output",
  nnz_cutoff = 1,
  delim = "_",
  MAX_ROW_WORD = 2L,
  ROW_WORD_SEP = "_",
  MAX_COL_WORD = 100L,
  COL_WORD_SEP = "@"
)

Arguments

r_headers

file set headers

r_batches

unique batch names for each header

r_mtx_files

A list of mtx files

r_row_files

A list of row files

r_col_files

A list of col files

r_fixed_rows

A list of rows/features

output

output file header

nnz_cutoff

number of non-zero cutoff for columns

delim

delimiter in the column name

Value

a list of file names: output.mtx,rows,cols.gz

Examples


options(stringsAsFactors=FALSE)
rr <- rgamma(10, 1, 1) # ten cells
mm <- matrix(rgamma(10 * 3, 1, 1), 10, 3)
t1 <- mmutilR::rcpp_mmutil_simulate_poisson(mm, rr, "test1")
t2 <- mmutilR::rcpp_mmutil_simulate_poisson(mm, rr, "test2")
bats <- hdrs <- c("test1","test2")
t3 <- mmutilR::rcpp_mmutil_merge_file_sets(
                      hdrs, bats, output = "test3", nnz_cutoff = 0)
A1 <- Matrix::readMM(t1$mtx);
rownames(A1) <- unlist(read.table(gzfile(t1$row)))
A2 <- Matrix::readMM(t2$mtx)
rownames(A2) <- unlist(read.table(gzfile(t2$row)))
A3 <- Matrix::readMM(t3$mtx)
rownames(A3) <- unlist(read.table(gzfile(t3$row)))
print(cbind(A1, A2))
#> 10 x 18 sparse Matrix of class "dgTMatrix"
#>                                        
#> r01 . . . . . . . . . . . . . . . . . .
#> r02 . . . . . . . . . . . . . . . . . .
#> r03 . 1 4 2 . 1 . . . . 1 4 2 . 1 . . .
#> r04 . . . . . . . . . . . . . . . . . .
#> r05 . 1 2 . 1 4 1 . . . 1 2 . 1 4 1 . .
#> r06 1 . 3 . 1 6 1 1 . 1 . 3 . 1 6 1 1 .
#> r07 1 1 . 1 . . . . . 1 1 . 1 . . . . .
#> r08 2 1 2 . . 4 2 1 . 2 1 2 . . 4 2 1 .
#> r09 . . 1 . . . . . . . . 1 . . . . . .
#> r10 . . 1 . . . . . 1 . . 1 . . . . . 1
print(A3)
#> 10 x 18 sparse Matrix of class "dgTMatrix"
#>                                        
#> r01 . . . . . . . . . . . . . . . . . .
#> r02 . . . . . . . . . . . . . . . . . .
#> r03 . 1 4 2 . 1 . . . . 1 4 2 . 1 . . .
#> r04 . . . . . . . . . . . . . . . . . .
#> r05 . 1 2 . 1 4 1 . . . 1 2 . 1 4 1 . .
#> r06 1 . 3 . 1 6 1 1 . 1 . 3 . 1 6 1 1 .
#> r07 1 1 . 1 . . . . . 1 1 . 1 . . . . .
#> r08 2 1 2 . . 4 2 1 . 2 1 2 . . 4 2 1 .
#> r09 . . 1 . . . . . . . . 1 . . . . . .
#> r10 . . 1 . . . . . 1 . . 1 . . . . . 1
unlink(list.files(pattern = "test1"))
unlink(list.files(pattern = "test2"))
unlink(list.files(pattern = "test3"))