Skip to content

Commit

Permalink
new readEDS code updates to make
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelove committed Aug 7, 2019
1 parent 0943b3d commit c7f4fe4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: tximport
Version: 1.13.11
Version: 1.13.12
Title: Import and summarize transcript-level estimates for transcript- and
gene-level analysis
Description: Imports transcript-level abundance, estimated counts and
Expand Down
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CHANGES IN VERSION 1.13.11
CHANGES IN VERSION 1.13.12
--------------------------

o Alevin count and inferential variance can be imported now
~40x faster for large number of cells, leveraging C++ code
from the fishpond package (>= 1.1.17).
from the fishpond package (>= 1.1.18).

CHANGES IN VERSION 1.13.8
-------------------------
Expand Down
22 changes: 4 additions & 18 deletions R/alevin.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ readAlevin <- function(files, dropInfReps, forceSlow) {
if (!requireNamespace("fishpond", quietly=TRUE)) {
hasFishpond <- FALSE
} else {
if (packageVersion("fishpond") < "1.1.17") {
if (packageVersion("fishpond") < "1.1.18") {
hasFishpond <- FALSE
}
}
if (!hasFishpond)
message("importing alevin data is much faster after installing `fishpond` (>= 1.1.17)")
message("importing alevin data is much faster after installing `fishpond` (>= 1.1.18)")

# for testing purposes, force the use of the slower R code for importing alevin
if (forceSlow) {
Expand Down Expand Up @@ -204,22 +204,8 @@ readAlevinBits <- function(matrix.file, gene.names, cell.names) {
readAlevinFast <- function(matrix.file, gene.names, cell.names) {
num.cells <- length(cell.names)
num.genes <- length(gene.names)

dat <- fishpond::readEDS(matrix.file, num.genes, num.cells)

# `dat$pos + 1` is `gene.idx` in the readAlevinBits() function
len.gene.idx <- lengths(dat$pos)
cell.idx <- rep(seq_along(len.gene.idx), len.gene.idx)

# build sparse matrix
# Note! we add 1 to the 0-based positions returned from fishpond::readEDS()
gene.idx <- unlist(dat$pos) + 1
mat <- Matrix::sparseMatrix(i=gene.idx,
j=cell.idx,
x=unlist(dat$exp),
dims=c(num.genes, num.cells),
dimnames=list(gene.names, cell.names),
giveCsparse=FALSE)
mat <- fishpond::readEDS(num.genes, num.cells, matrix.file)
dimnames(mat) <- list(gene.names, cell.names)
mat
}

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test_alevin.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test_that("import alevin works", {

txi <- tximport(files, type="alevin")

dir <- system.file("extdata", package="tximportData")
files <- file.path(dir,"alevin/neurons_900_v014/alevin/quants_mat.gz")
file.exists(files)

Expand Down

0 comments on commit c7f4fe4

Please sign in to comment.