Pheatmap:Error in annotation_colors[[colnames(annotation)[i]]] : subscript out of bounds
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(pheatmap) another<-read.table("~/Desktop/tcga3dcategorized.csv",sep=',',header=FALSE) test<-another[1:3] labels<-another[4] colnames(test)=c("Dim 1","Dim 2","Dim 3") annotation_row=data.frame(CancerType=factor(labels)) ann_colors=list(CancerType=c(KIRC="red", UCEC="#B2509E",LUSC="#D49DC7", LGG="#C1A72F",PCPG="#E8C51D",HNSC="#F9ED32",CESC="#104A7F",ESCA="#9EDDF9", BRCA="#007EB5",THCA="#CACCDB",PRAD="#6E7BA2",MESO="#DAF1FC",PAAD="#00AEEF", LUAD="#F6B667",LAML="#D97D25",UVM="#FBE3C7",GBM="#F89420",READ="#97D1A9", SKCM="#009444",KIRP="#754C29",COAD="#CEAC8F",LIHC="#3953A4",SARC="#BBD642", OV="#00A99D",BLCA="#D3C3E0",STAD="#A084BD",TGCT="#542C88",ACC="#FAD2D9", THYM="#ED1C24",KICH="#F8AFB3",DLBC="#EA7075",UCS="#7E1918",CHOL="#BE1E2D")) pheatmap(test,annotation_row=annotation_row,annotation_colors=ann_colors,main="title") ``` |
错误是:
1 2 | Error in annotation_colors[[colnames(annotation)[i]]] : subscript out of bounds |
您应该强制数据框使用行名。
1 2 | # after read.table rownames(another) <- paste0("row_", seq(nrow(another))) |
看看Pheatmap中有些奇怪的东西(有错误吗?)
检查您的数据结构-它们不正确。 由
您可以像这样将对象转换为矩阵:
1 | test_matrix <- data.matrix(test, rownames.force=NA) # change the rownames.force -argument if you want rownames |
然后,您可以将其输入到