SCS【19】单细胞自动注释细胞类型 (Symphony)

1be0737f686ee06f0ca0ffc253d219d4.gif


单细胞生信分析教程

桓峰基因公众号推出单细胞生信分析教程并配有视频在线教程,目前整理出来的相关教程目录如下:

Topic 6. 克隆进化之 Canopy

Topic 7. 克隆进化之 Cardelino

Topic 8. 克隆进化之 RobustClone

SCS【1】今天开启单细胞之旅,述说单细胞测序的前世今生

SCS【2】单细胞转录组 之 cellranger

SCS【3】单细胞转录组数据 GEO 下载及读取

SCS【4】单细胞转录组数据可视化分析 (Seurat 4.0)

SCS【5】单细胞转录组数据可视化分析 (scater)

SCS【6】单细胞转录组之细胞类型自动注释 (SingleR)

SCS【7】单细胞转录组之轨迹分析 (Monocle 3) 聚类、分类和计数细胞

SCS【8】单细胞转录组之筛选标记基因 (Monocle 3)

SCS【9】单细胞转录组之构建细胞轨迹 (Monocle 3)

SCS【10】单细胞转录组之差异表达分析 (Monocle 3)

SCS【11】单细胞ATAC-seq 可视化分析 (Cicero)

SCS【12】单细胞转录组之评估不同单细胞亚群的分化潜能 (Cytotrace)

SCS【13】单细胞转录组之识别细胞对“基因集”的响应 (AUCell)

SCS【14】单细胞调节网络推理和聚类 (SCENIC)

SCS【15】细胞交互:受体-配体及其相互作用的细胞通讯数据库 (CellPhoneDB)

SCS【16】从肿瘤单细胞RNA-Seq数据中推断拷贝数变化 (inferCNV)

SCS【17】从单细胞转录组推断肿瘤的CNV和亚克隆 (copyKAT)

SCS【18】细胞交互:受体-配体及其相互作用的细胞通讯数据库 (iTALK)


简介

