HelenaLC / CATALYST

Cytometry dATa anALYsis Tools
67 stars 30 forks source link

Minimum spanning trees / Force-directed FlowSom graph #332

Closed M4artin closed 1 year ago

M4artin commented 1 year ago

Hi Helena,

First of all, thank you for a very nice package. I was wondering if there are there any plans for a simple wrapper to produce MST-plots in this package? Or is there a way I can extract it myself along with my own meta cluster annotation (apologies if it's something very basic, I'm rather new to the SCE format).

Kind regards, Martin

HelenaLC commented 1 year ago

There are currently no plans to support this. But it's fairly simple to run the clustering and use FlowSOM-native functions (as shown here) to get the MST and visualize the SOM. Minimal example below:

# load dependencies
suppressPackageStartupMessages({
  library(FlowSOM)
  library(flowCore)
  library(CATALYST)
})

# setup example data
data(PBMC_fs, PBMC_panel, PBMC_md)
sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md)

# specify grid & markers for clustering
xdim <- ydim <- 10
features <- type_markers(sce)

# construct 'flowFrame'
y <- assay(sce, "exprs")
ff <- flowFrame(t(y))

# get SOM & MST
som <- FlowSOM(ff, colsToUse = features, 
  xdim = xdim, ydim = ydim, nClus = 20, silent = TRUE,
  compensate = FALSE, transform = FALSE, scale = FALSE)
mst <- BuildMST(som)

# visualize with 'PlotStars'
PlotStars(som, backgroundValues = som$metaclustering)
PlotStars(mst)