按LabRow排序热图行

时间:2019-09-09 15:54:16

标签: r ggplot2 heatmap

我从FoldChange数据集(176x10)中获得了一个热图,并使用另一个data.frame(176x2)将其标记为标签,其中我只有基因(主数据集的行名)及其产生的蛋白质缩写。

尽管有176个不同的基因,但大多数都产生相同的蛋白质,所以我有22个不同的缩写(行标签)。

我想按蛋白质缩写对行进行分组。

这是我正在运行的代码,其中teste是主要data.frame,而ident是标识data.frame:

#crio minha paleta de cores do heatmap
my_palette <- colorRampPalette(c("grey92", "green", "red"))(n = 299)
#crio os limites de cada cor 
col_breaks = c(seq(-5.4,-5.3,length=1), # for grey
               seq(-5.2,0,length=219),  # for green
               seq(0.01,11.1,length=80)) #for red

png("D:/Mestrado/PCW/Heatmap/heatmap_teste.png",    # create PNG for the heat map        
    width = 5*400,        # 5 x 300 pixels
    height = 5*500,
    res = 500,            # 300 pixels per inch
    pointsize = 8)        # smaller font size

heatmap.2(teste, 
          col = my_palette, #cores 
          breaks = col_breaks, #limites das cores 
          symbreaks = TRUE, symkey = FALSE, #limites de cores simetricos em 
          key.title = NA, key.ylab = NA, keysize = 1, density.info = "none",
          trace = "none", #sem tracos
          Colv = FALSE, Rowv = TRUE, #sem organizar pelas colunas, apenas por linhas (se quiser o dendro tem que ser TRUE)
          dendrogram = "none", #sem nenhum dendrograma, se tiver (both, row ou column) ele vai reorganizar os pontos
          margins = c(7,7), #margens de baixo, direita
          main = "DEGs by FoldChange", #titulo
          labRow = ident$abrev, #rownames
          cexRow = 0.2, cexCol = 0.4, #tamanho das letras das legendas de colunas e linhas
          srtCol = 0, offsetCol = 0, adjCol = c(0.44,0), #angulacao e posicao da legenda das colunas
          srtRow = 0, offsetRow = -0.9, adjRow = c(0,0) #angulacao e posicao da legenda das linhas
)

dev.off()

说实话,我不知道如何使用重复的字符串设置行的顺序。由于重复它们,因此无法将其设置为行名并制作标准行标签。我检查过的所有问题均未解决。任何帮助将不胜感激。

编辑

