Example Workflow for Single Cell Annotation Using CellMarker2.0"

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

You can view an example script for this workflow by running the following command

file.show(system.file(package = 'easybio', 'example-single-cell.R'))

The example marker data from pbmc3k datasets:

library(easybio)
head(pbmc.markers)
(marker <- matchCellMarker2(marker = pbmc.markers, n = 50, spc = 'Human')[, head(.SD, 2), by=cluster])
plotPossibleCell(marker)

Explanation:

To annotate, you can simply use the top-matched cell type:

cl2cell <- marker[, head(.SD, 1), by = .(cluster)]
cl2cell <- setNames(cl2cell[["cell_name"]], cl2cell[["cluster"]])
cl2cell

Visualize marker dot plots for similar clusters:

cls <- list(
  c(1, 5, 7), 
  c(8),
  c(3),
  c(0,2, 4, 6)
)
dotplotList <- plotSeuratDot(seuratObject, cls, marker = pbmc.markers, n = 50, spc = 'Human', topcellN = 2)

Explanation:

Construct a named vector for annotation:

cl2cell <- finsert(
  expression(
  c(1, 5) == "Monocyte",
  c(7) == "DC",
  c(8) == "megakaryocyte",
  c(3) == "B.cell",
  c(0, 2) == "Naive.CD8.T.cell",
  c(4) == "Cytotoxic.T.Cell",
  c(6) == "Natural.killer.cell",
), len = 9)
cl2cell

You can also directly retrieve markers:

get_marker(spc = 'Human', cell = c('Monocyte', 'Neutrophil'), number = 5, min.count = 1)

or Check the distribution of the marker directly:

plotMarkerDistribution(mkr = "CD68")


Try the easybio package in your browser

Any scripts or data that you put into this service are public.

easybio documentation built on Sept. 17, 2024, 1:08 a.m.