-
Notifications
You must be signed in to change notification settings - Fork 12
Update flash_init.R #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update flash_init.R #137
Conversation
|
@YushaLiu I'm just summarizing the changes that @willwerscheid has requested:
I believe if you update your fork, the changes will automatically be reflected in this Pull Request. |
|
@YushaLiu It isn't quite clear from your description what Y2 should be; maybe you can give a simple example in R code of how to set Y2 naively? Is Y2 supposed to be a matrix, vector, or scalar? |
|
@pcarbo I updated the description. Does it look clear now? |
|
Looks okay to me now, thanks. @willwerscheid I'll let you take care of the merge when you are okay with Yusha's changes. |
|
thanks, looks much better. this part is not accurate though: #' rather than having \code{flashier} compute \code{Y2}, which involves explicitly flashier does not do this - if a low-rank representation Y = XX' is used then Y2 is computed as sum(X * (X(X’X)) [edited] - see sq.nmode.prod.r1.lowrank() in data_lowrank.R. So I guess now I am wondering whether we actually need this change? This calculation should not be too different from what you suggest doing in the example (it is done this way in case Y = X_1 X_2' with X_1 \ne X_2). But I did notice that we might be using base crossprod instead of Matrix::crossprod... maybe that is causing your issues? Or maybe we need to handle the special case where X_1 = X_2? What do you think @pcarbo @YushaLiu ? I would like to avoid adding an argument to flash_init() if we can instead automatically calculate Y2 more efficiently. |
|
I agree with you @willwerscheid, especially if it is an easy fix! |
|
The issue is that X(X'X) is not in fact sparse so the current method for computing Y2 is indeed very inefficient. We should handle the case where X_1 = X_2 separately (since it can then be computed very efficiently); we should also see whether it is possible to do the general case and still preserve sparsity. |
|
Also, should you be using if (n == 1)
return(Matrix::rowSums(lr[[1]] * (x[[1]] %*% crossprod(x[[2]], u))))
if (n == 2)
return(Matrix::rowSums(lr[[2]] * (x[[2]] %*% t(crossprod(u, x[[1]]))))) |
|
Matrix::crossprod is in the NAMESPACE already; I think we can actually remove Matrix:: from the call to rowSums() |
|
Hm, not sure, but you may have to be explicit since |
Well, X'X is typically not sparse (i.e., has many nonzeros). Just to be absolutely clear: |
|
The term "sparse matrix" is ambiguous here because it could refer to a sparse matrix object (e.g., "dgCMatrix" class), or a matrix that has a high proportion of nonzeros. And I think you are referring to both at different times. (So am I.) |
|
I didn't follow all the conversations above, but I'm curious if there is a way to calculate Also, I personally feel that calculating |
A minor edit to allow
flash_initto take a value for Y2 rather than haveflashiercompute it, which throws out the errorCHOLMOD error 'problem too large'when the number of cells is too large (e.g., > 100k).