Learn R Programming

FlowSOM (version 1.0.0)

PlotPies: Plot comparison with other clustering

Description

Plot FlowSOM grid or tree, with pies indicating another clustering or manual gating result

Usage

PlotPies(fsom, cellTypes, MST=TRUE, legend=TRUE, clusters=NULL,main="", colorPalette=colorRampPalette(c("white","#00007F", "blue", "#007FFF","cyan", "#7FFF7F", "yellow", "#FF7F00", "red")))

Arguments

fsom
FlowSOM object, as generated by BuildMST
cellTypes
Array of factors indicating the celltypes
MST
logical. If TRUE, plot tree, else plot grid
legend
logical. Sometimes the position of the legend is not great, so it might be easier to plot without
clusters
optional, clustering of the SOM nodes
main
Title of the plot
colorPalette
Color palette to use

Value

by a pie chart indicating the percentage of cells present of each cell type

See Also

PlotStars,PlotMarker,PlotCenters, BuildMST

Examples

Run this code
    # Read from file, build self-organizing map and minimal spanning tree
    fileName <- system.file("extdata","lymphocytes.fcs",package="FlowSOM")
    flowSOM.res <- ReadInput(fileName, compensate=TRUE,transform=TRUE,
                            scale=TRUE)
    flowSOM.res <- BuildSOM(flowSOM.res,colsToUse=c(9,12,14:18))
    flowSOM.res <- BuildMST(flowSOM.res)
    
    # Get the manually gated labels using a gatingML file 
    # and the flowUtils library
    ff <- read.FCS(fileName)
    ff_c <- compensate(ff,ff@description$SPILL)
    colnames(ff_c)[8:18] <- paste("Comp-",colnames(ff_c)[8:18],sep="")
    library(flowUtils)
    flowEnv <- new.env()
    gatingFile <- system.file("extdata","manualGating.xml", 
                            package="FlowSOM")
    read.gatingML(gatingFile, flowEnv) 
    filterList <- list( "B cells" = flowEnv$ID52300206,
                    "ab T cells" = flowEnv$ID785879196,
                    "yd T cells" = flowEnv$ID188379411,
                    "NK cells" = flowEnv$ID1229333490,
                    "NKT cells" = flowEnv$ID275096433
                    )
    results <- list()
    for(cellType in names(filterList)){
        results[[cellType]] <- filter(ff_c,filterList[[cellType]])@subSet
    }
    manual <- rep("Unknown",nrow(ff))
    for(celltype in names(results)){
        manual[results[[celltype]]] <- celltype
    }
    
    # Plot pies indicating the percentage of cell types present in the nodes
    PlotPies(flowSOM.res,manual)

Run the code above in your browser using DataLab