细胞周期及可视化

本文介绍了如何使用Seurat4.0进行单细胞数据格式转换,包括从Seurat、SingleCellExperiment和AnnData等格式转换,并展示了如何通过项目细胞周期空间、TP53表达和细胞周期阶段估计来可视化细胞周期。还演示了如何使用tSNE和UMAP进行嵌入散点图绘制。
摘要由CSDN通过智能技术生成

Seurat4.0系列教程20:单细胞对象的格式转换

常见单细胞数据格式的转换:Seurat, SingleCellExperiment, AnnData

单细胞测序技术-细胞周期

好难哦 呜呜呜 想偷懒不学结构,就会抓瞎,希望能抓瞎到结束不出问题。我之后一定会好好认结构的。。。

#细胞周期可视化----
#很开心 好像找到了原文很吻合的推文
rm(list=ls())
gc()
getwd()
# setwd("E:/R/CCA_learning/fig7")
load("KF.all.Rdata")

# 一、装包----
# BiocManager::install("tricycle")
# BiocManager::install("scater")
{
  library(tricycle)  
library(scattermore)
library(scater)
  }

# 二、创建一个新的SingleCellExperiment对象(af.sce),----
# 并对其进行细胞周期的投影。确保每个单细胞数据都会被关联到一个特定的细胞周期阶段,有助于后续的分析。
af.sce = as.SingleCellExperiment(sce)
af.sce <- project_cycle_space(af.sce,
                              species = c("human"), 
                              gname.type = "SYMBOL")

# 三、绘制细胞周期位置着色的嵌入散射图----
scater::plotReducedDim(af.sce, dimred = "tricycleEmbedding") +
  labs(x = "Projected PC1", y = "Projected PC2") +
  ggtitle(sprintf("Projected cell cycle space (n=%d)",
                  ncol(af.sce))) +
  theme_bw(base_size = 14)
af.sce <- estimate_cycle_position(af.sce)
fit.l <- fit_periodic_loess(af.sce$tricyclePosition,
                            assay(af.sce, 'logcounts')["TP53",],
                            plot = TRUE,
                            x_lab = "Cell cycle position \u03b8", y_lab = "log2(TP53)",
                            fig.title = paste0("Expression of TP53 along \u03b8 (n=",
                                               ncol(af.sce), ")"))
fit.l$fig + theme_bw(base_size = 14)
af.sce <- estimate_Schwabe_stage(af.sce,
                                 gname.type = 'SYMBOL',
                                 species = 'human')
table(af.sce$CCStage %>% is.na())                                 
pdf(file = "07-cell_cycle_density.pdf",width =8,height = 6)
plot_ccposition_den(af.sce$tricyclePosition,
                    af.sce$orig.ident, 'sample', type = "circular",
                    bw = 10,  fig.title = "Density of cell cycle (\u03b8)") +
  theme_bw(base_size = 14)
dev.off()  

# 四、绘制可视化tSNE/UMAP散点图----
library(Seurat)

# 创建 Seurat 对象
seurat_obj <- as.Seurat(af.sce, counts = "counts", data = "logcounts")
Idents(seurat_obj)=seurat_obj$CCStage

pdf(file = "07-cellcycle.scRNA.TSEN.pdf",width =7.5,height = 5.5)
DimPlot(seurat_obj, reduction = "TSNE", label = T, label.size = 3.5,pt.size = 2.5)+theme_classic()+theme(panel.border = element_rect(fill=NA,color="black", size=0.5, linetype="solid"),legend.position = "right")
dev.off()
pdf(file = "07-cellcycle.scRNA.UMAP.pdf",width =7.5,height = 5.5)
DimPlot(seurat_obj, reduction = "UMAP", label = T, label.size = 3.5,pt.size = 2.5)+theme_classic()+theme(panel.border = element_rect(fill=NA,color="black", size=0.5, linetype="solid"),legend.position = "right")
dev.off()

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值