添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
sce_SCENIC <- open_loom("sce_SCENIC.sce_SCENIC")
# exprMat <- get_dgem(sce_SCENIC)#从sce_SCENIC文件提取表达矩阵
# exprMat_log <- log2(exprMat+1) # log处理
regulons_incidMat <- get_regulons(sce_SCENIC, column.attr.name="Regulons")
regulons <- regulonsToGeneLists(regulons_incidMat)
class(regulons)
regulonAUC <- get_regulons_AUC(sce_SCENIC, column.attr.name='RegulonsAUC')
regulonAucThresholds <- get_regulon_thresholds(sce_SCENIC)
第一个可视化: RSS分析,查看细胞类型特异性转录因子,需要先加载seurat对象,提取metadata信息,并进行分析!默认是点图!
human_data <- readRDS("~/Pyscenic/human_data.rds")
cellinfo <- [email protected][,c('celltype','group',"nFeature_RNA","nCount_RNA")]#细胞meta信息
colnames(cellinfo)=c('celltype', 'group','nGene' ,'nUMI')
######计算细胞特异性TF
cellTypes <-  as.data.frame(subset(cellinfo,select = 'celltype'))
selectedResolution <- "celltype"
sub_regulonAUC <- regulonAUC
rss <- calcRSS(AUC=getAUC(sub_regulonAUC),
               cellAnnotation=cellTypes[colnames(sub_regulonAUC),
                                        selectedResolution])
rss=na.omit(rss)
rssPlot <- 
  plotRSS(
  zThreshold = 3,
  cluster_columns = FALSE,
  order_rows = TRUE,
  thr=0.1,
  varName = "cellType",
  col.low = '#330066',
  col.mid = '#66CC66',
  col.high = '#FFCC33')
rssPlot
rss_data <- rssPlot$plot$data
devtools::install_github("XiaoLuo-boy/ggheatmap")
library(ggheatmap)
library(reshape2)
rss_data<-dcast(rss_data, 
                Topic~rss_data$cellType,
                value.var = 'Z')
rownames(rss_data) <- rss_data[,1]
rss_data <- rss_data[,-1]
colnames(rss_data)
col_ann <- data.frame(group= c(rep("Neutrophil",1),
                               rep("Macrophage",1),
                               rep("mDC",1),
                               rep("T cell",1),
                               rep("Mast",1)))#列注释
rownames(col_ann) <- colnames(rss_data)
groupcol <- c("#D9534F", "#96CEB4", "#CBE86B", "#EDE574", "#0099CC")
names(groupcol) <- c("Neutrophil","Macrophage","mDC", "T cell","Mast")
col <- list(group=groupcol)
text_columns <- sample(colnames(rss_data),0)#不显示列名
p <- ggheatmap(rss_data,color=colorRampPalette(c('#1A5592','white',"#B83D3D"))(100),
               cluster_rows = T,cluster_cols = F,scale = "row",
               annotation_cols = col_ann,
               annotation_color = col,
               legendName="Relative value",
               text_show_cols = text_columns)
             
next_regulonAUC <- regulonAUC[,match(colnames(human_data),colnames(regulonAUC))]
dim(next_regulonAUC)
regulon_AUC <- regulonAUC@NAMES
[email protected] = cbind([email protected] ,t(assay(next_regulonAUC[regulon_AUC,])))
#自己选定感兴趣的或者比较重要的转录因子,这里我是随机的
TF_plot <- c("ZNF561(+)","FOXP3(+)","YY1(+)","HOXB2(+)",
             "TBX21(+)","TCF12(+)","STAT2(+)","SOX21(+)",
             "RBBP5(+)","NR2F6(+)","NELFE(+)","MAFG(+)")
DotPlot(human_data, features = TF_plot)+
  theme_bw()+
  theme(panel.grid = element_blank(), 
        axis.text.x=element_text(hjust =1,vjust=1, angle = 45))+
  labs(x=NULL,y=NULL)+guides(size=guide_legend(order=3))
DotPlot(human_data, features = TF_plot, group.by = 'group')+
  theme_bw()+
  theme(panel.grid = element_blank(), 
        axis.text.x=element_text(hjust =1,vjust=1, angle = 45))+
  theme(legend.direction = "horizontal", 
        legend.position = "bottom")+
  labs(x=NULL,y=NULL)
cellsPerGroup <- split(rownames(cellTypes), 
                       cellTypes[,selectedResolution])
regulonActivity_byGroup <- sapply(cellsPerGroup,
                                  function(cells) 
                                  rowMeans(getAUC(sub_regulonAUC)[,cells]))
regulonActivity_byGroup_Scaled <- t(scale(t(regulonActivity_byGroup),
                                          center = T, scale=T)) 
regulonActivity_byGroup_Scaled=na.omit(regulonActivity_byGroup_Scaled)
                            风流倜傥的烈马
                            ‘>=‘ not supported between instances of ‘list‘ and ‘float‘_<' not supported between instances of 'li
                        3 小时前