单细胞技术和集成算法的最新进展使得构建包含许多供体、研究、疾病状态和测序平台的综合参考地图集成为可能。就像将测序读数映射到参考基因组一样,能够将查询细胞映射到复杂的、数百万个细胞的参考图谱上,以快速识别相关的细胞状态和表型是至关重要的。本文介绍了Symphony (https://github.com/immunogenomics/symphony),这是一种以方便、便携的格式构建大规模集成参考地图集的算法,可以在几秒钟内实现高效的查询映射。Symphony将查询细胞定位在稳定低维引用嵌入中,从而便于将引用定义的注释向下复制传输到查询。我们展示了Symphony在多个真实世界数据集中的强大功能,包括

(1)映射多供体、多物种查询以预测胰腺细胞类型;

(2)沿着胎儿肝脏造血的发育轨迹定位查询细胞;

(3)使用记忆T细胞的多模态citation-seq图谱推断表面蛋白表达。

Symphony 最早发表于 2021 年 Nature Communications 杂志上的一篇文章,文章题目为"Efficient and precise single-cell reference atlas mapping with Symphony"。发表该文章的 Raychaudhuri Lab 曾于 2019 年在 Nature Methods 杂志上发表单细胞数据整合算法 Harmony。

Symphony 算法首先将 Reference 数据集嵌入 UMAP 空间中,再将 Query 数据集(待注释数据集)嵌入到与 Reference 数据集相同的 UMAP 空间,接着使用 KNN 算法,根据 Reference 数据集,计算距离 Query 细胞最近的 K 个 Reference 细胞邻居,确定最可能的 cell type。

Symphony 包使用

1.使用已有的参考数据集进行细胞注释

2.使用自定义的参考数据集进行细胞注释

fa406f1886bbe4bd95908a1d0c8f8f11.png

https://zenodo.org/record/5090425#.ZC03MJFBw5s

软件包安装

if(!require(harmony))
  install.packages("harmony")

if(!require(symphony))
  install.packages("symphony")

if(!require(symphony))
  devtools::install_github("immunogenomics/symphony")
suppressPackageStartupMessages({
    library(symphony)
    library(tidyverse)
    library(data.table)
    library(matrixStats)
    library(Matrix)
    library(plyr)
    library(dplyr)

    ## 画图包
    library(ggplot2)
    library(ggthemes)
    library(ggrastr)
    library(RColorBrewer)
    library(patchwork)
    library(ggrepel)
})
source("F:/demo script/单细胞系列/symphony/symphony-main/vignettes/utils.R")  # color definitions and plotting functions
source("F:/demo script/单细胞系列/symphony/symphony-main/vignettes/plotBasic.R")
source("F:/demo script/单细胞系列/symphony/symphony-main/vignettes/colors.R")

数据准备

数据需要我们提前准备两个文件:

1.标准后的表达矩阵

  1. metadata 数据

下面例子的文件可到git上下载:

https://github.com/immunogenomics/symphony

e5a6c42e75e610c8afae3566688c7132.png

在本例中,我们将从两种技术(10x 3'v1和3'v2)的两个pbmc数据集构建一个引用,然后用Symphony映射来自一种新技术(10x 5')的第三个数据集。

exprs_norm = readRDS("F:/demo script/单细胞系列/symphony/symphony-main/vignettes/data/exprs_norm_all.rds")
metadata = read.table("F:/demo script/单细胞系列/symphony/symphony-main/vignettes/data/meta_data_subtypes.txt",
    row.names = 1, header = T, check.names = F, sep = "\t")

dim(exprs_norm)
## [1] 33694 20886
dim(metadata)
## [1] 20886     8

提取子集数据集作为reference and query

idx_query = which(metadata$donor == "5")  # use 5' dataset as the query
ref_exp_full = exprs_norm[, -idx_query]
ref_metadata = metadata[-idx_query, ]
query_exp = exprs_norm[, idx_query]
query_metadata = metadata[idx_query, ]

构建 Symphony Reference

关于如何构建Symphony Reference,有两个选项。

  1. (buildReferenceFromHarmonyObj)是更模块化的选项,这意味着用户在 Reference 压缩之前对预处理步骤有更多的控制。

  2. (buildReference)从表达式开始构建Reference,使过程更加自动化,但灵活性较低。

我们将在下面演示这两个选项。

选项1:从Harmony对象构建(首选方法)

这个选项比选项2包含更多的步骤,但是如果您想在Harmony集成步骤之前执行自己的预处理步骤,则可以使您的代码更加模块化和灵活。我们向大多数用户推荐这个选项。生成vargenes_means_sds(包含用于缩放基因的可变基因均值和标准偏差)以及为PCA步骤节省负载是很重要的。

选择可变基因,通过可变基因进行亚群内参表达

# Sparse matrix with the normalized genes x cells matrix
ref_exp_full[1:5, 1:2]
## 5 x 2 sparse Matrix of class "dgCMatrix"
##              threepfresh_AAACCTGAGCATCATC threepfresh_AAACCTGAGCTAACTC
## RP11-34P13.3                            .                            .
## FAM138A                                 .                            .
## OR4F5                                   .                            .
## RP11-34P13.7                            .                            .
## RP11-34P13.8                            .                            .
var_genes = vargenes_vst(ref_exp_full, groups = as.character(ref_metadata[["donor"]]),
    topn = 2000)
ref_exp = ref_exp_full[var_genes, ]
dim(ref_exp)
## [1]  3451 13189

计算并保存每个基因的均值和标准差

vargenes_means_sds = tibble(symbol = var_genes, mean = Matrix::rowMeans(ref_exp))
vargenes_means_sds$stddev = symphony::rowSDs(ref_exp, vargenes_means_sds$mean)
head(vargenes_means_sds)
## # A tibble: 6 × 3
##   symbol   mean stddev
##   <chr>   <dbl>  <dbl>
## 1 LYZ      1.80   1.91
## 2 HLA-DRA  1.90   1.71
## 3 CD74     2.56   1.54
## 4 S100A9   1.61   1.85
## 5 S100A4   2.50   1.46
## 6 FTL      3.58   1.18

使用计算出的基因均值和标准差对数据进行缩放,

ref_exp_scaled = symphony::scaleDataWithStats(
  ref_exp, vargenes_means_sds$mean,
  vargenes_means_sds$stddev,
  1
)


#Run SVD, save gene loadings (s$u)
#install.packages("irlba")
library(irlba)
set.seed(0)
s = irlba(ref_exp_scaled, nv = 20)
Z_pca_ref = diag(s$d) %*% t(s$v)  # 每个细胞的主成分
loadings = s$u

set.seed(0)
ref_harmObj = harmony::HarmonyMatrix(
  data_mat = t(Z_pca_ref),  ## PCA embedding matrix of cells
  meta_data = ref_metadata, ## dataframe with cell labels
  theta = c(2),             ## cluster diversity enforcement
  vars_use = c('donor'),    ## variable to integrate out
  nclust = 100,             ## number of clusters in Harmony model
  max.iter.harmony = 20,
  return_object = TRUE,     ## return the full Harmony model object
  do_pca = FALSE            ## don't recompute PCs
)

# Compress a Harmony object into a Symphony reference
reference = symphony::buildReferenceFromHarmonyObj(
  ref_harmObj,            # output object from HarmonyMatrix()
  ref_metadata,           # reference cell metadata
  vargenes_means_sds,     # gene names, means, and std devs for scaling
  loadings,               # genes x PCs matrix
  verbose = TRUE,         # verbose output
  do_umap = TRUE,         # Set to TRUE only when UMAP model was saved for reference
  save_uwot_path = './testing_uwot_model_1')
# Optionally, you can specify which normalization method was
# used to build the reference as a custom slot inside the Symphony object to 
# help record this information for future query users
reference$normalization_method = 'log(CP10k+1)'
saveRDS(reference, './testing_reference1.rds')

让我们看看参考对象包含:

meta_data: metadata
vargenes: variable genes, means, and standard deviations used for scaling
loadings: gene loadings for projection into pre-Harmony PC space
R: Soft cluster assignments
Z_orig: Pre-Harmony PC embedding
Z_corr: Harmonized PC embedding
centroids: locations of final Harmony soft cluster centroids
cache: pre-calculated reference-dependent portions of the mixture model
umap: UMAP coordinates
save_uwot_path: path to saved uwot model (for query UMAP projection into reference UMAP coordinates)
normalization_method: type of normalization used
str(reference)
## List of 13
##  $ meta_data           :'data.frame':	13189 obs. of  8 variables:
##   ..$ cell_id     : chr [1:13189] "threepfresh_AAACCTGAGCATCATC" "threepfresh_AAACCTGAGCTAACTC" "threepfresh_AAACCTGAGCTAGTGG" "threepfresh_AAACCTGCACATTAGC" ...
##   ..$ donor       : chr [1:13189] "3V2" "3V2" "3V2" "3V2" ...
##   ..$ nUMI        : int [1:13189] 2394 1694 4520 2788 4667 4440 3224 5205 5493 4419 ...
##   ..$ nGene       : int [1:13189] 871 806 1316 898 1526 1495 1253 1433 1632 1134 ...
##   ..$ percent_mito: num [1:13189] 0.0384 0.0573 0.0195 0.014 0.0362 ...
##   ..$ cell_type   : chr [1:13189] "bcells" "mono" "tcells" "tcells" ...
##   ..$ res_0.80    : int [1:13189] 3 5 2 1 0 0 6 4 0 4 ...
##   ..$ cell_subtype: chr [1:13189] "bnaive" "mono14" "cd4mem" "cd4naive" ...
##  $ vargenes            : tibble [3,451 × 3] (S3: tbl_df/tbl/data.frame)
##   ..$ symbol: chr [1:3451] "LYZ" "HLA-DRA" "CD74" "S100A9" ...
##   ..$ mean  : Named num [1:3451] 1.8 1.9 2.56 1.61 2.5 ...
##   .. ..- attr(*, "names")= chr [1:3451] "LYZ" "HLA-DRA" "CD74" "S100A9" ...
##   ..$ stddev: Named num [1:3451] 1.91 1.71 1.54 1.85 1.46 ...
##   .. ..- attr(*, "names")= chr [1:3451] "LYZ" "HLA-DRA" "CD74" "S100A9" ...
##  $ loadings            : num [1:3451, 1:20] -0.1071 -0.0704 -0.052 -0.1016 -0.0764 ...
##  $ R                   : num [1:100, 1:13189] 2.51e-10 6.46e-10 4.55e-10 1.04e-01 1.49e-02 ...
##  $ Z_orig              : num [1:20, 1:13189] 2.566 -13.635 -4.449 -0.973 -1.077 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:20] "PC_1" "PC_2" "PC_3" "PC_4" ...
##   .. ..$ : chr [1:13189] "threepfresh_AAACCTGAGCATCATC" "threepfresh_AAACCTGAGCTAACTC" "threepfresh_AAACCTGAGCTAGTGG" "threepfresh_AAACCTGCACATTAGC" ...
##  $ Z_corr              : num [1:20, 1:13189] 2.67 -12.27 -4.08 1.98 -1.21 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:20] "harmony_1" "harmony_2" "harmony_3" "harmony_4" ...
##   .. ..$ : chr [1:13189] "threepfresh_AAACCTGAGCATCATC" "threepfresh_AAACCTGAGCTAACTC" "threepfresh_AAACCTGAGCTAGTGG" "threepfresh_AAACCTGCACATTAGC" ...
##  $ betas               : num [1:3, 1:20, 1:100] -12.412 0.582 -0.582 1.061 0.694 ...
##  $ centroids           : num [1:20, 1:100] -0.7896 0.0674 -0.0882 0.2572 0.0249 ...
##  $ cache               :List of 2
##   ..$ : num [1:100, 1] 110 155 127 147 124 ...
##   ..$ : num [1:100, 1:20] -1362 953 693 603 405 ...
##  $ centroids_pc        :'data.frame':	100 obs. of  20 variables:
##   ..$ harmony_1 : num [1:100] -12.41 6.15 5.47 4.11 3.26 ...
##   ..$ harmony_2 : num [1:100] 1.06 0.98 4.16 -12.82 -10.71 ...
##   ..$ harmony_3 : num [1:100] -1.39 4.21 -2.19 -3.99 -3.42 ...
##   ..$ harmony_4 : num [1:100] 4.043 0.896 0.468 1.328 1.497 ...
##   ..$ harmony_5 : num [1:100] 0.391 -0.159 -0.866 -1.199 -0.176 ...
##   ..$ harmony_6 : num [1:100] 3.671 -0.22 -1.706 -1.413 0.633 ...
##   ..$ harmony_7 : num [1:100] -5.28 0.576 0.817 -0.316 0.112 ...
##   ..$ harmony_8 : num [1:100] -3.436 -1.304 2.898 0.256 1.211 ...
##   ..$ harmony_9 : num [1:100] -3.8916 0.5006 -3.4239 0.0352 0.8073 ...
##   ..$ harmony_10: num [1:100] 0.949 0.419 -2.019 0.409 -0.79 ...
##   ..$ harmony_11: num [1:100] -1.3928 0.0688 0.1749 0.2219 -1.5822 ...
##   ..$ harmony_12: num [1:100] -0.417 0.171 1.098 1.234 -4.802 ...
##   ..$ harmony_13: num [1:100] 0.825 0.353 1.206 0.164 1.535 ...
##   ..$ harmony_14: num [1:100] -0.5103 0.0407 0.6792 -0.9357 3.3156 ...
##   ..$ harmony_15: num [1:100] -0.5641 -0.0995 0.8319 -0.1903 0.1557 ...
##   ..$ harmony_16: num [1:100] -0.136 0.27 0.495 0.331 0.514 ...
##   ..$ harmony_17: num [1:100] -0.0144 0.2031 0.0241 -0.3746 0.118 ...
##   ..$ harmony_18: num [1:100] -0.705 -0.202 0.028 0.155 -0.282 ...
##   ..$ harmony_19: num [1:100] 0.1726 -0.1749 0.4197 -0.4117 0.0885 ...
##   ..$ harmony_20: num [1:100] 0.6368 0.0867 0.5938 0.0761 -0.5495 ...
##  $ umap                :List of 1
##   ..$ embedding: num [1:13189, 1:2] 3.59 7.48 -2.24 -4.31 6.68 ...
##   .. ..- attr(*, "scaled:center")= num [1:2] 0.248 0.203
##   .. ..- attr(*, "dimnames")=List of 2
##   .. .. ..$ : chr [1:13189] "threepfresh_AAACCTGAGCATCATC" "threepfresh_AAACCTGAGCTAACTC" "threepfresh_AAACCTGAGCTAGTGG" "threepfresh_AAACCTGCACATTAGC" ...
##   .. .. ..$ : chr [1:2] "UMAP1" "UMAP2"
##  $ save_uwot_path      : chr "./testing_uwot_model_1"
##  $ normalization_method: chr "log(CP10k+1)"

可视化参考UMAP

reference = readRDS('./testing_reference1.rds')
umap_labels = cbind(ref_metadata, reference$umap$embedding)
fig.size(3, 5)
plotBasic(umap_labels, title = 'Reference', color.by = 'cell_type')
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.

f5cbb131ccee3b9a30769508055c4911.png

选项2:从头构建(从表达式开始)

该选项从统一管道中的表达式开始计算引用对象,使预处理步骤自动化。

set.seed(0)
reference = symphony::buildReference(
  ref_exp_full,
  ref_metadata,
  vars = c('donor'),         # variables to integrate over
  K = 100,                   # number of Harmony clusters
  verbose = TRUE,            # verbose output
  do_umap = TRUE,            # can set to FALSE if want to run umap separately later
  do_normalize = FALSE,      # set to TRUE if input counts are not normalized yet
  vargenes_method = 'vst',   # method for variable gene selection ('vst' or 'mvp')
  vargenes_groups = 'donor', # metadata column specifying groups for variable gene selection 
  topn = 2000,               # number of variable genes to choose per group
  d = 20,                    # number of PCs
  save_uwot_path = './testing_uwot_model_2'
)
reference$normalization_method = 'log(CP10k+1)' # optionally save normalization method in custom slot

# Save reference (modify with your desired output path)
saveRDS(reference, './testing_reference2.rds')


reference = readRDS('./testing_reference2.rds')

可视化参考UMAP

fig.size(3, 5)
plotBasic(umap_labels, title = "Reference", color.by = "cell_type")

f9738fcc8c16028796bd319e1bd541be.png

Map query

为了将新的查询数据集映射到reference,您需要从上述步骤中保存一个reference对象,以及查询细胞表达式和meta数据。假设查询数据集已经按照与参考单细胞相同的方式进行了规范化(这里默认为log(CP10k+1)规范化)。

reference = readRDS('./testing_reference1.rds')
#### Map query
query = mapQuery(query_exp,             # query gene expression (genes x cells)
                 query_metadata,        # query metadata (cells x attributes)
                 reference,             # Symphony reference object
                 do_normalize = FALSE,  # perform log(CP10k+1) normalization on query
                 do_umap = TRUE)        # project query cells into reference UMAP

query = knnPredict(query, reference, reference$meta_data$cell_type, k = 5)
str(query)
## List of 7
##  $ exp      :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
##   .. ..@ i       : int [1:13735662] 45 59 72 110 139 153 160 197 211 242 ...
##   .. ..@ p       : int [1:7698] 0 1318 3482 5594 7120 8452 10450 11318 12889 14154 ...
##   .. ..@ Dim     : int [1:2] 33694 7697
##   .. ..@ Dimnames:List of 2
##   .. .. ..$ : chr [1:33694] "RP11-34P13.3" "FAM138A" "OR4F5" "RP11-34P13.7" ...
##   .. .. ..$ : chr [1:7697] "fivePrime_AAACCTGAGCGATAGC" "fivePrime_AAACCTGAGCTAAACA" "fivePrime_AAACCTGAGGGAGTAA" "fivePrime_AAACCTGAGTCTTGCA" ...
##   .. ..@ x       : num [1:13735662] 1.54 1.54 2.13 1.54 1.54 ...
##   .. ..@ factors : list()
##  $ meta_data:'data.frame':	7697 obs. of  10 variables:
##   ..$ cell_id                : chr [1:7697] "fivePrime_AAACCTGAGCGATAGC" "fivePrime_AAACCTGAGCTAAACA" "fivePrime_AAACCTGAGGGAGTAA" "fivePrime_AAACCTGAGTCTTGCA" ...
##   ..$ donor                  : chr [1:7697] "5" "5" "5" "5" ...
##   ..$ nUMI                   : int [1:7697] 2712 6561 6322 4528 3426 6199 2378 4934 3654 12842 ...
##   ..$ nGene                  : int [1:7697] 1318 2164 2112 1526 1332 1998 868 1571 1265 3159 ...
##   ..$ percent_mito           : num [1:7697] 0.0664 0.0565 0.0562 0.072 0.0683 ...
##   ..$ cell_type              : chr [1:7697] "nk" "mono" "mono" "tcells" ...
##   ..$ res_0.80               : int [1:7697] 9 0 0 11 0 8 1 1 3 0 ...
##   ..$ cell_subtype           : chr [1:7697] "nk" "mono14" "mono14" "cd8eff" ...
##   ..$ cell_type_pred_knn     : Factor w/ 7 levels "","bcells","dc",..: 6 5 5 7 5 2 7 7 2 5 ...
##   .. ..- attr(*, "prob")= num [1:7697] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ cell_type_pred_knn_prob: num [1:7697] 1 1 1 1 1 1 1 1 1 1 ...
##  $ Z        : num [1:20, 1:7697] 3.575 8.814 -11.757 -0.905 -2.626 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:20] "harmony_1" "harmony_2" "harmony_3" "harmony_4" ...
##   .. ..$ : chr [1:7697] "fivePrime_AAACCTGAGCGATAGC" "fivePrime_AAACCTGAGCTAAACA" "fivePrime_AAACCTGAGGGAGTAA" "fivePrime_AAACCTGAGTCTTGCA" ...
##  $ Zq_pca   : num [1:20, 1:7697] 3.58 10.64 -13.73 -4.33 -2.56 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:20] "PC_1" "PC_2" "PC_3" "PC_4" ...
##   .. ..$ : chr [1:7697] "fivePrime_AAACCTGAGCGATAGC" "fivePrime_AAACCTGAGCTAAACA" "fivePrime_AAACCTGAGGGAGTAA" "fivePrime_AAACCTGAGTCTTGCA" ...
##  $ R        : num [1:100, 1:7697] 4.11e-11 6.23e-11 9.70e-07 8.12e-12 6.80e-12 ...
##  $ Xq       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
##   .. ..@ i       : int [1:15394] 0 1 0 1 0 1 0 1 0 1 ...
##   .. ..@ p       : int [1:7698] 0 2 4 6 8 10 12 14 16 18 ...
##   .. ..@ Dim     : int [1:2] 2 7697
##   .. ..@ Dimnames:List of 2
##   .. .. ..$ : NULL
##   .. .. ..$ : NULL
##   .. ..@ x       : num [1:15394] 1 1 1 1 1 1 1 1 1 1 ...
##   .. ..@ factors : list()
##  $ umap     : num [1:7697, 1:2] -4.29 5.95 6.67 -5.21 7.44 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:7697] "fivePrime_AAACCTGAGCGATAGC" "fivePrime_AAACCTGAGCTAAACA" "fivePrime_AAACCTGAGGGAGTAA" "fivePrime_AAACCTGAGTCTTGCA" ...
##   .. ..$ : chr [1:2] "UMAP1" "UMAP2"

让我们看看这个查询对象包含了什么:

Z: query cells in reference Harmonized embedding
Zq_pca: query cells in pre-Harmony reference PC embedding (prior to correction)
R: query cell soft cluster assignments
Xq: query cell design matrix for correction step
umap: query cells projected into reference UMAP coordinates (using uwot)
meta_data: metadata

查询细胞类型预测现在在cell_type_pred_knn列中。cell_type_pred_knn_prob列报告获胜投票的最近邻居的比例(可以帮助识别落在两种参考细胞类型之间的“边界”上的查询细胞)。

head(query$meta_data)
##                                               cell_id donor nUMI nGene
## fivePrime_AAACCTGAGCGATAGC fivePrime_AAACCTGAGCGATAGC     5 2712  1318
## fivePrime_AAACCTGAGCTAAACA fivePrime_AAACCTGAGCTAAACA     5 6561  2164
## fivePrime_AAACCTGAGGGAGTAA fivePrime_AAACCTGAGGGAGTAA     5 6322  2112
## fivePrime_AAACCTGAGTCTTGCA fivePrime_AAACCTGAGTCTTGCA     5 4528  1526
## fivePrime_AAACCTGAGTTCGATC fivePrime_AAACCTGAGTTCGATC     5 3426  1332
## fivePrime_AAACCTGCACACTGCG fivePrime_AAACCTGCACACTGCG     5 6199  1998
##                            percent_mito cell_type res_0.80 cell_subtype
## fivePrime_AAACCTGAGCGATAGC   0.06637168        nk        9           nk
## fivePrime_AAACCTGAGCTAAACA   0.05654626      mono        0       mono14
## fivePrime_AAACCTGAGGGAGTAA   0.05615312      mono        0       mono14
## fivePrime_AAACCTGAGTCTTGCA   0.07199647    tcells       11       cd8eff
## fivePrime_AAACCTGAGTTCGATC   0.06830123      mono        0       mono14
## fivePrime_AAACCTGCACACTGCG   0.05097596    bcells        8         bmem
##                            cell_type_pred_knn cell_type_pred_knn_prob
## fivePrime_AAACCTGAGCGATAGC                 nk                       1
## fivePrime_AAACCTGAGCTAAACA               mono                       1
## fivePrime_AAACCTGAGGGAGTAA               mono                       1
## fivePrime_AAACCTGAGTCTTGCA             tcells                       1
## fivePrime_AAACCTGAGTTCGATC               mono                       1
## fivePrime_AAACCTGCACACTGCG             bcells                       1

可视化 Mapping 结果,绘制所有细胞的UMAP可视化图

# Sync the column names for both data frames
reference$meta_data$cell_type_pred_knn = NA
reference$meta_data$cell_type_pred_knn_prob = NA
reference$meta_data$ref_query = "reference"
query$meta_data$ref_query = "query"

# Add the UMAP coordinates to the metadata
meta_data_combined = rbind(query$meta_data, reference$meta_data)
umap_combined = rbind(query$umap, reference$umap$embedding)
umap_combined_labels = cbind(meta_data_combined, umap_combined)

# Plot UMAP visualization of all cells
fig.size(3, 5)
plotBasic(umap_combined_labels, title = "Reference and query cells", color.by = "ref_query")

b3cb06e49822a6c1bcc00a68c210c7f1.png

绘制所有细胞的 query 和 reference

fig.size(3, 7)
plotBasic(umap_combined_labels, title = "Reference and query cells", color.by = "cell_type",
    facet.by = "ref_query")

194bac13fa211949a0e1768e5287578b.png

References:

  1. Kang, J.B., Nathan, A., Weinand, K. et al. Efficient and precise single-cell reference atlas mapping with Symphony. Nat Commun 12, 5890 (2021). https://doi.org/10.1038/s41467-021-25957-x

这个细胞互作软件包代码量还是很多的,需要具有一定 R 语言编程基础,并不是看起来那么简单,所有好多老师想直接自己学习教程来分析,但是实质上没有基础还是很难实现,每步报错都不知道该怎样处理,是最崩溃的,所以有需求的老师可以联系桓峰基因,提供最优质的服务!!!

桓峰基因,铸造成功的您!

未来桓峰基因公众号将不间断的推出单细胞系列生信分析教程,

敬请期待!!

桓峰基因和投必得合作,文章润色优惠85折,需要文章润色的老师可以直接到网站输入领取桓峰基因专属优惠券码:KYOHOGENE,然后上传,付款时选择桓峰基因优惠券即可享受85折优惠哦!https://www.topeditsci.com/

有想进生信交流群的老师可以扫最后一个二维码加微信,备注“单位+姓名+目的”,有些想发广告的就免打扰吧,还得费力气把你踢出去!

30777845ae2451c2078fea25c6eb5576.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/6937.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

一图看懂 bz2 模块:处理压缩和解压缩文件, 资料整理+笔记(大全)

本文由 大侠(AhcaoZhu)原创&#xff0c;转载请声明。 链接: https://blog.csdn.net/Ahcao2008 一图看懂 bz2 模块&#xff1a;处理压缩和解压缩文件, 资料整理笔记&#xff08;大全&#xff09;摘要模块图类关系图模块全展开【bz2】统计常量int模块4 io5 os6 warnings7 _compre…

数据结构与算法基础(王卓)(23):邻接表(链式存储结构)

顶点结点&#xff1a; //顶点的结点结构 typedef struct VNode {VertexType data; //顶点信息ArcNode* firstarc; //指向第一条依附该顶点的边的指针 }VNode, AdjList[MVNum]; //例如&#xff1a;VNode v[MVNum] 相当于 AdjList v 我觉得也可以改成这样写&#xff08;存疑&…

基于数字孪生智慧污水厂Web3D可视化管理系统

城市水环境不仅关系到国民生活的质量&#xff0c;还对我国社会发展有着深入的影响。城市污水处理厂的存在不仅能够提升生态环保工作发挥的效用&#xff0c;还能够向城市居民宣传生态环保的重要性&#xff0c;使得更多的市民认识到节约、环保的意义&#xff0c;能够从自身出发&a…

UVM学习笔记2——验证基础知识(验证计划、验证方法)

文章目录前言一、覆盖率二、验证计划1、验证计划模板2、验证计划评估三、验证方法1、动态仿真/dynamic simulation2、静态检查/formal check3、虚拟模型4、硬件加速/hardware acceleration5、效能验证6、性能验证四、验证分类1、验证工具2、验证复杂度/可见度/透明度3、验证的芯…

Java设计模式(一)单例模式

设计模式是对软件设计中普遍存在的各种问题&#xff0c;提出解决方案 设计模式包含了面向对象的精髓&#xff0c;懂了设计模式&#xff0c;你就懂了面向对象分析和设计的精要。 设计模式的七大原则 1.单一职责原则 2.接口隔离原则 3.依赖倒置原则 4.里氏替换原则 5.开闭原则o…

大数据项目实战之数据仓库:用户行为采集平台——第2章 项目需求及架构设计

第2章 项目需求及架构设计 2.1 项目需求分析 1&#xff09;采集平台 &#xff08;1&#xff09;用户行为数据采集平台搭建 &#xff08;2&#xff09;业务数据采集平台搭建 2&#xff09;离线需求 主题 子主题 指标 流量主题 各渠道流量统计 当日各渠道独立…

pdf压缩文件怎么压缩最小?办公常备软件

PDF文件的大小有时会让人感到困扰&#xff0c;特别是在网络上传输和存储方面。为了解决这个问题&#xff0c;我们需要将PDF文件压缩至最小。 在进行压缩之前&#xff0c;需要检查PDF文件的分辨率和图形质量。通过降低分辨率和图形质量&#xff0c;可以显著减小文件的大小。此外…

springCloud学习【6】之分布式搜索引擎(3)

文章目录前言一 数据聚合1.1 DSL实现聚合1.1.1 Bucket聚合语法1.1.2 聚合结果排序1.1.3 限定聚合范围1.2 Metric聚合语法1.3 小结1.4 RestAPI实现聚合1.5 API语法1.7 案例二 自动补全2.1 拼音分词器的安装2.2 自定义分词器2.3 自动补全查询2.4 自动补全查询的JavaAPI三 数据同步…

Unity升级后打包AssetBundle变慢

1&#xff09;Unity升级后打包AssetBundle变慢 ​2&#xff09;打包使有些资源合成了一个资源data.unity3d&#xff0c;有些分开的原因 3&#xff09;Unreal在移动设备中无法使用Stat命令获取到GPU Thread的耗时 4&#xff09;Unity中如何看到相机视野范围内的剔除结果 这是第3…

【C++】迭代器

内容来自《C Primer&#xff08;第5版&#xff09;》9.2.1 迭代器、9.2.3 begin和end成员、9.3.6 容器操作可能使迭代器失效、10.4.3 反向迭代器 目录 1. 迭代器 1.1 迭代器范围 1.2 使用左闭合范围蕴含的编程假定 2. begin和end成员 3. 容器操作可能使迭代器失效 3.1 编…

【SQL基础笔记】

本文标签: SQL语法 SQL分类 DDL DML DQL DCL 目录 一、SQL语法 二、SQL的分类 三、DDL 1.DDL-数据库操作 2.DDL-表操作 3.DDL-数据类型 4.DDL-表操作 四、DML 五、DQL 1.DQL-基本查询 2.DQL-条件查询: 3.DQL-聚合函数 4.DQL-分组查询 5.DQL-排序查询 6.DQL-分页查询 7.综合案…

让ChatGPT在中断回答的时候自动输入「请接上文继续」并发送

一、脚本内容 让ChatGPT在中断回答的时候自动输入「请接上文继续」并发送 // UserScript // name ChatGPT自动接上文继续 // namespace http://tampermonkey.net/ // version 1.3 // description 让ChatGPT在中断回答的时候自动输入「请接上文继续」并发送 /…

Elasticsearch:高级数据类型介绍

在我之前的文章 “Elasticsearch&#xff1a;一些有趣的数据类型”&#xff0c;我已经介绍了一下很有趣的数据类型。在今天的文章中&#xff0c;我再进一步介绍一下高级的数据类型&#xff0c;虽然这里的数据类型可能和之前的一些数据类型有所重复。即便如此&#xff0c;我希望…

MySQL数据同步ES的常用思路和方法

文章目录 1.同步双写2.异步双写3.定时任务4.数据订阅大家应该都在各种电商网站检索过商品,检索商品一般都是通过什么实现呢?搜索引擎Elasticsearch。 那么问题来了,商品上架,数据一般写入到MySQL的数据库中,那么用于检索的数据又是怎么同步到Elasticsearch的呢? 1.同步双…

认识Spring(下)

作者&#xff1a;~小明学编程 文章专栏&#xff1a;Spring框架 格言&#xff1a;热爱编程的&#xff0c;终将被编程所厚爱。 目录 Spring更加高效的读取和存储对象 存储bean对象 五大注解 关于五大类注解 对象的注入 属性注入 构造方法注入 Setter注入 三种注入方式的…

IPV6 资料收集

IPV6与IPV4区别 1、地址长度的区别&#xff1a;IPv4协议具有32位&#xff08;4字节&#xff09;地址长度&#xff1b;IPv6协议具有128位&#xff08;16字节&#xff09;地址长度。 2、地址的表示方法区别&#xff1a;IPv4地址是以小数表示的二进制数。 IPv6地址是以十六进制表…

4.1 读写不同数据源的数据

4.1 读写不同数据源的数据4.1.1 读写数据库数据1、数据库数据获取2、数据库数据存储4.1.2 读写文本文件1、文本文件读取2、文本文件存储4.1.3 读写Excel文件1、Excel文件读取2、Excel文件存储完整代码4.1.1 读写数据库数据 1、数据库数据获取 pandas提供了读取与存储关系型数…

为什么说网络安全行业是 IT 行业最后的红利?

一、为什么选择网络安全&#xff1f; 这几年随着我国《国家网络空间安全战略》《网络安全法》《网络安全等级保护 2.0》等一系列政策/法规/标准的持续落地&#xff0c;网络安全行业地位、薪资随之水涨船高。 未来 3-5 年&#xff0c;是安全行业的黄金发展期&#xff0c;提前踏…

Android OKHttp源码解析

Https是Http协议加上下一层的SSL/TSL协议组成的&#xff0c;TSL是SSL的后继版本&#xff0c;差别很小&#xff0c;可以理解为一个东西。进行Https连接时&#xff0c;会先进行TSL的握手&#xff0c;完成证书认证操作&#xff0c;产生对称加密的公钥、加密套件等参数。之后就可以…