• 主页
  • 课程

    关于课程

    • 课程归档
    • 成为一名讲师
    • 讲师信息
    教学以及管理操作教程

    教学以及管理操作教程

    ¥1,000.00 ¥100.00
    阅读更多
  • 特色
    • 展示
    • 关于我们
    • 问答
  • 事件
  • 个性化
  • 博客
  • 联系
  • 站点资源
    有任何问题吗?
    (00) 123 456 789
    weinfoadmin@weinformatics.cn
    注册登录
    恒诺新知
    • 主页
    • 课程

      关于课程

      • 课程归档
      • 成为一名讲师
      • 讲师信息
      教学以及管理操作教程

      教学以及管理操作教程

      ¥1,000.00 ¥100.00
      阅读更多
    • 特色
      • 展示
      • 关于我们
      • 问答
    • 事件
    • 个性化
    • 博客
    • 联系
    • 站点资源

      未分类

      • 首页
      • 博客
      • 未分类
      • 单细胞多样本整合分析

      单细胞多样本整合分析

      • 发布者 jiangxingyu
      • 分类 未分类
      • 日期 2022年5月24日
      测试开头
      单细胞多样本整合分析单细胞多样本整合分析 今天是生信星球陪你的第870天单细胞多样本整合分析

         大神一句话,菜鸟跑半年。我不是大神,但我可以缩短你走弯路的半年~

         就像歌儿唱的那样,如果你不知道该往哪儿走,就留在这学点生信好不好~

         这里有豆豆和花花的学习历程,从新手到进阶,生信路上有你有我!

      代码主要来自:https://satijalab.org/seurat/articles/integration_introduction.html

      1.数据准备

      不得不说,网速的限制是无处不在啊。这个数据有点大, 官网给的下载方式是用代码,在大陆基本上不可能成功咯。还是把包下载到本地,用本地安装R包的方法靠谱一点

      rm(list = ls())
      library(Seurat)
      library(SeuratData)
      library(patchwork)
      # install dataset
      #InstallData("ifnb")
      #install.packages("ifnb.SeuratData_3.1.0.tar.gz",repos = NULL)
      # load dataset
      ifnb = LoadData("ifnb")

      2.了解和拆分数据

      因为是用来做整合的例子,而内置数据是个整体的数据,所以要把它拆分掉。

      # split the dataset into a list of two seurat objects (stim and CTRL)
      head(ifnb@meta.data)
      ##                   orig.ident nCount_RNA nFeature_RNA stim seurat_annotations
      ## AAACATACATTTCC.1 IMMUNE_CTRL       3017          877 CTRL          CD14 Mono
      ## AAACATACCAGAAA.1 IMMUNE_CTRL       2481          713 CTRL          CD14 Mono
      ## AAACATACCTCGCT.1 IMMUNE_CTRL       3420          850 CTRL          CD14 Mono
      ## AAACATACCTGGTA.1 IMMUNE_CTRL       3156         1109 CTRL                pDC
      ## AAACATACGATGAA.1 IMMUNE_CTRL       1868          634 CTRL       CD4 Memory T
      ## AAACATACGGCATT.1 IMMUNE_CTRL       1581          557 CTRL          CD14 Mono
      table(ifnb@meta.data$stim)
      ## 
      ## CTRL STIM 
      ## 6548 7451
      ifnb.list <- SplitObject(ifnb, split.by = "stim")
      length(ifnb.list)
      ## [1] 2

      可以看到ctrl和stim组各自的细胞数量。

      3.完成整合

      两个拆分后的对象分别Normalize,找高变化基因,寻找锚点,结合在一起。

      # normalize and identify variable features for each dataset independently
      ifnb.list <- lapply(X = ifnb.list, FUN = function(x) {
        x <- NormalizeData(x)
        x <- FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
      })

      # select features that are repeatedly variable across datasets for integration
      features <- SelectIntegrationFeatures(object.list = ifnb.list)
      immune.anchors <- FindIntegrationAnchors(object.list = ifnb.list, anchor.features = features)
      # this command creates an 'integrated' data assay
      immune.combined <- IntegrateData(anchorset = immune.anchors)
      # specify that we will perform downstream analysis on the corrected data note that the
      # original unmodified data still resides in the 'RNA' assay
      DefaultAssay(immune.combined) <- "integrated"

      之后的分析默认使用整合后的数据integrated。

      4.常规的降维聚类分群

      # Run the standard workflow for visualization and clustering
      immune.combined <- ScaleData(immune.combined, verbose = FALSE)
      immune.combined <- RunPCA(immune.combined, npcs = 30, verbose = FALSE)
      immune.combined <- RunUMAP(immune.combined, reduction = "pca", dims = 1:30)
      immune.combined <- FindNeighbors(immune.combined, reduction = "pca", dims = 1:30)
      immune.combined <- FindClusters(immune.combined, resolution = 0.5)
      ## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
      ## 
      ## Number of nodes: 13999
      ## Number of edges: 569703
      ## 
      ## Running Louvain algorithm...
      ## Maximum modularity in 10 random starts: 0.9057
      ## Number of communities: 16
      ## Elapsed time: 1 seconds
      # Visualization
      p1 <- DimPlot(immune.combined, reduction = "umap", group.by = "stim")
      p2 <- DimPlot(immune.combined, reduction = "umap", label = TRUE, repel = TRUE)
      p1 + p2
      单细胞多样本整合分析

      5.singleR注释

      官网使用的是根据marker基因手动识别细胞类型,设置了标签。我这里用singleR偷个懒。。。
      singleR分的类比较粗糙,右边那一大片都是单核细胞,没有那么具体。而手动的话可以继续细分。

      # 注释
      library(celldex)
      library(SingleR)
      #ref <- celldex::HumanPrimaryCellAtlasData()
      ref <- get(load("single_ref/ref_Hematopoietic.RData"))
      library(BiocParallel)
      pred.scRNA <- SingleR(test = immune.combined@assays$integrated@data, 
                            ref = ref,
                            labels = ref$label.main, 
                            clusters = immune.combined@active.ident)
      pred.scRNA$pruned.labels
      ##  [1] "Monocytes"       "CD8+ T cells"    "CD4+ T cells"    "Monocytes"      
      ##  [5] "B cells"         "CD8+ T cells"    "NK cells"        "CD4+ T cells"   
      ##  [9] "Monocytes"       "B cells"         "CD8+ T cells"    "Dendritic cells"
      ## [13] "Monocytes"       "Monocytes"       "HSCs"
      plotScoreHeatmap(pred.scRNA, clusters=pred.scRNA@rownames, fontsize.row = 9,show_colnames = T)
      单细胞多样本整合分析
      new.cluster.ids <- pred.scRNA$pruned.labels
      names(new.cluster.ids) <- levels(immune.combined)
      levels(immune.combined)
      ##  [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14"
      immune.combined <- RenameIdents(immune.combined,new.cluster.ids)
      levels(immune.combined)
      ## [1] "Monocytes"       "CD8+ T cells"    "CD4+ T cells"    "B cells"        
      ## [5] "NK cells"        "Dendritic cells" "HSCs"
      UMAPPlot(object = immune.combined, pt.size = 0.5, label = TRUE)
      单细胞多样本整合分析
      如果因为代码看不懂,而跟不上正文的节奏,可以来找我,系统学习。以下课程都是循环开课。下一期的时间,点进去咨询微信咯
      生信零基础入门学习小组
      生信入门班(四周线上直播课)
      数据挖掘班(医生/医学生首选)
      测试结尾

      请关注“恒诺新知”微信公众号,感谢“R语言“,”数据那些事儿“,”老俊俊的生信笔记“,”冷🈚️思“,“珞珈R”,“生信星球”的支持!

      • 分享:
      作者头像
      jiangxingyu

      上一篇文章

      mde包,超赞的数据缺失值探索与处理R包
      2022年5月24日

      下一篇文章

      看深度学习如何发高分生信文章
      2022年6月21日

      你可能也喜欢

      2-1675088548
      lncRNA和miRNA生信分析系列讲座免费视频课和课件资源包,干货满满
      30 1月, 2023
      9-1675131201
      如何快速批量修改 Git 提交记录中的用户信息
      26 1月, 2023
      5-1660909989
      scanpy官方教程2022|03-scanpy包核心绘图功能
      19 8月, 2022

      搜索

      分类

      • R语言
      • TCGA数据挖掘
      • 单细胞RNA-seq测序
      • 在线会议直播预告与回放
      • 数据分析那些事儿分类
      • 未分类
      • 生信星球
      • 老俊俊的生信笔记

      投稿培训

      免费

      alphafold2培训

      免费

      群晖配置培训

      免费

      最新博文

      Nature | 单细胞技术揭示衰老细胞与肌肉再生
      301月2023
      lncRNA和miRNA生信分析系列讲座免费视频课和课件资源包,干货满满
      301月2023
      如何快速批量修改 Git 提交记录中的用户信息
      261月2023
      logo-eduma-the-best-lms-wordpress-theme

      (00) 123 456 789

      weinfoadmin@weinformatics.cn

      恒诺新知

      • 关于我们
      • 博客
      • 联系
      • 成为一名讲师

      链接

      • 课程
      • 事件
      • 展示
      • 问答

      支持

      • 文档
      • 论坛
      • 语言包
      • 发行状态

      推荐

      • iHub汉语代码托管
      • iLAB耗材管理
      • WooCommerce
      • 丁香园论坛

      weinformatics 即 恒诺新知。ICP备案号:粤ICP备19129767号

      • 关于我们
      • 博客
      • 联系
      • 成为一名讲师

      要成为一名讲师吗?

      加入数以千计的演讲者获得100%课时费!

      现在开始

      用你的站点账户登录

      忘记密码?

      还不是会员? 现在注册

      注册新帐户

      已经拥有注册账户? 现在登录

      close
      会员购买 你还没有登录,请先登录
      • ¥99 VIP-1个月
      • ¥199 VIP-半年
      • ¥299 VIP-1年
      在线支付 激活码

      立即支付
      支付宝
      微信支付
      请使用 支付宝 或 微信 扫码支付
      登录
      注册|忘记密码?