rm(list=ls())
gc()
getwd()
load("sce.seurat.object.Rdata")
# beep(sound = 10, expr = NULL)
setwd("E:/R/CCA_learning/article_last")
getwd()
{
library(Seurat)
library(ggplot2)
library(clustree)
library(cowplot)
library(dplyr)
library(beepr)}
table(Idents(sce))
# 1.寻找每群的标记基因----
{
sce.markers <- FindAllMarkers(object = sce, only.pos = TRUE,
min.pct = 0.25,
thresh.use = 0.25)
beep(sound = 8, expr = NULL)
}
top10 <- sce.markers %>% group_by(cluster) %>% top_n(n=10,wt=avg_log2FC)
{DoHeatmap(sce, label = F , # 不加label
features = top10$gene,
group.by = "cellType",
assay = "RNA",
group.colors = c("#8dd3c7","#FFA54F","#bebada","#fb8072","#80b1d3","#2E8B57","#b3de69","#fccde5","#696969","#bc80bd") )+ #设置组别颜色
scale_fill_gradientn(colors = c("navy","white","firebrick3"))} %>%
ggsave(filename="top10.png",plot=.,width = 10,height = 15)
# 2.气泡图----
top3sce.markers= sce.markers %>%
group_by(cluster) %>%
slice_max(n = 3, order_by = avg_log2FC)
#气泡图代码----
{
pdf("dotplot.pdf")
DotPlot(sce, features = unique(top3sce.markers$gene) ,
assay='RNA' ) +
coord_flip() + #翻转
theme(panel.grid = element_blank(),
axis.text.x=element_text(angle = 45, hjust = 0.5,vjust=0.5))+ #轴标签
labs(x=NULL,y=NULL) +
guides(size = guide_legend("Percent Expression") )+ #legend
scale_color_gradientn(colours = c("navy","white","firebrick3"))
dev.off()
}
# ggsave(filename="dotplot.png",plot=.,width = 10,height = 15)
save(sce, sce.markers,top3sce.markers,top10, file="KF.all.Rdata")
load("KF.all.Rdata")
VlnPlot(sce,features = 'BUB1',pt.size = 0.5)
VlnPlot(sce,features = 'CLU',pt.size = 0.5)
##怎么脑子突然开窍了,意识到unknown细胞群没注释 好了 已经解决了 下午的ll 别再难过了----
top10 = sce.markers %>%
group_by(cluster) %>%
slice_max(n = 10, order_by = avg_log2FC)
脑子混乱的乱记一通
最新推荐文章于 2024-11-15 16:03:08 发布