Closed fenghuijian closed 5 years ago
Hello,
The data used as input to PCA is stored in sam.adata.uns['X_processed']
. Note that this particular matrix has already been standardized/normalized prior to PCA.
If you would like the full expression matrix rescaled by all the weights, without standardization, then you'll have to calculate it yourself:
w = sam.adata.var['weights'].get_values()
weighted_matrix = sam.adata.X.multiply(w).tocsr()
So, Doesn't the gene expression matrix get iterated? I think the gene expression matrix gets iterated.
The gene weights get iterated. Each iteration, they are used to rescale the original gene expression matrix prior to PCA.
So, sam.adata.X
is the weighted gene expression matrix for n-1
iterations, right? (n is the number of iterations)
sam.adata.X
is the original expression matrix which gets rescaled by the weights prior to PCA. The weights and the nearest neighbor graph are the only objects getting updated each iteration.
weighted_matrix = sam.adata.X.multiply(w).tocsr()
This function is just multiplying the weights by the original expression matrix. And it isn't the weight gene expression matrix of the last iteration.
Those weights are the output of the final iteration! SAM iteratively updates the gene weights and nearest neighbor graph -- not the expression data. To get the weighted gene expression matrix used in the last iteration, simply multiply those weights into the gene expression matrix. Sorry for the confusion.
Thank you very much for your reply
Hi! How do I extract the weighted gene expression matrix. The
sam.adata.X
should be the input gene expression matrix