请问我在进行单细胞Heatmap过程中,总是出现这一步报错,请问是什么导致的。
cs_data <- as.matrix(exp[sc_marker$gene, names(new_celltype)])
Error in h(simpleError(msg, call)) :
在为'as.matrix'函数选择方法时评估'x'参数出了错: subscript out of bounds
library(Seurat)
library(stringr)
library(dplyr)
all.markers <- FindAllMarkers(scedata,
only.pos = TRUE,
min.pct = 0.25,
logfc.threshold = 0.75)
markers <- c("Rps27rt",
"Tmsb4x",
"Rps12.ps3",
"Rpl9.ps6",
"Gm10073",
"Wdr89",
"Gm47283",
"Rpl27.ps3",
"Zfp36l2",
"AC149090.1",
"Camk2b",
"Rpl10.ps3",
"Txnip",
"mt.Co1",
"Cx3cr1",
"Hbb.bs",
"Lat",
"Cd3e",
"Tulp4",
"C1S",
"COL6A2",
"CXCL13",
"CFD",
"CCL5",
"CCL4",
"CXCR4",
"PTPRC",
"LYZ",
"CD52",
"Cd3e",
"Hbb.bt",
"Slfn4",
"Ifi27l2a",
"Mob3a",
"Arl4c",
"Eif1",
"Pura",
"Dkc1",
"Rnf130",
"Rnf213",
"Gem",
"Gm13212",
"Itgam",
"Gimap4",
"Arhgdib",
"Hgsnat",
"Irf7",
"Tigd2",
"Brix1",
"Uqcrh",
"Nsa2",
"Cuedc1"
)
sc_marker <- all.markers[markers,]
exp <- GetAssayData(scedata, slot = "counts")
exp <- log10(exp + 1)
head(scedata$celltype)
new_celltype <- sort(scedata$celltype)
head(new_celltype)
cs_data <- as.matrix(exp[sc_marker$gene, names(new_celltype)])
ac=data.frame(cluster=new_celltype)
rownames(ac)=colnames(cs_data)
library(pheatmap)
pheatmap(cs_data,show_colnames =F,show_rownames = T,
cluster_rows = F,
cluster_cols = F,
annotation_col=ac,
border_color = "black")
library(ComplexHeatmap)
color = paletteer_d("ggsci::nrc_npg")[c(1,3,4,2,5)]
names(color) <- levels(new_celltype)
top_anno <- HeatmapAnnotation(cluster=anno_block(gp=gpar(fill=color),
labels = levels(new_celltype),
labels_gp = gpar(cex=0.5,color='white',fontsize = 18)))
Heatmap(cs_data,
cluster_rows = FALSE,
cluster_columns = FALSE,
show_column_names = FALSE,
show_row_names = T,
column_split = new_celltype,
top_annotation = top_anno,
column_title = NULL,
heatmap_legend_param = list(
title='Expression',
title_position='leftcenter-rot'),
col = colorRampPalette(c("white","#66CCFF","#333366"))(100),
border = "black",
row_names_gp = gpar(fontsize = 8))
cs_data <- as.matrix(exp[sc_marker$gene, names(new_celltype)])
Error in h(simpleError(msg, call)) :
在为'as.matrix'函数选择方法时评估'x'参数出了错: subscript out of bounds
啊,你能否把原始的代码发给我看一下吗 这个
是否需要data文件