SofieVG / FlowSOM

Using self-organizing maps for visualization and interpretation of cytometry data
61 stars 26 forks source link

Question som$map$codes #40

Closed fbenedett closed 3 years ago

fbenedett commented 3 years ago

Hello,

I am a bit struggling to understand the details of FlowSOM. Imagine that you have a flow set that you have clustered. som <- BuildSOM(fsom, colsToUse = some_colors ) cell_clustering_som <- som$map$mapping[,1]

So, cell_clustering_som tell us to which cluster a given line of the flow set belongs. If I have: expr_mat=fsApply(fsom,exprs)

What is the relation between expr_mat and som$map$codes? I was thinking that "codes" represent the average expression for a given cluster, so if I do (for instance for cluster 1): apply(expr_mat[cell_clustering_som==1, some_colors],2,mean)) I should get the "codes" for cluster 1, but I don't.

Simply, is there a way to get som$map$codes from cell_clustering_som and expr_mat?

Thank you for any answer.

SofieVG commented 3 years ago

Dear Fabrizio,

The values you get with the method you describe should correspond to som$map$medianValues The codes, however, are the ones gained by training the self-organizing map. This means that during training, one by one cells are presented to the current cluster centers, the closest one is determined, and this one and the ones near it in the grid are updated so the value shifts closer to the value of the cell presented (how much closer etc depending on the algorithm parameters). By iterating this procedure many times (default ten times the amount of cells presented) the cluster centers move to dense regions in the high-dimensional space. In the end, a final iteration is made through all cells to assign them to the closest cluster center without updating the center values anymore. So while these codes representing the cluster centers will be near the cells assigned to it, it will not exactly correspond to the mean / median you are computing. In the FlowSOM visualisations, we make use of the median values per cluster rather than these code values.

Hope this helps! Kind regards, Sofie

On Wed, 23 Dec 2020 at 17:37, Fabrizio Benedetti notifications@github.com wrote:

Hello,

I am a bit struggling to understand the details of FlowSOM. Imagine that you have a flow set that you have clustered. som <- BuildSOM(fsom, colsToUse = some_colors ) cell_clustering_som <- som$map$mapping[,1]

So, cell_clustering_som tell us to which cluster a given line of the flow set belongs. If I have: expr_mat=fsApply(fsom,exprs)

What is the relation between expr_mat and som$map$codes? I was thinking that "codes" represent the average expression for a given cluster, so if I do (for instance for cluster 1): apply(expr_mat[cell_clustering_som==1, some_colors],2,mean)) I should get the "codes" for cluster 1, but I don't.

Simply, is there a way to get som$map$codes from cell_clustering_som and expr_mat?

Thank you for any answer.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SofieVG/FlowSOM/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOS724OW4T4JVCNVRWVWKTSWIMDVANCNFSM4VHGDXSA .

fbenedett commented 3 years ago

Thank you for your explanation and your time.