Thank you so much. It's really helpful!
Hi there,
Briefly, I know NMF (non-negative matrix factorization) as modeling the matrix X of expression for g genes and s samples, constituting the product of a matrix G of g gene weights for k factors and a matrix S of s sample weights for k factors.
And I want to derive the matrix G for selecting genes with high weights for specific NMF factor (cluster). How to get this matrix in NMF()?
Thanks for someone could give me some hints.
1 answer
I think what you want is the W matrix which you can get with the basis command (NMF package), E.g.:
# A matrix of 20 genes and 10 samples
mat<- matrix(runif(n= 200, min= 0, max= 100), nrow= 20, ncol= 10)
library(NMF)
res<- nmf(mat, rank= 2)
w<- basis(res)
h<- coef(res)
w %*% h # ~ mat
dim(w) # 20 2
Hopefully you get the idea. But on reading again your question make sure that what you need is instead the H matrix of the transpose of the expression matrix.
If I have a new dataset with 30 different samples measured by the above 20 genes, how to project the new data into the low-dimensional subspace generated by NMF. Can I just multiplying the w matrix? Thanks in advance.
Hi Dario, I am wondering if it's possible to use an alternative distance except KL or euclidean in nmf() function? Thanks a lot!
Hi- looking at the documentation of nmf (i.e. ?nmf), it appears the parameter method accept a keyword for the distance algorithm. Look at the Algorithm section of the docs for the available ones. E.g. nmf(x, 2, method= 'lee')
Log in to answer this question.