scMayoMap aims to annotate cell clusters in single-cell data, facilitating the analysis and interpretation of single-cell RNA-sequencing (scRNA-seq) data.
Install the development version of scMapping using the following commands:
devtools::install_github("chloelulu/scMayoMap")
pkgs <- c("ggplot2", "dplyr","tidyr","tibble","reshape2")
new.packages <- pkgs[!(pkgs %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
Load the necessary packages:
pkgs <- c("ggplot2", "dplyr","tidyr","tibble","reshape2")
sapply(pkgs, require, character.only = TRUE)
library(scMayoMap)
Upon loading scMayoMap, the demo "data" and integrated "scMayoMapDatabase" will automatically be available.
head(data)
scMayoMapDatabase is included within the package. Users can also utilize their marker pool, ensuring they match the format of scMappingDatabase.
head(scMayoMapDatabase[,c(1:4)])
To annotate a scRNA-seq data analysis output generated by FindAllMarkers You can specify the tissue type (i.e.,tissue = 'muscle') or not (tissue = NULL, default). But we do suggest to specify the tissue type, which will be more accurate. Additionally, please make sure your data is in the same format as demo data.
obj <- scMayoMap(data = data, tissue = 'muscle')
User can also define their own database as input. For example, if you want to use your own marker pool. The database should be in the same format as scMayoMapDatabase. Presence of a gene in a celltype will be 1, otherwise 0. column names should contain 'gene' column. Currently, our database only supports gene symbols. If you have a data with Ensembl ID, please refer biomaRt or other methods to convert the gene names.
head(demodata)
db <- tidyr::spread(demodata, key = c('celltype'), value = 'value')
db[is.na(db)] <- 0
obj <- scMayoMap(data = data, database = db)
You can retrieve the result summary table and export it in a format of your choosing.
res <- obj$res
head(res)
You can retrieve the table of marker genes utilized for predictions. Refer to the scMayoMap R Documentation for detailed descriptions of each column.
markers <- obj$markers
head(markers)
scMayoMap provides a plotting function to aid in visualizing the results. You can specify a directory where the plot will be saved (e.g., directory = '~/Desktop/'); if none is provided, the plot will be automatically saved to the current working directory (default is "directory = NULL"). Users should adjust the "width" and "height" parameters to suit their preferred figure size.
plt <- scMayoMap.plot(scMayoMap.object = obj, directory = '~/Desktop/', width = 8, height = 6)
Below code illustrates how to use scMayoMap if you start with a Seurat analysis. We will use a demo dataset from SeuratData. You need to install package Seurat and SeuratData before try below example. However, if you have a large dataset, you may refer to multi-thread to speed up FindAllMarkers procedure.
library(SeuratData)
library(Seurat)
seurat.obj <- LoadData(ds = "pbmc3k")
seurat.obj <- NormalizeData(object = seurat.obj)
seurat.obj <- FindVariableFeatures(object = seurat.obj)
seurat.obj <- ScaleData(object = seurat.obj)
seurat.obj <- RunPCA(object = seurat.obj)
seurat.obj <- FindNeighbors(object = seurat.obj)
seurat.obj <- FindClusters(object = seurat.obj)
seurat.markers <- FindAllMarkers(seurat.obj, method = 'MAST')
scMayoMap.obj <- scMayoMap(data = seurat.markers, database=scMayoMapDatabase, tissue = 'blood')
plt <- scMayoMap.plot(scMayoMap.object = scMayoMap.obj)
You can also retrieve the markers identified by scMayoMap to create a dot plot. The following code illustrates how to visualize the genes mapped to cluster 0, where the predicted cell type is Granulocyte.
gns <- scMayoMap.obj$markers$genes[scMayoMap.obj$markers$cluster==0 & scMayoMap.obj$markers$celltype=='Granulocyte']
gns <- strsplit(gns, ',')[[1]]
DotPlot(seurat.obj, features = gns)
If you use scMayoMap, please cite: