我的目标是根据
Scissor.select
对列进行聚类和排序,使用规定的注释颜色,并删除列标签(即图底部的标签)。
但是,我的代码没有对列进行排序,也没有使用注释调色板。
library(pheatmap)
annotation_colors <- list("Scissor- cells"='#ffa600',"Background Cells"='#c1c1c1',"Scissor+ cells"='#003f5c')
pdf("Plots/gsva_scissor_singlecell_KIRP.pdf", width=10, height=10)
pheatmap(top20.genesets,
cluster_cols = F,
cluster_rows = F,
labels_row = NULL,
annotation_colors=annotation_colors,
clustering_distance_rows = "euclidean", # You can choose a different distance metric
clustering_distance_cols = "euclidean", # You can choose a different distance metric
main = "Genesets of Scissor.select",
annotation_col = Scissor.select)
dev.off()
输入:
> dput(top20.genesets[1:20,1:20])
structure(c(0.490698593595098, -0.104087580459566, -0.104087580459566,
-0.104087580459566, -0.104087580459566, -0.104087580459566, -0.104087580459566,
-0.104087580459566, -0.104087580459566, -0.104087580459566, -0.104087580459566,
-0.104087580459566, -0.104087580459566, -0.104087580459566, -0.104087580459566,
-0.104087580459566, -0.104087580459566, -0.104087580459566, -0.104087580459566,
-0.104087580459566, 0.421306873288721, 0.371741358784165, 0.371741358784165,
0.371741358784165, 0.371741358784165, 0.371741358784165, 0.371741358784165,
0.371741358784165, 0.371741358784165, 0.371741358784165, 0.371741358784165,
0.371741358784165, 0.371741358784165, 0.371741358784165, 0.371741358784165,
0.371741358784165, 0.371741358784165, 0.371741358784165, 0.371741358784165,
0.371741358784165, 0.361828255883254, 0.292436535576877, 0.292436535576877,
0.292436535576877, 0.292436535576877, 0.292436535576877, 0.292436535576877,
0.292436535576877, 0.292436535576877, 0.292436535576877, 0.292436535576877,
0.292436535576877, 0.292436535576877, 0.292436535576877, 0.292436535576877,
0.292436535576877, 0.292436535576877, 0.292436535576877, 0.292436535576877,
0.292436535576877, 0.431219976189632, 0.183392403666855, 0.183392403666855,
0.183392403666855, 0.183392403666855, 0.183392403666855, 0.183392403666855,
0.183392403666855, 0.183392403666855, 0.183392403666855, 0.183392403666855,
0.183392403666855, 0.183392403666855, 0.183392403666855, 0.183392403666855,
0.183392403666855, 0.183392403666855, 0.183392403666855, 0.183392403666855,
0.183392403666855, 0.470872387793276, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.470872387793276, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.421306873288721, 0.421306873288721, 0.421306873288721,
0.421306873288721, 0.460959284892365, 0.351915152982343, 0.351915152982343,
0.351915152982343, 0.351915152982343, 0.351915152982343, 0.351915152982343,
0.351915152982343, 0.351915152982343, 0.351915152982343, 0.351915152982343,
0.351915152982343, 0.351915152982343, 0.351915152982343, 0.351915152982343,
0.351915152982343, 0.351915152982343, 0.351915152982343, 0.351915152982343,
0.351915152982343, 0.480785490694187, 0.361828255883254, 0.361828255883254,
0.361828255883254, 0.361828255883254, 0.361828255883254, 0.361828255883254,
0.361828255883254, 0.361828255883254, 0.361828255883254, 0.361828255883254,
0.361828255883254, 0.361828255883254, 0.361828255883254, 0.361828255883254,
0.361828255883254, 0.361828255883254, 0.361828255883254, 0.361828255883254,
0.361828255883254, 0.470872387793276, 0.401480667486898, 0.401480667486898,
0.401480667486898, 0.401480667486898, 0.401480667486898, 0.401480667486898,
0.401480667486898, 0.401480667486898, 0.401480667486898, 0.401480667486898,
0.401480667486898, 0.401480667486898, 0.401480667486898, 0.401480667486898,
0.401480667486898, 0.401480667486898, 0.401480667486898, 0.401480667486898,
0.401480667486898, 0.381654461685076, 0.470872387793276, 0.470872387793276,
0.470872387793276, 0.470872387793276, 0.470872387793276, 0.470872387793276,
0.470872387793276, 0.470872387793276, 0.470872387793276, 0.470872387793276,
0.470872387793276, 0.470872387793276, 0.470872387793276, 0.470872387793276,
0.470872387793276, 0.470872387793276, 0.470872387793276, 0.470872387793276,
0.470872387793276, 0.332088947180521, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.391567564585987, 0.391567564585987,
0.391567564585987, 0.391567564585987, 0.391567564585987, 0.391567564585987,
0.391567564585987, 0.391567564585987, 0.391567564585987, 0.391567564585987,
0.391567564585987, 0.391567564585987, 0.391567564585987, 0.391567564585987,
0.391567564585987, 0.391567564585987, 0.391567564585987, 0.391567564585987,
0.391567564585987, 0.342002050081432, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.490698593595098, 0.242871021072321, 0.242871021072321,
0.242871021072321, 0.242871021072321, 0.242871021072321, 0.242871021072321,
0.242871021072321, 0.242871021072321, 0.242871021072321, 0.242871021072321,
0.242871021072321, 0.242871021072321, 0.242871021072321, 0.242871021072321,
0.242871021072321, 0.242871021072321, 0.242871021072321, 0.242871021072321,
0.242871021072321, 0.381654461685076, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, 0.441133079090543, 0.441133079090543, 0.441133079090543,
0.441133079090543, -0.00495655145045554, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.480785490694187, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.451046181991454, 0.451046181991454, 0.451046181991454,
0.451046181991454, 0.480785490694187, 0.431219976189632, 0.431219976189632,
0.431219976189632, 0.431219976189632, 0.431219976189632, 0.431219976189632,
0.431219976189632, 0.431219976189632, 0.431219976189632, 0.431219976189632,
0.431219976189632, 0.431219976189632, 0.431219976189632, 0.431219976189632,
0.431219976189632, 0.431219976189632, 0.431219976189632, 0.431219976189632,
0.431219976189632, 0.431219976189632, 0.480785490694187, 0.480785490694187,
0.480785490694187, 0.480785490694187, 0.480785490694187, 0.480785490694187,
0.480785490694187, 0.480785490694187, 0.480785490694187, 0.480785490694187,
0.480785490694187, 0.480785490694187, 0.480785490694187, 0.480785490694187,
0.480785490694187, 0.480785490694187, 0.480785490694187, 0.480785490694187,
0.480785490694187, 0.470872387793276, 0.342002050081432, 0.342002050081432,
0.342002050081432, 0.342002050081432, 0.342002050081432, 0.342002050081432,
0.342002050081432, 0.342002050081432, 0.342002050081432, 0.342002050081432,
0.342002050081432, 0.342002050081432, 0.342002050081432, 0.342002050081432,
0.342002050081432, 0.342002050081432, 0.342002050081432, 0.342002050081432,
0.342002050081432), dim = c(20L, 20L), dimnames = list(c("REACTOME_GLUTAMATE_AND_GLUTAMINE_METABOLISM",
"REACTOME_CONSTITUTIVE_SIGNALING_BY_ABERRANT_PI3K_IN_CANCER",
"REACTOME_CONSTITUTIVE_SIGNALING_BY_OVEREXPRESSED_ERBB2", "REACTOME_DOWNREGULATION_OF_ERBB2_ERBB3_SIGNALING",
"REACTOME_DOWNREGULATION_OF_ERBB2_SIGNALING", "REACTOME_ERBB2_ACTIVATES_PTK6_SIGNALING",
"REACTOME_ERBB2_REGULATES_CELL_MOTILITY", "REACTOME_GRB2_EVENTS_IN_ERBB2_SIGNALING",
"REACTOME_GRB7_EVENTS_IN_ERBB2_SIGNALING", "REACTOME_PI3K_AKT_SIGNALING_IN_CANCER",
"REACTOME_PI3K_EVENTS_IN_ERBB2_SIGNALING", "REACTOME_SEMA4D_IN_SEMAPHORIN_SIGNALING",
"REACTOME_SEMA4D_INDUCED_CELL_MIGRATION_AND_GROWTH_CONE_COLLAPSE",
"REACTOME_SHC1_EVENTS_IN_ERBB2_SIGNALING", "REACTOME_SIGNALING_BY_ERBB2",
"REACTOME_SIGNALING_BY_ERBB2_ECD_MUTANTS", "REACTOME_SIGNALING_BY_ERBB2_IN_CANCER",
"REACTOME_SIGNALING_BY_PTK6", "REACTOME_TFAP2_AP_2_FAMILY_REGULATES_TRANSCRIPTION_OF_GROWTH_FACTORS_AND_THEIR_RECEPTORS",
"REACTOME_TRANSCRIPTIONAL_REGULATION_BY_THE_AP_2_TFAP2_FAMILY_OF_TRANSCRIPTION_FACTORS"
), c("AAACCTGAGCGTTTAC.p906", "AAACCTGAGTGCAAGC.p906", "AAACCTGTCATCACCC.p906",
"AAACGGGCAGTTAACC.p906", "AAACGGGGTGCTAGCC.p906", "AAACGGGTCACAAACC.p906",
"AAAGATGAGCGTTGCC.p906", "AAAGATGCAAGGTTTC.p906", "AAAGATGGTCTCTCTG.p906",
"AAAGATGTCGCGGATC.p906", "AAAGCAAAGACCTAGG.p906", "AAAGCAAGTAAAGGAG.p906",
"AAAGTAGAGAGTCTGG.p906", "AAATGCCGTGTGCCTG.p906", "AACACGTAGAGACGAA.p906",
"AACACGTTCCCATTTA.p906", "AACCATGGTATAATGG.p906", "AACCATGTCGTTGACA.p906",
"AACCGCGTCATAGCAC.p906", "AACGTTGCAACTGCGC.p906")))
> dput(Scissor.select[1:20,])
c("Scissor- cells", "Background Cells", "Scissor- cells", "Scissor- cells",
"Scissor+ cells", "Scissor+ cells", "Scissor- cells", "Scissor- cells",
"Scissor- cells", "Scissor+ cells", "Scissor+ cells", "Scissor- cells",
"Scissor+ cells", "Scissor- cells", "Scissor- cells", "Scissor+ cells",
"Scissor+ cells", "Scissor+ cells", "Scissor+ cells", "Scissor+ cells"
)
所需格式:
如果您查看 pheatmap 文档,他们有一些很好的示例。 您可以通过将 Scissor.select 从列表更改为数据框并将行名称设置为矩阵的列名称来实现图表。 您还想为注释颜色创建一个命名列表,以便 pheatmap 知道将颜色与您的注释相关联。
Scissor.select <- data.frame(CellType = c("Scissor- cells", "Background Cells", "Scissor- cells", "Scissor- cells",
"Scissor+ cells", "Scissor+ cells", "Scissor- cells", "Scissor- cells",
"Scissor- cells", "Scissor+ cells", "Scissor+ cells", "Scissor- cells",
"Scissor+ cells", "Scissor- cells", "Scissor- cells", "Scissor+ cells",
"Scissor+ cells", "Scissor+ cells", "Scissor+ cells", "Scissor+ cells"
))
rownames(Scissor.select) <- colnames(top20.genesets)
annotation_colors <- list(CellType = c("Scissor- cells"='#ffa600',"Background Cells"='#c1c1c1',"Scissor+ cells"='#003f5c'))
pdf("Plots/gsva_scissor_singlecell_KIRP.pdf", width=10, height=10)
pheatmap::pheatmap(top20.genesets,
cluster_cols = T,
cluster_rows = F,
show_colnames = F,
annotation_col = Scissor.select,
annotation_colors=annotation_colors,
clustering_distance_rows = "euclidean", # You can choose a different distance metric
clustering_distance_cols = "euclidean", # You can choose a different distance metric
main = "Genesets of Scissor.select"
)
dev.off()