How to get a matrix gene weights in NMF
1
0
Entering edit mode
6.1 years ago
sugus ▴ 150

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.

NMF weight matrix R • 3.7k views
ADD COMMENT
3
Entering edit mode
6.1 years ago

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
ADD COMMENT
0
Entering edit mode

Thank you so much. It's really helpful!

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Hi Dario, I am wondering if it's possible to use an alternative distance except KL or euclidean in nmf() function? Thanks a lot!

ADD REPLY
0
Entering edit mode

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')

ADD REPLY

Login before adding your answer.

Traffic: 1927 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6