shangll123 / SpatialPCA

Spatially aware dimension reduction for spatial transcriptomics.
40 stars 9 forks source link

Question about SpatialPCA_EstimateLoading #6

Closed 0617spec closed 1 year ago

0617spec commented 1 year ago

Hi! Recently I‘ve read your paper and I am interensted in your work. But there is one point I did not understand in SpatialPCA_EstimateLoading.R In SpatialPCA_EstimateLoading.R, from what I understand, W_est_here is used for calculate $\widehat{W}$. $\widehat{W}=LR$ , L is a m by d matrix for the first d eigenvectors of G_each.

W_est_here = eigs_sym(G_each, k=PCnum, which = "LM")$vectors-(-sum_det -(k*(n-q))/2*log(params$tr_YMY+F_funct_sameG(W_est_here,G_each)))

I do not understand what the code (-sum_det -(k*(n-q))/2*log(params$tr_YMY+F_funct_sameG(W_est_here,G_each))) is for. Could you please answer this question for me? Thank you in advance!

shangll123 commented 1 year ago

Hello,

Thank you for your interest in our paper!

Actually, W_est_here = eigs_sym(G_each, k=PCnum, which = "LM")$vectors and (-sum_det -(k*(n-q))/2*log(params$tr_YMY+F_funct_sameG(W_est_here,G_each))) are two separate lines, the first line is to estimate W, and the second line returns the likelihood value. This likelihood function is called through the SpatialPCA_EstimateLoading function and parameters are optimized using "optim" package. I may wrote the two lines too close, sorry about the confusion.

Best, Lulu