Giter VIP home page Giter VIP logo

Comments (5)

Alanocallaghan avatar Alanocallaghan commented on August 11, 2024

Seems like a bad idea but also something people would certainly use. I like the weighted average idea, something like

projectReducedDim <- function(old.points, new.points, old.embedding, k = 2) {
    res <- queryKNN(X = old.points, query = new.points, k = k)
    weight <- 1 / res$distance
    weight <- weight / rowSums(weight)
    new.embedding <- sapply(1:ncol(old.embedding), function(i) {
        rowMeans(
            sapply(1:ncol(res$index), function(j) {
                old.embedding[res$index[, j], i] * weight[, j]
            })
        )
    })
    new.embedding
}

I realise there's surely a more elegant way to do the nested loops.

I could also wrap the snifter stuff into scater without a terrible amount of effort.

from scater.

LTLA avatar LTLA commented on August 11, 2024

Check out https://github.com/LTLA/batchelor/blob/master/R/utils_tricube.R for a tricube-weighted average based on the nearest neighbors. Watch out for problems with distances of zero if you're going to use inverse weights.

from scater.

Alanocallaghan avatar Alanocallaghan commented on August 11, 2024

Ooh, perfect. Might just ::: that unless that's deeply frowned on

from scater.

LTLA avatar LTLA commented on August 11, 2024

Probably best to just copy it over, avoid an explicit dependency on batchelor. It's not too large and it should be easy to drag across the few unit tests just in case.

from scater.

Alanocallaghan avatar Alanocallaghan commented on August 11, 2024

Resolved by commit(s) above but feel free to submit feedback/gripes here

from scater.

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.