偷偷问一下,关注了吗?
内容获取
1、购买打包合集(2025KS微信VIP付费合集),价格感人,可以加入微信VIP群(答疑交流群,甚至有小伙伴觉得群比代码更好),可以获取建号以来所有内容,群成员专享视频教程,提前更新,其他更多福利!
2、《KS科研分享与服务》公众号有QQ群,进入门槛是20元(完全是为了防止白嫖党,请理解),请考虑清楚。群里有免费推文的注释代码和示例数据(终身拥有),没有付费内容,群成员福利是购买单个付费内容半价!
需要者详情请联系作者(非需要者勿扰,处理太费时间):
玩转单细胞(16):Scanpy单细胞h5ad数据转化为Seurat对象
玩转单细胞(17):差异基因分析可以舍弃一些没必要的基因-例如MT..RPL..
这个问题我们之前提到过,很多小伙伴可能看到某些文章中这样的可视化,很感兴趣,其实熟悉python分析的小伙伴一眼就可以看出是scanpy出图,虽然R也能实现这样的效果,但是自从我们集全了seurat转h5ad(单细胞seurat V5转V4格式及seurat转为h5ad格式),以及h5ad转seurat之后(玩转单细胞(16):Scanpy单细胞h5ad数据转化为Seurat对象),这都不是问题了,想要这种风格的作图,直接转化格式即可!
(reference:Molecular logic for cellular specializations that initiate the auditory parallel processing pathways)
setwd('./data_analysis/Gene_NMF/')
# devtools::install_github("cellgeni/sceasy")
library(sceasy)
library(reticulate)
use_condaenv('sceasy')
loompy <- reticulate::import('loompy')
uterus <- readRDS("~/data_analysis/Gene_NMF/uterus.rds")
sceasy::convertFormat(uterus, from="seurat", to="anndata", outFile='uterus.h5ad')
#plot TSNE
import scanpy as sc
import anndata
#这里我seurat的数据是TSNE降维
uterus = anndata.read_h5ad('./uterus.h5ad')
sc.pl.tsne(
uterus,
color=["celltype"],
frameon=False,
ncols=1,)
#plot marker gene dotplot
#每种celltype对应的marker gene
markers = {'Smooth muscle cells':['ACTA2', 'RGS5'],
'Macrophages':['MS4A6A','CD68','LYZ'],
'Lymphocytes':['CCL5','STK17B','PTPRC'],
'Stromal fibroblasts':['DCN', 'COL6A3', 'LUM'],
'Endothelial cells':['PECAM1','PCDH17', 'VWF'],
'Unciliated epithelial cells':['EPCAM', 'CDH1'],
'Ciliated epithelial cells':['FOXJ1','CDHR3','DYDC2'],}
sc.pl.dotplot(uterus, markers, 'celltype',dendrogram=True)
当然了,也有小伙伴完全没有接触过python,想用R做出这样的效果,不必担心,优秀的老俊俊推出过R版的包,实现scanpy的效果。更多参数请详细阅读帮助函数。
其他优秀可视化参考:(https://github.com/junjunlab/scRNAtoolVis)
#安装包
install.packages('devtools')
devtools::install_github('junjunlab/scRNAtoolVis')
library(Seurat)
library(ggplot2)
library(dplyr)
library(scRNAtoolVis)
uterus <- readRDS("D:/KS项目/公众号文章/uterus.rds")
DefaultAssay(uterus) <- "RNA"
markers <- c("ACTA2", "RGS5",
"MS4A6A", "CD68","LYZ",
"CCL5", "STK17B","PTPRC",
"DCN", "COL6A3", "LUM",
"PECAM1","PCDH17", "VWF",
"EPCAM", "CDH1",
"FOXJ1","CDHR3","DYDC2")
markers_plot <- data.frame(cluster = c(rep("Smooth muscle cells",2),
rep("Macrophages",3),
rep("Lymphocytes",3),
rep("Stromal fibroblasts",3),
rep("Endothelial cells",3),
rep("Unciliated epithelial cells",2),
rep("Ciliated epithelial cells",3)),
gene = markers)
jjDotPlot(object = uterus,
markerGene = markers_plot,
anno = T,
id = 'celltype',
textSize = 10,
base_size= 10,
plot.margin = c(5,3,3,3))
关注我们获取精彩内容:
关注不迷路:扫描下面二维码关注公众号!
B站视频号链接:https://space.bilibili.com/471040659?spm_id_from=333.1007.0.0
关注 KS科研分享与服务,
认清正版优质内容和服务!
优质内容持续输出,物超所值!
合作联系:ks_account@163.com