1. .libPaths(c("/home/.opt/sysoft/R-4.0.2/lib64/R/library", "/home/shwzhao/R/x86_64-pc-linux-gnu-library/4.0"))
    2. library(tidyverse)
    3. library(pheatmap)
    1. TPM <- read_tsv("Quercus_acutissima.pep.tpm2.SY.tsv")
    2. ERFfam <- read_tsv("ERF.2.tsv", col_names = c("Geneids", "subFam"))
    3. TPM2 <- TPM %>%
    4. pivot_longer(-Geneids) %>%
    5. mutate(name = str_replace(name, "-.*", "")) %>%
    6. group_by(Geneids, name) %>%
    7. mutate(value = sum(value)/3) %>%
    8. distinct() %>%
    9. pivot_wider(names_from = "name", values_from = "value")
    10. ERFfamTPM <- ERFfam %>%
    11. left_join(TPM2, by = "Geneids") %>%
    12. mutate(subFam = factor(subFam, levels = c("I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"))) %>%
    13. arrange(subFam) %>%
    14. select(-subFam) %>%
    15. column_to_rownames("Geneids") %>%
    16. as.matrix()
    17. annotation_row <- ERFfam %>%
    18. column_to_rownames("Geneids")
    19. pdf("test.2.pdf", width = 8, height = 15)
    20. pheatmap(ERFfamTPM,
    21. scale = "row",
    22. cluster_rows = F,
    23. cluster_cols = F,
    24. # display_numbers = TRUE,
    25. # number_format = "%1.0f",
    26. # gaps_row = c(15, 30, 45),
    27. # gaps_col = c(3, 6, 9, 12, 15),
    28. annotation_row = annotation_row,
    29. # annotation_col = annotation_col
    30. )
    31. dev.off()