KrishnaswamyLab / MAGIC

MAGIC (Markov Affinity-based Graph Imputation of Cells), is a method for imputing missing values restoring structure of large biological datasets.
GNU General Public License v2.0
341 stars 97 forks source link

R package of magic #59

Closed bvieth closed 6 years ago

bvieth commented 6 years ago

Hello,

I would like to know if the R version of magic is under construction since I ran into a couple of errors.

Firstly, the R function is missing @import or @importFrom statements and therefore an entry in the NAMESPACE file, so that one needs to manually load the R packages listed under Imports of the DESCRIPTION file. In line of this problem, the functions developed for sparseMatrix objects from Matrix are not properly called, e.g. transpose function t(). This problem can be avoided by explicitly specifying the namespace of the functions, e.g. Matrix::t(). #60 Secondly, while running the function line by line, I found that the Markov normalization ( W <- W / rowSums(W) ) creates a large vector and my local desktop R is not able to handle that (memory limits). It runs on our number crunchers, though. Also the subsequent conversion of as.matrix(W), creates a 2.4 Gb matrix. I was testing magic on a medium sized matrix with 18000 genes measured across 58 cells. Lastly, the diffusion step ( W_t <- W %^% t ) throws an error (Error in W %^% t : could not find function "%^%"). I have to say, I have never seen this operator in R before.

Kind regards Beate

pkathail commented 6 years ago

Hi Beate, The R version of MAGIC was very recently implemented, so definitely might still contain some bugs. I'll update the DESCRIPTION and NAMESPACE with the suggestions you mentioned. The %^% function is implemented in our source code, in run_magic.R, so that error might also be a namespace issue.

As to the memory issue, I've been testing it with a matrix of about 20,000 genes x 4000 cells, and haven't run into any issues yet running it locally, so I'm not sure what the issue is there. Sorry I can't be of more help, but if you figure out what the problem is, please let me know so we can figure out a fix!

pkathail commented 6 years ago

Pushed a change that I think should fix some of these issues, please let me know if you're still having problems.