<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ## ggplot2 heatmap > 數據依然來自于上一節的數據 ```R library("reshape2") library("ggplot2") # 準備ggplt2所需要的數據格式 mat_ht_gg <- melt(t(mat_ht_z)) # 作圖 HT1 <- ggplot(data = mat_ht_gg, aes(x = Var1, y = Var2)) + geom_tile(aes(fill = value)) print(HT1) # 可以換一種顏色 HT2 <- HT1 + scale_fill_gradient2(low = "blue", high = "red") print(HT2) ``` ![scatter plot](http://kancloud.nordata.cn/2018-12-30-074426.png) ![scatter plot](http://kancloud.nordata.cn/2018-12-30-074429.png) >如果想要獲得聚類的圖,需要提前對輸入數據進行聚類 ```R # do cluster library(ggplot2) library(ggcorrplot) library(ggdendro) # col cluster mat_dendro_col <- as.dendrogram(hclust(d = dist(x = t(mat_ht_z)))) mat_dendro_ord_col <- order.dendrogram(mat_dendro_col) #row cluster mat_dendro_row <- as.dendrogram(hclust(d = dist(x = mat_ht_z))) mat_dendro_ord_row <- order.dendrogram(mat_dendro_row) # Re-order heatmap columns to match dendrogram mat_ht_gg_clu <- mat_ht_z[mat_dendro_ord_row, mat_dendro_ord_col] mat_ht_clu <- melt(t(mat_ht_gg_clu)) HT3 <- ggplot(data = mat_ht_clu, aes(x = Var1, y = Var2)) + geom_tile(aes(fill = value)) + scale_fill_gradient2(low = "blue", high = "red") print(HT3) ``` ![scatter plot](http://kancloud.nordata.cn/2018-12-30-074431.png) > 如果想要加上聚類的線可以通過ggdendrogram疊加上去 ```R library(grid) dendro_plot_col <- ggdendrogram(data = mat_dendro_col, rotate = FALSE) + theme(axis.text.x = element_text(size = 2)) dendro_plot_row <- ggdendrogram(data = mat_dendro_row, rotate = TRUE) + theme(axis.text.y = element_text(size = 2)) HT4 <- ggplot(data = mat_ht_clu, aes(x = Var1, y = Var2)) + geom_tile(aes(fill = value)) + scale_fill_gradient2(low = "blue", high = "red") + theme(axis.text.y = element_blank(), axis.title.y = element_blank(), axis.ticks.y = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank(), axis.ticks.x = element_blank(), legend.position = "bottom") grid.newpage() print(HT4, vp=viewport(0.6, 0.8, x = 0.5, y = 0.3)) #x change x positiion, y change y position, print(dendro_plot_col, vp=viewport(0.66, 0.2, x = 0.495, y = 0.78)) # 0.875change cluster plot wide print(dendro_plot_row, vp=viewport(0.2, 0.77, x = 0.9, y = 0.335)) # 0.65change cluster plot wide ``` ![scatter plot](http://kancloud.nordata.cn/2018-12-30-074433.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看