exprTable <- read.table("exprTable.txt", sep="\t", row.names=1, header=T) exprTable
library(pheatmap) pheatmap(exprTable)
自己做个hclust
传进去,顺序跟pheatmap默认是一样的
exprTable_t <- as.data.frame(t(exprTable)) col_dist = dist(exprTable_t) hclust_1 <- hclust(col_dist) pheatmap(exprTable, cluster_cols = hclust_1)
按发育时间排序样品
manual_order = c("Zygote", "X2_cell", "X4_cell", "X8_cell", "Morula", "ICM") dend = reorder(as.dendrogram(hclust_1), wts=order(match(manual_order, rownames(exprTable_t)))) # dend = reorder(as.dendrogram(hclust_1), wts=order(match(manual_order, rownames(exprTable_t))), agglo.FUN = max) col_cluster <- as.hclust(dend) pheatmap(exprTable, cluster_cols = col_cluster)
可以按任意指标排序,基因表达是一个例子。
dend = reorder(as.dendrogram(hclust_1), wts=exprTable_t$Tet3) col_cluster <- as.hclust(dend) pheatmap(exprTable, cluster_cols = col_cluster)
dend = reorder(as.dendrogram(hclust_1), wts=exprTable_t$Tet3*(-1)) col_cluster <- as.hclust(dend) pheatmap(exprTable, cluster_cols = col_cluster)
col_cluster <- hclust_1 %>% as.dendrogram %>% sort %>% as.hclust pheatmap(exprTable, cluster_cols = col_cluster)
col_cluster <- hclust_1 %>% as.dendrogram %>% ladderize(TRUE) %>% as.hclust pheatmap(exprTable, cluster_cols = col_cluster)
col_cluster <- hclust_1 %>% as.dendrogram %>% ladderize(FALSE) %>% as.hclust pheatmap(exprTable, cluster_cols = col_cluster)
样本量多时的自动较忧排序
sv = svd(exprTable)$v[,1] dend = reorder(as.dendrogram(hclust_1), wts=sv) col_cluster <- as.hclust(dend) pheatmap(exprTable, cluster_cols = col_cluster)
exprTable_cor <- cor(exprTable) exprTable_cor
pheatmap(exprTable_cor, cluster_rows = T, cluster_cols = T)
cor_cluster = hclust(as.dist(1-exprTable_cor)) pheatmap(exprTable_cor, cluster_rows = cor_cluster, cluster_cols = cor_cluster)
cor_sum <- rowSums(exprTable_cor) dend = reorder(as.dendrogram(cor_cluster), wts=cor_sum) col_cluster <- as.hclust(dend) pheatmap(exprTable_cor, cluster_rows = col_cluster, cluster_cols = col_cluster)
manual_order = c("Zygote", "X2_cell", "X4_cell", "X8_cell", "Morula", "ICM") dend = reorder(as.dendrogram(cor_cluster), wts=order(match(manual_order, rownames(exprTable_cor))),agglo.FUN = max) col_cluster <- as.hclust(dend) pheatmap(exprTable_cor, cluster_rows = col_cluster, cluster_cols = col_cluster)
height = height[height>0]
height
hang_dend = hang.dendrogram(dend)
plot(hang_dend)
height = get_nodes_attr(hang_dend, "height")
height
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.