Giter Site home page Giter Site logo

Comments (8)

plger avatar plger commented on September 20, 2024

good idea, thanks, will do that in the next days!

from scdblfinder.

plger avatar plger commented on September 20, 2024

So the lines you suggested to replace with sumCountsAcrossCells were not summing counts but averaging pca values. For the moment I just replaced names with indexes.
(I changed the other point to a direct bluster call)

from scdblfinder.

LTLA avatar LTLA commented on September 20, 2024

Didn't notice they were PCA values - in that case, you could shorten it down to:

#' @importFrom DelayedArray rowsum DelayedArray
y <- rowsum(DelayedArray(x), k) # DelayArray is only necessary if the reddims might not be ordinary matrices.
y / as.integer(table(k)[rownames(y)]) # subsetting is probably not necessary, but just to be safe. 

This should be more efficient too, based on the comments in ?rowsum examples.

from scdblfinder.

plger avatar plger commented on September 20, 2024

will do. Why the DelayedArray(x)? If we import it, shouldn't R use the DelayedArray rowsum method anyway iff that's what x is?

from scdblfinder.

LTLA avatar LTLA commented on September 20, 2024

If you believe that your reduced dimensions will only be ordinary matrices, then you can get rid of the DelayedArray() (plus the import statements). But if you think that your reduced dimensions might be other matrix-like objects, like sparse matrices or whatever, then the wrapping in a DelayedArray() (plus the imports) will ensure that those are handled correctly. base::rowsum won't handle such weird objects correctly, and DelayedArray::rowsum will only do so if the object is wrapped in a DA.

from scdblfinder.

plger avatar plger commented on September 20, 2024

will only do so if the object is wrapped in a DA.

That's the bit I don't get and would like to understand. This all works fine:

m <- matrix(1:12, nrow=4)
rowsum(m, c(1,1,2,2))
m2 <- as(m,"dgCMatrix")
rowsum(m2, c(1,1,2,2))
m3 <- DelayedArray(m)
rowsum(m3, c(1,1,2,2))

(Also works fine with DelayedArray::rowsum)...)

I'll have to make the whole scDblFinder DelayedArray-friendly...

from scdblfinder.

LTLA avatar LTLA commented on September 20, 2024

Ah. Looks like DA added a rowsum.dgCMatrix, for some reason. Probably because I nagged about it for so long.

Note that other matrices won't work, though:

m2.1 <- as(m, 'dgTMatrix')
rowsum(m2.1, c(1,1,2,2))
## Error in rowsum.default(m2.1, c(1, 1, 2, 2)) : 'x' must be numeric

Of course, none of this is relevant if you think that the reduced dims are going to be ordinary matrices, which they usually are. The DA stuff is primarily important for the assays. Good test is to see whether you can run scDblFinder on one of the small HDF5-backed PBMC datasets in TENxPBMCData without loading everything into memory.

from scdblfinder.

plger avatar plger commented on September 20, 2024

I'm pretty sure it won't run off memory at the moment, I haven't done anything yet to make it DelayedArray-friendly. Now I'm optimizing a few details and DA will be next...

from scdblfinder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.