> dput(teste)
structure(c(-5.4, -0.6708813033, 1.378061661, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -0.7571104188, -5.4, -5.4, 
-5.4, -5.4, -5.4, 0.8833872859, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -0.6892789513, -5.4, -5.4, 
-5.4, -5.4, -0.8297914588, -0.6868436186, -5.4, -5.4, -5.4, -5.4, 
-5.4, -0.7607811156, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -1.01541751, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -0.6409336586, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, 1.143839406, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-0.9523203778, 1.135483862, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, 2.196512174, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -1.118763389, -5.4, -5.4, -5.4, -0.5937832564, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, 0.6163008345, -5.4, -5.4, 2.042870229, 
1.803821023, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -0.6816546611, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
1.519633857, -5.4, -5.4, -5.4, -5.4, -5.4, 3.724578472, -5.4, 
-5.4, -5.4, -5.4, -5.4, -0.996969924, -5.4, -5.4, -5.4, -5.4, 
1.316517479, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, 2.043820324, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 1.896437041, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -2.458977247, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, 3.189582744, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, 2.197727272, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 1.069020329, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -1.011282724, -1.720724529, -1.14882796, -5.4, -1.064854931, 
4.102143891, -5.4, 1.661527301, -5.4, 5.095997124, 0.9133722606, 
1.868416916, 1.637004853, -5.4, 3.517522062, 2.083747425, 1.523230573, 
1.849253304, -5.4, -5.4, -5.4, 0.9306790445, -1.062442899, -1.176330787, 
-2.710491387, -1.480669494, -5.4, -5.4, 0.9777491518, -5.4, -5.4, 
-5.4, 0.7681252032, 0.6301085726, -2.32268854, -5.4, -5.4, -1.289301326, 
-1.494957671, -5.4, -0.7254508759, -5.4, -5.4, -5.4, 1.221566025, 
-2.95189949, -1.310351167, -0.8732731726, -1.904882379, -0.7041243891, 
-5.4, 1.79437725, -5.4, 0.8258023835, -1.80439866, -5.4, 0.704782973, 
-0.8769026093, 2.484070963, -5.4, -5.4, -5.4, -2.180854498, -5.4, 
-5.4, -1.197095007, -1.007931409, 5.112664294, -5.4, -1.501190751, 
-1.003861254, -5.4, 3.910890063, -5.4, -1.60542926, -5.4, 0.6487590291, 
1.980346109, 2.109874466, -5.4, -5.4, -5.4, 1.974534682, -3.175398172, 
0.7552275053, -5.4, 3.107766887, -1.223584334, -5.4, -1.842269446, 
-5.4, -5.4, -2.085803702, -0.7681739662, -1.300722531, 3.835147531, 
1.908263156, -5.4, 0.6782407641, -2.644888972, -5.4, 4.332185749, 
-4.530326955, -5.4, 1.020428394, -0.6811771425, -0.7322498985, 
2.572052542, 1.376113783, -1.427040157, 0.6285386048, 1.549720916, 
0.819878914, -5.4, -1.071249564, -5.4, 3.743034082, 1.413452604, 
1.874095623, -5.4, -5.4, -5.4, 2.938575443, 1.695867549, -5.4, 
-4.859600416, -5.4, -5.4, 2.550110166, -5.4, 5.839424164, -5.4, 
-5.4, -1.93616625, -5.4, -5.4, -5.4, -2.422132618, -1.190522506, 
-5.4, 1.820430606, 2.047451812, -5.4, -5.4, -5.4, -0.6652277929, 
-5.4, -0.6658891661, -3.084467853, 0.7820596037, -5.4, -0.6403401992, 
-5.4, -1.598339219, -5.4, -5.4, -1.042102949, 7.349999276, 11.01747813, 
1.357121165, -5.4, -1.424288179, -5.4, -1.5066184, -1.546833109, 
1.226058904, -3.466153797, -0.9458963861, -5.4, -1.202565609, 
-2.460594779, 0.8392283651, 1.213170547, -5.4, -5.4, 1.89978346, 
-5.4, -5.4, -1.029939997, -5.4, -1.446086401, -5.4, -5.4, -5.4, 
-0.6629551241, 4.099016269, 1.085262503, 2.932959589, -5.4, -5.4, 
2.093063487, -5.4, 1.915848274, -5.4, -5.4, -5.4, -0.9962349794, 
-5.4, -2.10037681, -5.4, -5.4, -5.4, -0.6210117273, 1.331372413, 
-5.4, 1.975658524, 1.211549921, -1.233471262, -5.4, -5.4, -5.4, 
1.399379313, -5.4, -0.6740016669, -5.4, -1.01124412, -5.4, -2.390943665, 
-5.4, -5.4, 0.8565706577, -2.867120677, -1.35053717, -1.521508746, 
-1.037313268, -1.900548874, 0.6094680988, 1.945517617, -5.4, 
-5.4, -1.952521244, -3.036790929, 0.8413240654, -0.7487997545, 
-5.4, -5.4, -5.4, 1.49218976, -2.134296304, 0.6468980522, -5.4, 
-5.4, -5.4, 4.022331637, -0.6822762592, -0.8392739086, -5.4, 
0.6663729783, 3.763703412, -5.4, -5.4, -5.4, 0.9411168983, -5.4, 
1.205722503, -5.4, -5.4, -5.4, 2.566157569, -3.110145172, -5.4, 
-5.4, 2.824551349, -0.9101716509, 2.35914329, -5.4, -5.4, 1.330068602, 
-5.4, -1.168802563, -5.4, 4.531656424, 1.193230929, -5.4, -5.4, 
-1.860900372, -5.4, 3.966780341, -5.4, 4.474636821, 2.960770832, 
-5.4, -1.087510462, 2.031218454, -5.4, -3.111368394, 0.6198447009, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 1.409333162, -5.4, -5.4, 
1.534214948, -1.985404448, -5.4, 2.246851864, -0.6085522445, 
-5.4, -0.7825077679, -5.4, 2.819064468, 1.546044754, 5.45071172, 
-5.4, -5.4, -5.4, -5.4, 0.6215479324, -5.4, -5.4, -5.4, 1.953754509, 
4.111392533, 1.217192143, -5.4, -5.4, -5.4, -0.6536367475, -5.4, 
-5.4, -1.593053248, 1.272739347, -5.4, -5.4, -5.4, -2.2094143, 
-5.4, -5.4, -0.9252090744, -5.4, 10.73150153, -5.4, 0.8290287022, 
-1.361527581, -0.7217209107, -5.4, -5.4, 0.9501998031, -1.498026229, 
-5.4, -1.40522647, -0.7726975585, -5.4, 0.6705689582, -5.4, -5.4, 
-5.4, 1.74646153, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
0.694357608, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
1.783182539, -5.4, 0.8308832845, -5.4, -5.4, -5.4, 3.032451351, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 3.239523326, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, 1.760724595, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -0.9189042752, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -2.048912159, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, 1.061778374, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, 0.8598045899, -5.4, -5.4, -0.922740647, 
-5.4, -1.142811945, -5.4, -1.08035035, 4.192213438, 1.233850588, 
2.210412903, -5.4, 4.834885409, 0.9480776802, 1.825836912, 2.114830539, 
-5.4, 4.026107714, 2.016130458, 1.478036658, -5.4, -5.4, -5.4, 
-5.4, 1.187772243, -5.4, -1.058109756, -2.42424694, -2.361846044, 
-5.4, -5.4, 1.079248107, -5.4, -5.4, -5.4, 0.8574188354, 0.8751229474, 
-1.890357045, -5.4, -5.4, -0.5977094019, -5.4, -5.4, -0.8422891094, 
-5.4, 1.17095774, 1.173785251, 1.249815231, -2.871954831, -2.00499841, 
-0.8239583587, -1.694191205, -5.4, -5.4, 1.810281832, -5.4, 0.7994156775, 
-5.4, -5.4, -5.4, -0.9963121533, 1.659822361, -5.4, -2.715670325, 
-5.4, -2.110508416, 0.7158621168, 0.7894392697, -5.4, -5.4, 4.424310347, 
-5.4, -1.632377109, -1.209387343, -5.4, -5.4, -5.4, -0.9859913276, 
-5.4, 0.7046625975, 1.796654556, 1.658042843, -5.4, -0.7236388412, 
-5.4, 1.98568531, -3.449300335, 0.7456276423, -5.4, 4.026375215, 
-5.4, 2.484859106, -1.644161591, 0.8181133867, 0.8644447512, 
-5.4, -0.6006995013, -0.857653255, 3.358682663, 2.347032519, 
-5.4, 0.7789589063, -2.446329589, 1.690858527, 4.254847228, -4.009045787, 
-5.4, 0.8818386137, -5.4, -5.4, 2.355385654, 2.105381881, -1.299258612, 
0.7601858588, -5.4, 0.9578884572, -5.4, -5.4, -2.449136834, 2.192089436, 
0.9335797681, 2.053549902, -5.4, -5.4, -5.4, 3.878944011, 1.873728991, 
-5.4, -5.179255352, -5.4, -0.6167480012, -5.4, -5.4, 3.623600045, 
0.7878877467, 0.7268142377, -1.527002397, -0.5992913466, -5.4, 
0.7335243032, -1.960406125, -5.4, -5.4, 2.943339449, 2.657323841, 
2.733839504, 0.7704358606, -5.4, -0.647194463, -3.129150599, 
-5.4, -2.206755605, -5.4, -5.4, -5.4, 0.6924850632, -5.4, 0.5967840906, 
0.7609795869, -1.100392814, 3.577022964, 9.074809571, 1.812236418, 
-5.4, -1.243123789, -5.4, -1.420592199, -5.4, 1.524302799, -4.001283207, 
-0.9079146004, -1.079043267, -1.061229437, -2.567940513, -5.4, 
1.123194077, 0.7829357937, -5.4, 1.834010837, -5.4, -5.4, -1.028641048, 
-5.4, -1.469574719, -5.4, -5.4, 1.402427256, -0.8254210766, 3.821792519, 
1.110334347, 2.882993624, -5.4, -2.22064757, 2.58667136, -5.4, 
1.858988288, -5.4, -2.162519909, 0.6237718206, -5.4, -5.4, -1.571255273, 
-5.4, -5.4, -1.54719474, -0.5829175255, 1.234230151, -5.4, 2.663153224, 
1.466171852, -1.330471429, -5.4, -5.4, -5.4, 1.5248916, 1.005234764, 
-5.4, -5.4, -0.6807612469, -5.4, -5.4, -5.4, -5.4, 0.8736322162, 
-2.78670184, -2.053482171, -1.478627584, -0.831661332, -1.145778843, 
1.118941048, 1.951889007, -5.4, -5.4, -5.4, -5.4, 0.6904523816, 
-0.875736737, -5.4, -1.947390165, -5.4, 1.746835277, -2.068817415, 
0.8987035571, -5.4, -5.4, -5.4, 3.321984806, -5.4, -0.9765333094, 
-5.4, 0.9436959441, -5.4, -5.4, -5.4, -5.4, 0.989733326, -5.4, 
-5.4, -0.9720749183, -5.4, -5.4, 2.562242601, -3.389279321, -5.4, 
0.8544244477, 3.727387944, -5.4, 3.539887618, -5.4, -5.4, 1.623520883, 
-5.4, -1.00623577, -5.4, 4.009756208, 1.62090692, -5.4, -5.4, 
-1.666453244, -5.4, 3.873948501, -5.4, 4.421052529, 2.811600845, 
-5.4, -0.7820419152, 1.801912927, -5.4, -2.990434239, 0.7421884312, 
-5.4, -5.4, -5.4, -5.4, -1.529296347, -5.4, 0.9189101027, -5.4, 
-5.4, -5.4, -1.575970477, -5.4, 2.415298572, -0.8763283561, -5.4, 
-0.7036571622, -5.4, -5.4, -5.4, 3.252009246, -5.4, -5.4, -5.4, 
-5.4, 0.6037701868, -5.4, -5.4, -5.4, -5.4, 5.225556907, 1.814619573, 
2.352877451, -5.4, -5.4, -0.6428722872, -5.4, -5.4, -5.4, 0.979634222, 
-5.4, 1.157009301, -5.4, -5.4, -5.4, -5.4, -0.9902041984, -5.4, 
8.740755939, 0.8953128285, 1.138157962, -1.186046688, -5.4, -5.4, 
-5.4, 1.238333919, -2.034225796, -5.4, -1.668538414, -0.6378353422, 
-5.4, -5.4, -5.4, -5.4, -1.527173422, -1.849005147, -1.171151886, 
-5.4, -5.4, -0.5816710932, -5.4, 2.727173764, -5.4, 1.364994615, 
-5.4, -5.4, -5.4, -5.4, 2.441860943, -5.4, 2.233498248, 1.303446426, 
-5.4, -5.4, -5.4, -5.4, -5.4, 0.6516369852, -5.4, -1.417670848, 
-2.910890561, -1.712052143, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
0.8240507971, 0.7066771301, -1.678864376, -5.4, -5.4, -1.032925626, 
-5.4, -5.4, -5.4, -5.4, -5.4, 0.8925829987, 0.7056065538, -2.282143331, 
-1.155465238, -5.4, -1.525091129, -5.4, -5.4, -5.4, -0.586719217, 
-5.4, -5.4, -5.4, 0.5914108523, -5.4, 2.415725237, -5.4, -5.4, 
-1.457894778, -1.36089068, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-1.27101933, -1.066514165, -5.4, -5.4, -5.4, -5.4, -1.750710298, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 1.338478945, -2.942607127, 
0.5803367949, -5.4, -5.4, -1.091731099, -5.4, -2.130092057, 0.805826597, 
-5.4, -5.4, -5.4, -1.049558793, 2.572260894, 2.061656273, 1.31485788, 
0.7359025216, -1.976612751, 1.870510535, -5.4, -5.4, -5.4, -5.4, 
-0.8812170442, -5.4, 1.580719948, -5.4, -5.4, -5.4, 1.327739083, 
0.9967058448, -0.7013011397, -5.4, -5.4, -5.4, 1.058196656, 1.9206526, 
-5.4, -5.4, -5.4, 2.422545642, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -1.542041379, -5.4, 0.8913326124, 0.8034806118, -1.816011134, 
-5.4, -5.4, -5.4, -1.979761875, -1.387740639, -3.280454578, -5.4, 
1.787150894, 2.74004832, -5.4, -5.4, -5.4, -3.232009206, -5.4, 
-2.179254416, -5.4, -5.4, -1.342345671, 0.6524310688, -5.4, -5.4, 
-5.4, -0.9862688445, 3.965308779, -5.4, 1.38482852, -5.4, -1.205015207, 
-5.4, -5.4, -5.4, -5.4, -3.775247636, -0.9727188025, -5.4, -0.8815881317, 
-2.487155486, -5.4, -5.4, -5.4, -1.527173422, -1.849005147, -1.171151886, 
-5.4, -5.4, -0.5816710932, -5.4, 2.727173764, -5.4, 1.364994615, 
-5.4, -5.4, -5.4, -5.4, 2.441860943, -5.4, 2.233498248, 1.303446426, 
-5.4, -5.4, -5.4, -5.4, -5.4, 0.6516369852, -5.4, -1.417670848, 
-2.910890561, -1.712052143, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
0.8240507971, 0.7066771301, -1.678864376, -5.4, -5.4, -1.032925626, 
-5.4, -5.4, -5.4, -5.4, -5.4, 0.8925829987, 0.7056065538, -2.282143331, 
-1.155465238, -5.4, -1.525091129, -5.4, -5.4, -5.4, -0.586719217, 
-5.4, -5.4, -5.4, 0.5914108523, -5.4, 2.415725237, -5.4, -5.4, 
-1.457894778, -1.36089068, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 
-1.27101933, -1.066514165, -5.4, -5.4, -5.4, -5.4, -1.750710298, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 1.338478945, -2.942607127, 
0.5803367949, -5.4, -5.4, -1.091731099, -5.4, -2.130092057, 0.805826597, 
-5.4, -5.4, -5.4, -1.049558793, 2.572260894, 2.061656273, 1.31485788, 
0.7359025216, -1.976612751, 1.870510535, -5.4, -5.4, -5.4, -5.4, 
-0.8812170442, -5.4, 1.580719948, -5.4, -5.4, -5.4, 1.327739083, 
0.9967058448, -0.7013011397, -5.4, -5.4, -5.4, 1.058196656, 1.9206526, 
-5.4, -5.4, -5.4, 2.422545642, -5.4, -5.4, -5.4, -5.4, -5.4, 
-5.4, -1.542041379, -5.4, 0.8913326124, 0.8034806118, -1.816011134, 
-5.4, -5.4, -5.4, -1.979761875, -1.387740639, -3.280454578, -5.4, 
1.787150894, 2.74004832, -5.4, -5.4, -5.4, -3.232009206, -5.4, 
-2.179254416, -5.4, -5.4, -1.342345671, 0.6524310688, -5.4, -5.4, 
-5.4, -0.9862688445, 3.965308779, -5.4, 1.38482852, -5.4, -1.205015207, 
-5.4, -5.4, -5.4, -5.4, -3.775247636, -0.9727188025, -5.4, -0.8815881317, 
-2.487155486, -5.4, 0.7792280505, -5.4, -5.4, 1.938460569, 1.297253685, 
-5.4, -5.4, -5.4, -5.4, -2.254931927, -5.4, -0.8089649939, -5.4, 
-5.4, -5.4, 1.055731761, -3.475591227, -5.4, -1.438808968, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 2.833925306, 
-5.4, -5.4, 1.018527805, -5.4, -5.4, 1.057346735, -1.280041913, 
-0.9919286322, -0.8941532811, 1.797270928, 1.800669612, 1.095242155, 
0.6091239711, -5.4, -1.09116174, -5.4, -5.4, -5.4, -0.982181148, 
-5.4, -5.4, -5.4, -5.4, 0.8610467763, -1.208151571, 1.12947883, 
-5.4, -5.4, -0.7382658493, -5.4, -3.602262995, -5.4, -5.4, -2.488808028, 
-5.4, -5.4, 1.423134723, -5.4, -5.4, -0.7326746102, -5.4, -5.4, 
-5.4, -0.744508311, -5.4, 0.9701224159, -5.4, -5.4, -5.4, -5.4, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -0.6886595657, -5.4, -5.4, 
-1.010072244, 0.8865882392, -5.4, -5.4, -5.4, -5.4, -5.4, 0.7615357175, 
-5.4, -5.4, 0.8742412208, -5.4, -0.7231593892, -5.4, -0.9837437006, 
-5.4, -5.4, -5.4, -5.4, 3.539070967, 1.928558156, 0.9099822222, 
-5.4, -5.4, -5.4, -1.689269108, -5.4, -5.4, -0.8556496925, -5.4, 
1.417508495, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -3.511712113, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, 1.950338063, -5.4, -5.4, 
-0.7089725182, 1.539223664, -5.4, -5.4, -5.4, 1.739783051, -5.4, 
3.024689566, 2.285667742, -0.8408134665, -5.4, -0.7349885981, 
-5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -1.463734157, 1.441321896, 
-0.7359260856, -5.4, -5.4, -5.4, -5.4, -5.4, -5.4, -0.9136717008, 
0.8166356405, -5.4, -5.4, 1.068844933, -5.4, -5.4, 1.966598868, 
-5.4, -5.4, -5.4, 1.853832412, -5.4), .Dim = c(176L, 10L), .Dimnames = list(
    NULL, c("C0vsC12", "C0vsC24", "C0vsT12", "C0vsT24", "C12vsC24", 
    "C12vsT12", "C12vsT24", "C24vsT12", "C24vsT24", "T12vsT24"
    )))
