Seurat包其中的FindIntegrationAnchors
2020-10-13 本文已影响0人
单细胞空间交响乐
在用Seurat包做多样本整合的时候,我们通常采用两种方式:
(1)merge的方式
(2)FindIntegrationAnchors的方式整合
这里我们来解析一下FindIntegrationAnchors函数里面的参数及用法:
对于要进行多样本整合的数据,通常的做法是:
for (each in samples){
# ob=paste("ob",each,sep="_")
pbmc <- readRDS(paste0(path,'/',each,'_QC.rds'))
if(grep('-1',colnames(pbmc@assays$RNA@counts)[1])){
colnames(pbmc@assays$RNA@counts) <- str_replace_all(colnames(pbmc@assays$RNA@counts), '-1',paste0('-',numsap))
}else{
colnames(pbmc@assays$RNA@counts) <- paste0(colnames(pbmc@assays$RNA@counts),'-',numsap)
}
ob <- CreateSeuratObject(counts =pbmc@assays$RNA@counts,project =each,min.cells = min_cells)
ob$stim <-each
ob <- NormalizeData(ob)
ob <- FindVariableFeatures(ob, selection.method = "vst",nfeatures = Nfeatures)
numsap=numsap+1
ob.list[[each]] <- ob
}
anchors <- FindIntegrationAnchors(object.list = ob.list, dims = 1:20)
combined <- IntegrateData(anchorset = anchors, dims = 1:20)
也就是单样本做了均一化后,进行多样本的整合
那这个函数FindIntegrationAnchors就是来帮助我们寻找样本整合的数据点;
看一下这个函数的参数:
Description:
Find a set of anchors between a list of ‘Seurat’ objects. These
anchors can later be used to integrate the objects using the
‘IntegrateData’ function.(多个Seurat对象寻找anchors,也就是锚点)
主要参数:
assay: A vector of assay names specifying which assay to use when
constructing anchors. If NULL, the current default assay for
each object is used.(这个参数说明我们可以用部分样本进行anchors的寻找)。
reference: A vector specifying the object/s to be used as a reference
during integration. If NULL (default), all pairwise anchors
are found (no reference/s). If not NULL, the corresponding
objects in ‘object.list’ will be used as references. When
using a set of specified references, anchors are first found
between each query and each reference. The references are
then integrated through pairwise integration. Each query is
then mapped to the integrated reference.(这种方式说明,如果我们有部分样本细胞定义的结果很好,那么这部分样本可以作为reference,然后未知细胞类型的样本与参考集之间查找锚点,然后进行整合,这种方式类似于RCA,scanpy的样本整合方式,区别在于这里不需要事先对细胞进行定义)。
anchor.features: Can be either:
• A numeric value. This will call
‘SelectIntegrationFeatures’ to select the provided number
of features to be used in anchor finding
• A vector of features to be used as input to the anchor
finding process
(如果在先验知识很强的前提下,我们可以指定基因进行锚点的查找)。
normalization.method:
Name of normalization method used: LogNormalize
or SCT
(SCT的标准化的方式是SCTransform这个函数,大家可以看一下,推荐这个)
reduction: Dimensional reduction to perform when finding anchors. Can
be one of:
• cca(典型相关分析): Canonical correlation analysis(挖掘出数据间的关联关系的算法,原理就是CCA将多维数据利用线性变换投影为1维的数据,然后计算相关系数,进而得到二者的相关性,在这里我们就是两两细胞之间的相关性,
那么我们的投影标准就是:
投影后,两组数据的相关系数最大。
但是要要注意,CCA投影到一维且寻找最大相关性,所以存在整合过矫正的问题)
• rpca: Reciprocal PCA
When determining anchors between any two datasets using reciprocal PCA, we project each dataset into the other's PCA space and constrain the anchors by the same mutual neighborhood requirement. All downstream integration steps remain the same and we are able to 'correct' (or harmonize) the datasets.
(也就是是说从基因角度寻找锚点变成了主成分)。
For large studies with many datasets, we recommend also combining reciprocal PCA with reference-based integration, or SCTransform normalization (see details on previous tab)。但是要注意,这种整合方式仅用于大样本,因为锚点寻找的方式比CCA“粗糙”,大家要注意这一点。
k.anchor: How many neighbors (k) to use when picking anchors
k.filter: How many neighbors (k) to use when filtering anchors
k.score: How many neighbors (k) to use when scoring anchors
(锚点的确定原则,这个需要深入研究一下)
nn.method: Method for nearest neighbor finding. Options include: rann,
annoy
其中Seurat中有很多方法值得我们借鉴,但是具体情况要具体分析,千万不要是个方法就拿来用。
请保持愤怒,让王多鱼倾家荡产~~~~