Closed ixxmu closed 1 week ago
Nature文章标题如下
在文章 Fig.5a
a, UMAP of pan-tumour TME and vascular metacells, coloured by annotated cell identity. The dots represent the metacells produced by SuperCell. Bmem, memory B cells.
Science | 同款
https://www.science.org/doi/10.1126/science.adf3786
文章中 Fig. 4A
(A) Cortical NSC subtypes and pseudotime. (B) Region and age proportion of the NSCs (left). Markers for the anterior-enriched PMP22+ RG cell subtype (right).
https://github.com/sestanlab/Macaque_corticogenesis_scRNA-seq
Rstudio | 画图
01
加载单细胞数据
##系统报错改为英文
Sys.setenv(LANGUAGE = "en")
##禁止转化为因子
options(stringsAsFactors = FALSE)
##清空环境
rm(list=ls())
#install.packages('Seurat')
#library(Seurat)
###加载所需要的包
library(Seurat)
library(tidyverse)
library(dplyr)
library(patchwork)
##读取10x的数据
scRNA.counts=Read10X("E:/super.lesson/s2/GSE197177_RAW/ZY_1/")
###创建Seurat对象
scRNA = CreateSeuratObject(scRNA.counts ,
min.cells = 3,project="sampl.1",
min.features = 40)
02
数据预处理
## 数据归一化处理
scRNA1 <- NormalizeData(scRNA1, normalization.method = "LogNormalize",
scale.factor = 10000)
## 找高变基因
scRNA1 <- FindVariableFeatures(scRNA1, selection.method = "vst",
nfeatures = 2000)
## 数据放缩
scale.genes <- rownames(scRNA1)
scRNA1 <- ScaleData(scRNA1, features = scale.genes)
03
降维聚类
## pca降维
scRNA1 <- RunPCA(scRNA1 , features = VariableFeatures(object = scRNA1) )
## 聚类
scRNA1 <- FindNeighbors(scRNA1, dims = 1:20)
scRNA1 <- FindClusters(scRNA1, resolution = 0.5)
## 构建进化树
scRNA1<-BuildClusterTree(scRNA1)
PlotClusterTree(scRNA1)
## unap可视化降维
scRNA_harmony=scRNA1
scRNA_harmony <- RunUMAP(scRNA_harmony, reduction = "pca",
dims = 1:10,n.components = 3L)
## 注意:reduction中umap有三列信息
04
umap维度信息提取
# Extract UMAP information from Seurat Object
umap_1 <- scRNA_harmony[["umap"]]@cell.embeddings[,1]
umap_2 <- scRNA_harmony[["umap"]]@cell.embeddings[,2]
umap_3 <- scRNA_harmony[["umap"]]@cell.embeddings[,3]
umap=as.data.frame(scRNA_harmony@reductions[["umap"]]@cell.embeddings)
plotting.data=cbind(umap,scRNA_harmony@meta.data)
05
三维可视化
colors<-c('#E41A1C','#377EB8','#4DAF4A','#984EA3','#F29403','#F781BF',"#ed1299")
library(scatterplot3d)
# 1. Source the function
source( "E:/super.lesson/lesson9/huage.3D.plot.R" )
# 2. 3D scatter plot
colors.2 <- colors[as.numeric(plotting.data$seurat_clusters)]
s3d <- scatterplot3d(plotting.data[,c(1:3)],angle=40,
axis=T,tick.marks=F,col.axis="black",
color =colors.2 ,col.grid="#dae1f1",
pch = 16,
cex.symbols = 0.5,grid=T, box=FALSE )
06
动态三维图
library(plotly)
plot_ly(data = plotting.data,
x = ~umap_1, y = ~umap_2, z = ~umap_3,
color = ~seurat_clusters,
colors = colors,
type = "scatter3d",
mode = "markers",
marker = list(size = 1, width=2), # controls size of points
# text=~label, #This is that extra column we made earlier for which we will use for cell ID
hoverinfo="text")
强烈推荐,想学生信,复现CNS文章源代码,看👇这个文章:
欢迎关注 | 华哥科研平台
往期精彩内容
亲,写的这么辛苦,记得关注、点赞、打赏哟!
https://mp.weixin.qq.com/s/-vuXRZ9ruVOQWxP6KPEZIQ