knitr::opts_chunk$set(echo = TRUE)
library(STvEA) set.seed(4068)
Dusoswa et al. used CyTOF to profile splenocytes in a glioma mouse model (https://doi.org/10.1073/pnas.1907921117). We downloaded the FCS files of their dataset from Cytobank. All STvEA functions called "CODEX" or "codex_" can be equally used with CyTOF data, except those relating to spatial plotting.
cytof_names <- ReadNamesFCS("../data/MGL02_Spleen_Live_cells.fcs")[["channels"]] print(cytof_names) is_blank <- rep(FALSE, length(cytof_names)) # there are no blank channels is_protein <- !grepl("Time|Event|Center|Offset|Width|Residual|DNA|livedead|bc|^[0-9]|GFP",cytof_names) stvea_object <- ReadDataFCS("../data/MGL02_Spleen_Live_cells.fcs", is_protein, is_blank, protein_names = cytof_names[is_protein]) print(dim(stvea_object@codex_protein))
stvea_object <- FilterCODEX(stvea_object) print(dim(stvea_object@codex_protein)) # The filtering function does not remove any cells
Multiple articles reference the default Fluidigm CyTOF software randomizing counts by adding a value uniformly sampled from [-1,0]. Thus we take the ceiling of the CyTOF values and fit a negative binomial distribution. If this doesn't work, we can instead apply a standard arcsinh transformation. References: https://doi.org/10.1002/cyto.a.23908, https://biosurf.org/cytof_data_scientist.html
# Fit negative binomial stvea_object <- CleanCODEX(stvea_object, model="nb", normalize=FALSE, num_cores=8) # set num_cores to 1 on Windows # Alternatively, apply arcsinh transformation #stvea_object <- CleanCODEX(stvea_object, model="arcsinh")
We use UMAP to compute the 2 dimensional embedding of the cleaned CyTOF protein expression for later visualization. The call to UMAP also returns the KNN indices with k = n_neighbors. This function call will take over an hour for almost 150,000 cells. Decrease the negative_sample_rate to speed it up.
stvea_object <- GetUmapCODEX(stvea_object, metric = 'pearson', n_neighbors=30, min_dist=0.1, negative_sample_rate = 50)
We perform Louvain clustering on a KNN graph of the CyTOF cells, built from the KNN indices returned by UMAP. If k is provided, it must be less than or equal to n_neighbors from above. If it is not provided, it is set equal to n_neighbors.
stvea_object <- ClusterCODEX(stvea_object, k=30)
Color each cell in the CyTOF UMAP embedding with its cluster assignment. Cells in gray were not assigned to any cluster.
PlotClusterCODEXemb(stvea_object, pt_size=0.1)
Color each cell in the CyTOF UMAP embedding with its expression level of proteins. One or two protein names can be input. If two protein names are provided, color will be interpolated between red and green color values.
PlotExprCODEXemb(stvea_object, "CD11b", pt_size=0.1)
PlotExprCODEXemb(stvea_object, c("Tbet","TCRb"), pt_size=0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.