FelixTheStudent / cellpypes

Cell type pipes for R
GNU General Public License v3.0
51 stars 3 forks source link

Existing labels #16

Open FelixTheStudent opened 2 years ago

FelixTheStudent commented 2 years ago

Create an object slot where the user can put existing labels (e.g. output from Louvain, reference label transfer, etc.).

Write functions to:

FelixTheStudent commented 2 years ago

While not implemented in cellpypes yet, here is code to achieve the same thing:

obj <- seurat %>%
  pype_from_seurat() %>%
  rule("Tcells", "CD3E",  ">", 1) %>% 
  rule("Treg",   "FOXP3", ">", .1, parent="Tcells") %>% 
  rule("Treg_eff","ICOS", ">", 1.5, parent="Treg") %>% 
  rule("Treg_mem","CCR7", ">", 1.5, parent="Treg") 
# replace clusters 4,5 and 7 with cellpype labels:
pype_types <- as.character(classify(obj, c("Treg_eff", "Treg_mem")))
clusters   <- as.character(seurat$seurat_clusters)
seurat$edited_clusters <- case_when(
  clusters %in% c(4,5,7) ~ pype_types,
  TRUE ~ clusters)
# plot result:
DimPlot(seurat, group.by = "edited_clusters")