脑子混乱的乱记一通

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)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值