SingleR包通过利用纯细胞类型的参考转录组数据集独立推断每个单细胞的起源细胞,从单细胞RNA测序数据执行无偏细胞类型识别。

1. 载入单细胞数据

# if (!requireNamespace("BiocManager", quietly = TRUE))
#   install.packages("BiocManager")
#
# BiocManager::install("scRNAseq")library(scRNAseq) # Collection of Public Single-Cell RNA-Seq Datasets
ls("package:scRNAseq")
hESCs <- LaMannoBrainData('human-es')
# 取前100个单细胞的表达谱做演示
hESCs <- hESCs[,1:100]
assays(hESCs)
assay(hESCs)[1:4,1:4]#assay(x, i)
#is simply a convenience function which is equivalent to
#assays(x)[[i]]
#assays(se)[[1]][1:5, 1:5]
#assay(se)[1:5, 1:5]

2. 载入细胞类型注释数据集

celldex包提供一组参考表达数据集,这些数据集带有精确的细胞类型标签,用于单细胞数据的自动注释或批量RNA序列的反卷积等过程。

library(celldex)hpca.se <- HumanPrimaryCellAtlasData()
hpca.se

3. 注释细胞类型

library(SingleR)
ls("package:SingleR")# library(BiocStyle)
# browseVignettes("BiocStyle")# SingleR Returns the best annotation for each cell in a test dataset,
# given a labelled reference dataset in the same feature space.
# • scores, a numeric matrix of correlations at the specified quantile for each label (column) in
# each cell (row). This will contain NAs if multiple references were supplied to trainSingleR
# with recompute=TRUE.
# • first.labels, a character vector containing the predicted label before fine-tuning. Only
# added if fine.tune=TRUE.
# • tuned.scores, a DataFrame containing first and second.
# These are numeric vectors containing the best and next-best scores
# at the final round of fine-tuning for each cell. Only added if fine.tune=TRUE.
# • labels, a character vector containing the predicted label based on the maximum entry in
# scores.
# • pruned.labels, a character vector containing the pruned labels where “low-quality”. els are
# replaced with NAs. Only added if prune=TRUE.## SingleR() expects reference datasets to be normalized and log-transformed.
library(scuttle)
hESCs <- logNormCounts(hESCs)
hpca.se <- logNormCounts(hpca.se)pred.hesc <- SingleR(test = hESCs, ref = hpca.se, assay.type.test="logcounts",labels = hpca.se$label.main)
class(pred.hesc) # "DFrame"
dim(pred.hesc) # 行为单细胞名,列为特征,其中label是细胞类型
colnames(pred.hesc)
head(pred.hesc)
table(pred.hesc$labels)
#Create a heatmap of the SingleR assignment scores across all cell-label combinations.
plotScoreHeatmap(pred.hesc)
#Plot the distribution of deltas (i.e., the gap between the assignment score
#for the assigned label and those of the remaining labels) across cells assigned to each reference label.
plotDeltaDistribution(pred.hesc, ncol = 3)summary(is.na(pred.hesc$pruned.labels))

4. 用一个SingleCellExperiment对象的细胞类型label去注释另一个SingleCellExperiment

library(scRNAseq)
sceM <- MuraroPancreasData()# One should normally do cell-based quality control at this point, but for
# brevity's sake, we will just remove the unlabelled libraries here.
sceM <- sceM[,!is.na(sceM$label)]# SingleR() expects reference datasets to be normalized and log-transformed.
# scuttle包:Provides basic utility functions for performing single-cell analyses,
#focusing on simple normalization, quality control and data transformations.
#Also provides some helper functions to assist development of other packages.library(scuttle)
sceM <- logNormCounts(sceM)## -----------------------------------------------------------------------------
sceG <- GrunPancreasData()
sceG <- sceG[,colSums(counts(sceG)) > 0] # Remove libraries with no counts.
sceG <- logNormCounts(sceG)
sceG <- sceG[,1:100]## -----------------------------------------------------------------------------
pred.grun <- SingleR(test=sceG, ref=sceM, labels=sceM$label, de.method="wilcox")
table(pred.grun$labels)

5. 可视化

## -----------------------------------------------------------------------------
plotScoreHeatmap(pred.grun)## -----------------------------------------------------------------------------
plotDeltaDistribution(pred.grun, ncol = 3)## -----------------------------------------------------------------------------
summary(is.na(pred.grun$pruned.labels))## -----------------------------------------------------------------------------
## 不同细胞类型的marker基因
all.markers <- metadata(pred.grun)$de.genes
sceG$labels <- pred.grun$labels# Beta cell-related markers
library(scater)
plotHeatmap(sceG, order_columns_by="labels",features=unique(unlist(all.markers$beta))) 

