spade-logoSPADE is a visualization tool for high-dimensional data.  It is particularly useful for data acquired on a CyTOF machine.

SPADE stands for Spanning tree Progression of Density normalized Events.  It represents high-dimensional data points in 2D space by determining the multidimensional distance or similarity between these events and using that as the plotted distance between these events. For more  information about SPADE see the SPADE homepage.

Installing R, SPADE, and the CYTOscape viewer

SPADE can be run directly from FlowJo but FlowJo will use the R algorithms in the background to do the calculations, so you must install R and the R SPADE implementation onto your computer.  You will only need to do this once.   Once installed you no longer need to open R to access the tools in FlowJo.

R can be downloaded from  http://www.r-project.org/. Once you have installed R, load SPADE by typing:

> source("http://bioconductor.org/biocLite.R")
> biocLite("spade")

Test is out by typing:

 > library(spade)

It should return: ‘Loading required package: igraph0’

The CytoScape viewer is a nice tool to interpret the results. You can download this from: http://www.cytoscape.org/download.html.  For the time being you want version 2.8.2.  There is a version 3 out, but it appears that 2.8 supports SPADE more directly and has video tutorials available.  Connect CytoScape and R by typing (using whatever path you placed CytoSPADE in):

OS X:
SPADE.installPlugin("/Applications/Cytoscape_v2.8.2")
Windows:
SPADE.installPlugin("C:/Cytoscape_v2.8.2")

If it’s successful you will see the message ‘Successfully installed CytoSpade plugin in:  Applications/Cytoscape_v2.8.2’

You’re ready to do some spanning now.

Please note that after you install R on windows machines, R also has to be added to the Path environment variable:

Capture2

Otherwise it may give “Failed to calculated Spade” errors.

Running SPADE through FlowJo

This is easy – load a data file, make some gates to get to the target population, click on it and select ‘Calculate Spade’ from the Power band / Extra menu, as shown in the picture below.  A menu will pop up asking you to select parameters.  Fewer parameters means a shorter run time.

Screen shot 2013-11-12 at 11-1.23.31 PM

This can take a little while to run.  This demo included 68,783 cells that I used 10 parameters from a CyTOF experiment and it ran for 5 min.  You’ll get a notification pop up when it finishes telling you where the outputs were placed.  They will end up in a folder within the folder that contained the FCS file you used.  For example:

Screen shot 2013-11-12 at 11.31.22 PM

The folder of pdfs are static images with little annotation and of limited use.  The gml and table files are used by CytoScape, and we’ll return to that below.   The FCS outputs can be brought back into FlowJo.  Of particular interest is the …cluster.fcs file, which appends a cluster number to each event, cleverly using the parameter name ‘cluster’ to identify the clusters.  As an example, here’s the cluster parameter displayed for this file – note I’ve switched the scale to linear with an upper limit of about 250.  These can be gated on to identify SPADE derived clusters within FJ.

Screen shot 2013-11-12 at 11.40.02 PM

 

Viewing the results in CytoScape

To get the pretty SPADE pictures everyone is used to, we’ll need CytoScape.  Open it from your applications folder – it uses R, but like FlowJo can call it in the background.  You need to go to the plugins menu and select SPADE.  A window will pop up that will ask you to navigate to the parent folder that contains all of the SPADE outputs.  Select the parent folder as your target.

Screen shot 2013-11-12 at 11.57.14 PM

 

You then need to pick a file to display and a coloring attribute from the selection box on the left – in the example below I am using file A1 and coloring by count.  The files selection cues up the graphic (like the one shown below).  The coloring attribute then sets the parameter that the events will be  heat-mapped by.

Screen shot 2013-11-04 at 1.18.18 PM

 

To get an idea about the data you can flip through it screening it for positivity across different colors.  Then you can click on a node and bring up a 2D graph in the bottom left hand panel.  You can use the ‘Editor’ tab to select a group of nodes, add nodes, or add connection lines.  Drawing a box around a set number of nodes allows you to highlight and select just them.  There’s a create network from selected nodes button that allows you to break out just a subset.  Also, by clicking on a node the ID number of it, which matches the cluster number, appears at the bottom of the screen so that you can trace this back to the cluster histogram in FJ.  For more instruction on how to use the Cytoscape viewer, try viewing their tutorials at http://www.cytoscape.org/.