pneuvial / c3co

Inferring cancer cell clonality from copy-number data
5 stars 1 forks source link

get.W(..., type=2L): Re-implement ridge regularization to control amount of added jitter (currently eps=1e-08) #72

Closed HenrikBengtsson closed 5 years ago

HenrikBengtsson commented 5 years ago

Extracted from https://github.com/pneuvial/c3co/issues/58#issuecomment-465957716 on 2019-02-21 where @jchiquet wrote:

Later, we might tweak the following to call quadprog by ourselves and then control the amount of ridge regularization (here arbitrarily set to 1e-8):

else if (type == 2) {
        if (!is.null(Wx)) 
            stop("cannot solve least squares problem - weights not implemented for type 2")
        if (!is.null(Wa)) 
            stop("cannot solve least squares problem - weights not implemented for type 2")
        dvec <- crossprod(A, B)
        Dmat <- crossprod(A, A)
        diag(Dmat) <- diag(Dmat) + 1e-08
        Amat <- t(rbind(E, G))
        bvec <- c(F, H)
        sol <- solve.QP(Dmat, dvec, Amat, bvec, meq = Neq)
        sol$IsError <- FALSE
        sol$X <- sol$solution
    }