> dput(ident)
structure(list(gene = structure(1:176, .Label = c("gene10120", 
"gene10247", "gene1032", "gene10377", "gene10467", "gene10529", 
"gene10533", "gene10593", "gene10632", "gene10774", "gene10836", 
"gene10889", "gene10984", "gene11115", "gene11293", "gene11393", 
"gene11453", "gene11454", "gene11456", "gene11458", "gene11696", 
"gene11704", "gene11754", "gene1193", "gene11930", "gene11932", 
"gene11948", "gene11991", "gene12117", "gene12118", "gene12216", 
"gene12218", "gene12343", "gene12359", "gene12413", "gene12584", 
"gene12607", "gene12696", "gene12707", "gene12708", "gene12726", 
"gene12745", "gene12775", "gene12777", "gene12802", "gene12891", 
"gene13023", "gene13024", "gene1303", "gene13050", "gene13051", 
"gene13357", "gene13517", "gene1360", "gene14084", "gene14164", 
"gene14481", "gene14610", "gene147", "gene14718", "gene14736", 
"gene14785", "gene14835", "gene14857", "gene14914", "gene15024", 
"gene15057", "gene15092", "gene15413", "gene15557", "gene15943", 
"gene15998", "gene16066", "gene16174", "gene16303", "gene16406", 
"gene16436", "gene16482", "gene16952", "gene16987", "gene171", 
"gene17454", "gene17502", "gene17545", "gene17689", "gene17696", 
"gene17706", "gene17738", "gene17880", "gene17892", "gene17935", 
"gene17936", "gene17939", "gene1797", "gene18197", "gene18427", 
"gene18596", "gene1982", "gene19957", "gene19959", "gene19960", 
"gene20107", "gene2120", "gene2162", "gene2331", "gene2536", 
"gene2660", "gene2663", "gene2664", "gene2775", "gene2838", "gene2950", 
"gene3084", "gene3087", "gene3336", "gene3486", "gene3830", "gene3877", 
"gene4061", "gene4133", "gene4134", "gene4246", "gene4292", "gene4319", 
"gene4501", "gene4520", "gene4522", "gene4527", "gene4550", "gene4805", 
"gene5066", "gene5145", "gene5207", "gene5293", "gene5336", "gene5468", 
"gene5488", "gene5787", "gene5838", "gene6084", "gene6607", "gene6671", 
"gene6799", "gene6942", "gene699", "gene7019", "gene7049", "gene7205", 
"gene7317", "gene7344", "gene7425", "gene7693", "gene803", "gene841", 
"gene8477", "gene8551", "gene8602", "gene8626", "gene879", "gene8799", 
"gene8913", "gene9058", "gene9059", "gene9085", "gene9153", "gene9155", 
"gene9212", "gene940", "gene9513", "gene957", "gene9649", "gene9661", 
"gene9664", "gene9675", "gene978", "gene9800"), class = "factor"), 
    abrev = structure(c(18L, 13L, 4L, 4L, 13L, 17L, 19L, 15L, 
    10L, 19L, 19L, 19L, 5L, 10L, 6L, 4L, 15L, 19L, 20L, 20L, 
    7L, 7L, 8L, 19L, 10L, 20L, 8L, 19L, 22L, 4L, 9L, 1L, 4L, 
    19L, 1L, 17L, 6L, 11L, 19L, 19L, 22L, 15L, 7L, 17L, 7L, 4L, 
    19L, 13L, 8L, 10L, 10L, 19L, 19L, 2L, 13L, 2L, 13L, 8L, 10L, 
    18L, 19L, 17L, 4L, 13L, 10L, 13L, 19L, 13L, 22L, 4L, 17L, 
    19L, 17L, 13L, 16L, 22L, 22L, 18L, 9L, 7L, 18L, 18L, 13L, 
    18L, 19L, 8L, 4L, 19L, 13L, 22L, 19L, 19L, 19L, 17L, 22L, 
    22L, 13L, 6L, 10L, 21L, 21L, 19L, 6L, 12L, 22L, 17L, 22L, 
    22L, 22L, 4L, 7L, 22L, 22L, 19L, 8L, 17L, 3L, 4L, 22L, 22L, 
    22L, 18L, 19L, 13L, 8L, 19L, 19L, 19L, 19L, 4L, 8L, 22L, 
    8L, 11L, 17L, 8L, 8L, 10L, 14L, 3L, 22L, 7L, 13L, 22L, 19L, 
    7L, 17L, 6L, 22L, 8L, 9L, 7L, 4L, 8L, 6L, 10L, 13L, 22L, 
    3L, 3L, 6L, 17L, 17L, 13L, 7L, 7L, 13L, 9L, 18L, 10L, 17L, 
    19L, 12L, 9L, 8L, 20L), .Label = c("a-Ara", "a-Gal", "a-Mann", 
    "AGal", "AgluT", "Ara", "B-Gal", "B-GalT", "B-Mann", "Cell", 
    "epi", "fuc", "GalAT", "GluA", "GluT", "MannT", "PG", "PL", 
    "PME", "Rha", "RhamL", "Xyl"), class = "factor")), class = "data.frame", row.names = c(NA, 
-176L))

