使用FindTransferAnchors对样本进行预注释

处理参考样本

1
2
3
4
5
6
7
8
9
10
11
12
13
ref_sce <- readRDS('~/upload/zl_liu/data/pca.rds')
ref_sce <- subset(ref_sce, group == 'CRPC')
table(ref_sce@meta.data$cell_type_fig3)
g2m_genes <- Seurat::CaseMatch(search=Seurat::cc.genes$g2m.genes,
match=rownames(ref_sce))
s_genes <- Seurat::CaseMatch(search=Seurat::cc.genes$s.genes,
match=rownames(ref_sce))
ref_sce <- Seurat::CellCycleScoring(ref_sce, g2m.features=g2m_genes, s.features=s_genes)
ref_sce$CC.Difference <- ref_sce$S.Score - ref_sce$G2M.Score
ref_sce[["percent.mt"]] <- Seurat::PercentageFeatureSet(ref_sce, pattern = "^MT-")
ref_sce[["percent.ERCC"]] <- Seurat::PercentageFeatureSet(ref_sce, pattern = "^ERCC-")
ref_sce[["percent.rp"]] <- Seurat::PercentageFeatureSet(ref_sce, pattern = "^RP[SL]")
ref_sce <- Seurat::SplitObject(object = ref_sce, split.by = 'orig.ident')

integration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ref_sce <- lapply(X = ref_sce, FUN = function(x) {
x <- Seurat::SCTransform(x, vst.flavor = "v2",
vars.to.regress = c("CC.Difference", "percent.mt", "percent.rp"),
verbose = F)
})
features <- Seurat::SelectIntegrationFeatures(object.list = ref_sce,
assay = rep('SCT', length(ref_sce)))
ref_sce <- Seurat::PrepSCTIntegration(object.list = ref_sce,
anchor.features = features,
assay = rep('SCT', length(ref_sce)))
anchors <- Seurat::FindIntegrationAnchors(object.list = ref_sce,
normalization.method = "SCT",
anchor.features = features,
assay = rep('SCT', length(ref_sce)))
combined <- Seurat::IntegrateData(anchorset = anchors,
normalization.method = "SCT")
combined <- Seurat::RunPCA(combined, verbose = FALSE)
combined <- Seurat::RunUMAP(combined,
reduction = "pca", dims = 1:30,
verbose = FALSE)
Seurat::DimPlot(combined, reduction = "umap",
group.by = "cell_type_fig3",
repel = T, label = T)

处理预处理完的样本

样本来自此

打个补丁

1
2
3
4
5
6
sce <- readRDS('SRX6887740.rds')
Seurat::DefaultAssay(sce) <- 'RNA'
sce[["percent.rp"]] <- Seurat::PercentageFeatureSet(sce, pattern = "^RP[SL]")
sce <- Seurat::SCTransform(sce, vst.flavor = "v2",
vars.to.regress = c("CC.Difference", "percent.mt", "percent.rp"),
verbose = F)

FindTransferAnchors

1
2
3
4
anchors <- Seurat::FindTransferAnchors(reference = combined, query = sce,
normalization.method = "SCT",
reference.assay = 'integrated',
query.assay = 'SCT')

TransferData

1
2
3
predictions <- Seurat::TransferData(anchorset = anchors, 
refdata = combined$cell_type_fig3)
sce <- AddMetaData(object = sce, metadata = predictions)

可视化

1
2
3
4
5
6
7
sce <- Seurat::RunPCA(sce, verbose = FALSE)
sce <- Seurat::RunUMAP(sce, reduction = "pca",
dims = 1:30,
verbose = FALSE)
Seurat::DimPlot(sce, reduction = "umap",
group.by = "predicted.id",
repel = T, label = T)

使用FindTransferAnchors对样本进行预注释
https://occdn.limour.top/2362.html
Author
Limour
Posted on
September 29, 2022
Licensed under