SingleR包注释单细胞数据相关推荐

  1. 这个R包自动注释单细胞数据的平均准确率为83%,使用后我的结果出现了点问题|附全代码...

    估计大家都有一个这样的感觉就是单细胞数据具有一定的数据依赖性,好多的marker在相同的组织中,别人的数据就表达的十分明显,在你的数据中就是不太显著,比如NK细胞的KLRF1.于是,细胞自动注释也就应 ...

  2. scuttle包对单细胞数据质控

    scuttle软件包为单细胞组学数据分析提供了一些实用功能.这包括一些计算和过滤质量控制的简单方法:基础数据转换涉及各种类型的缩放规范化:以及跨单元或功能的灵活聚合. 1. 载入SingleCellE ...

  3. linux数据包注释,关于 linux中TCP数据包(SKB)序列号的小笔记

    关于  SKB序列号的小笔记 为了修改TCP协议,现在遇到了要改动tcp分组的序列号,但是只是在tcp_sendmsg函数中找到了SKB的end_seq  一直没有找到seq 不清楚在那里初始化了,就 ...

  4. R语言分析单细胞数据Day1——下载Seurat包并进行预处理(一)

    Task.1 安装Seurat,准备处理single cell data 安装Seurat时,只能安装3.2.3以下的版本,太高就不兼容! install.packages('remotes') %安 ...

  5. 一个R包完成单细胞基因集富集分析 (全代码)

    singleseqgset | 单细胞RNA-Seq基因集富集分析 NGS系列文章包括NGS基础.转录组分析 (Nature重磅综述|关于RNA-seq你想知道的全在这).ChIP-seq分析 (Ch ...

  6. 让你的单细胞数据动起来!|iCellR(二)

    前情回顾:让你的单细胞数据动起来!|iCellR(一) 在上文我们已经基本完成了聚类分析和细胞在不同条件下的比例分析,下面继续开始啦,让你看看iCellR的强大! 1. 每个cluster的平均表达量 ...

  7. 使用对比学习处理大规模多模态单细胞数据

    目录 摘要 引言 Results Overview of Concerto 对比学习的embedding通过微调显著提高了自动细胞分类的性能,并支持跨组织的新细胞类型发现. 其他结果 摘要 单细胞数据 ...

  8. 使用自动和手动方法注释单细胞转录组图谱的指南

    目录 摘要 引言 自动注释 Marker-based automatic annotation Reference-based automatic cell annotation 细化自动注释 手动注 ...

  9. TCGAbiolinks包下载TCGA数据

    ​​​​​​Bioconductor的TCGAbiolinks包用于GDC数据综合分析的R/Bioconductor软件包,本文主要展示下载数据集和代码. 1.   包的加载 # if (!requi ...

最新文章

  1. android 新分区 挂载,android 新增分区以及挂载方法-Go语言中文社区
  2. 下次激活策略10_巅峰武侠卡牌巨制手游乱世江湖1元商城特权bt版今日10:00上线_乱世江湖...
  3. Day11多态部分-1 【1.1 多态的体现】
  4. [res].xml格式
  5. Java程序员需要掌握的计算机底层知识(三):进程、线程、纤程、中断
  6. 为什么“三次握手,四次挥手”?
  7. ASP.NET Web API 异常日志记录
  8. 关于java.sql.SQLRecoverableException: Closed Connection异常的解决方案(转)
  9. 前端面试之那些稀奇古怪的问题
  10. hp ux安装oracle 11g,HP UX安装oracle 11g asm扫不到盘
  11. ansys16.0安装教程
  12. 关于opengl 编程指南中使用几何着色器渲染毛发的分析
  13. 华为防火墙NAT分类(源地址转换和目标地址转换)
  14. js substring、substr和slice 截取字符串
  15. css伪元素实现箭头和关闭及环形实心圆点
  16. Excel的文件打开特别慢,xls文件特别大解决一例
  17. outlook ios日历_如何从Outlook 2013中的日历中删除假期
  18. 【修仙境界】等级划分
  19. jQuery 关键字搜索(自动完成效果,autocomplete)
  20. 基于555定时器的24秒计时器

热门文章

  1. https 请求白屏_记一次HTTPS性能优化
  2. Linux下进程间通信——管道
  3. CondLaneNet:基于条件卷积的自顶向下车道检测框架
  4. php7降到5.6,如何在Fedora 25上从php 7降级到5.6
  5. corrplot包绘制相关性图
  6. 应用心理学跨考计算机难不难,跨专业心理学考研难不难 主要学什么
  7. 基于ggplot2的解剖图和组织模块可视化
  8. JGG | 肠道细菌加重小分子量卡拉胶诱发的直肠炎症
  9. 关于植物和共生微生物,这116张PPT讲明白了(值得收藏!)
  10. MPB:南农金巍等-​​​瘤胃甲烷菌的分离培养与保存