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