我得到的图像: heatmap (我知道它看起来很尴尬-我仍然在设置参数,实际上是我想出了将5.4 FoldChanges变成灰色的方式,使那些没有表达的基因在灰色背景下使用断点进行比较)

1 个答案:

答案 0 :(得分:1)

如我的评论中所述,您可以通过class App extends React.Component { constructor(props) { super(props); this.state = { value: '', todos: [ { title: 'Learn React', id: Math.random(), completed: true } ] } }; handleChange = (evt) => { this.setState({ value: evt.target.value }) }; handleSubmit = (evt) => { evt.preventDefault(); const todos = [...this.state.todos]; todos.push({ title: this.state.value, id: Math.random(), completed: false }); this.setState(state => ({ todos, value: '' })) }; handleToggle = (id) => { const todos = [...this.state.todos]; todos.map(todo => { if (todo.id === id) { return todo.completed = !todo.completed } else { return todo } }); this.setState(state => ({ todos })) }; render() { return ( <div className="App"> <Grid className="Header" justify="center" container> <Grid item xs={11}> <h1 className="Title">My to-do react app</h1> <FormBox value={this.state.value} onSubmit={this.handleSubmit} onChange={this.handleChange}/> </Grid> </Grid> <TodoList todos={this.state.todos} onChange={this.handleToggle} /> </div> ); } } 构面很容易地做到这一点。这是一个粗糙的例子。

ggplot2

请注意,我并没有注意使标签可读,但这很容易做到。

enter image description here

您甚至可以

dfmat <- cbind(df, scale(mat))

library(reshape2)
meltdf <- melt(dfmat)

library(ggplot2)
ggplot(meltdf, aes(x = variable, y = gene, fill = value)) + 
geom_tile() +
facet_grid(abrev ~ ., scales = "free_y", space = "free_y") + theme_minimal() +
scale_fill_gradient(low = "green", high = "red")

enter image description here