Open Sophia409 opened 5 years ago
Hi, here is a version of the MapCells function for Seurat V3:
MapCells=function(object, unknown.id="P11", known.id="P60", num.k=10, thresh.require=0.9,map.col="Cell_types",new.col="Mapped") {
tsne.dims=object@reductions$tsne
input.dims=Embeddings(object,reduction.type = "integrated",dims.use = tsne.dims)
input.dist=as.matrix(dist(input.dims))
cells.end <- colnames(object[,object@meta.data$DevStage == known.id])
cells.map=colnames(object[,object@meta.data$DevStage == unknown.id])
map.id=pbsapply(cells.map,function(x)
names(which(sort(table(object@meta.data[names(sort(input.dist[x,cells.end])[1:num.k]),map.col]),decreasing = T)>=num.k*thresh.require))[1])
nn.same=pbsapply(cells.map, function(x) length(intersect(names(sort(input.dist[x,])[1:num.k]),cells.map)))
print(table(map.id))
map.id[is.na(map.id)]="Unassigned"
map.id[names(which(nn.same>=num.k*1))]="Unassigned"
print(table(map.id))
object@meta.data[cells.end,new.col]=object@meta.data[cells.end,map.col]
object@meta.data[cells.map,new.col]=map.id
return(object)
}
You can also install the modified version of Seurat that was used in Mayer et al. 2018 via GitHub:
library(devtools)
install_github("mayer-lab/SeuratForMayer2018")
library(Seurat)
library(pbapply)
@mayer-lab Hello, many thanks for your help.I also installed that modified version of Seurat, but it is based on Seurat V2. So the IntegrateData method is not included. Do you continue to recommend using RunCCA for mapping precursor cells to adult subtypes or IntegrateData method?
Hi, if you like to reproduce the analysis from the paper I suggest to use MapCells. Of course there are many other ways to connect cell-types across datasets (e.g. https://doi.org/10.1038/s41592-019-0534-4). As you have probably noticed, in Seurat V3 you can also transfer cell type labels from a reference dataset.
Hello, Mayer-lab I have read you paper and want to follow your pipeline to assign precursor cells to adult subtypes in my data.Since Seurat has updated to V3, IntegrateData has replaced RunCCA-AlignSubspace function.So wondering in this version, how I can assignment of precursor cells to adult subtypes after integrating both datasets? I read your Script 2_cell_assignment.R,and try to modify MapCells function to v3 verison. But because I'm a new comer in single cell analysis and R language, I have try my best and still couldn't finish this task. I will be much appreciated if you can show me the updated code to Perform this function. Looking forward to your help Sophia