Pheatmap:annotation_colors [[colnames(annotation)[i]]]]错误:下标超出范围

时间:2019-03-30 14:25:43

标签: r bioinformatics pheatmap

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 14
        versionName "14.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }...
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:28.0.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testCompile 'junit:junit:4.12'

    implementation 'com.google.android.exoplayer:exoplayer:r2.5.2'
    implementation 'com.nineoldandroids:library:2.4.0'

    implementation 'com.android.support:multidex:1.0.3'
}

错误是:

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")
```

2 个答案:

答案 0 :(得分:1)

您应强制数据框使用行名。

addClass

Something weird in pheatmap (a bug?)

答案 1 :(得分:0)

检查您的数据结构-它们不正确。由another和作为其子集的read.table生成的结构testdataframes。而且您正在尝试将它们输入使用pheatmap的{​​{1}}函数中,该函数与matrix的结构不同。 您可以像这样将对象转换为矩阵:

dataframe

然后,您可以将其输入test_matrix <- data.matrix(test, rownames.force=NA) # change the rownames.force -argument if you want rownames 。如果不起作用,则可以检查被馈送到pheatmap的对象的尺寸。