#### 最开始的热图
library(pheatmap)
library(dplyr)
df <- read.csv("scMetabolism_RESULTS/scMetabolism.csv", row.names=1, check.names=F)
avg_df =aggregate(df[,1:ncol(df)-1],list(df$orig.ident),mean)
rownames(avg_df) = avg_df$Group.1
avg_df=avg_df[,-1]
avg_df <- as.data.frame(t(avg_df))
data <- avg_df
kegg_inf <- read.csv("/disk221/lihx/SOFTware/KEGG/KEGG_map.csv", row.names=1, check.names=FALSE)
metabolism_inf <- read.csv("scMetabolism_RESULTS/scMetabolism.matrix.csv", header = TRUE, check.names = FALSE)
colnames(metabolism_inf) <- c("KEGG","RF_S2", "RF_S1", "SF_S2", "SF_S1")
metabolism_inf <- inner_join(metabolism_inf,kegg_inf[,c(1,4)],by=c("KEGG"="KEGG"))
annotation_row <- data.frame(Category=metabolism_inf$second_category)
rownames(annotation_row) <- metabolism_inf$KEGG
annotation_col <- data.frame(STRAIN=sapply(strsplit(colnames(data), "-"), function(x) x[1]))
rownames(annotation_col) <- colnames(data)
ann_colors=list(STRAIN=c('RF_S1'='#2A9D8F','RF_S2'='#E76F51','SF_S1'='#2A9D56','SF_S2'='#F4A261'))
pheatmap(data, scale="row",
annotation_colors=ann_colors,
# annotation_col=annotation_col,
annotation_row=annotation_row,
show_rownames=T, show_colnames=T, cluster_rows=F, cluster_cols=F,
# color = colorRampPalette(c("#1A5592",'white',"#B83D3D"))(100),
color=colorRampPalette(c("navy",'white',"firebrick3"))(50),
filename="scMetabolism_RESULTS/pheatmap.pdf", width=12, height=12)
请问这段代码哪里有问题?为什么会出现错误 Error in check.length("fill"): 'gpar' element 'fill' must not be length 0
Traceback:
1. heatmap_motor(mat, border_color = border_color, cellwidth = cellwidth,
. cellheight = cellheight, treeheight_col = treeheight_col,
. treeheight_row = treeheight_row, tree_col = tree_col, tree_row = tree_row,
. filename = filename, width = width, height = height, breaks = breaks,
. color = color, legend = legend, annotation_row = annotation_row,
. annotation_col = annotation_col, annotation_colors = annotation_colors,
. annotation_legend = annotation_legend, annotation_names_row = annotation_names_row,
. annotation_names_col = annotation_names_col, main = main,
. fontsize = fontsize, fontsize_row = fontsize_row, fontsize_col = fontsize_col,
. hjust_col = hjust_col, vjust_col = vjust_col, angle_col = angle_col,
. fmat = fmat, fontsize_number = fontsize_number, number_color = number_color,
. gaps_row = gaps_row, gaps_col = gaps_col, labels_row = labels_row,
. labels_col = labels_col, ...)
2. heatmap_motor(matrix, cellwidth = cellwidth, cellheight = cellheight,
. border_color = border_color, tree_col = tree_col, tree_row = tree_row,
. treeheight_col = treeheight_col, treeheight_row = treeheight_row,
. breaks = breaks, color = color, legend = legend, annotation_col = annotation_col,
. annotation_row = annotation_row, annotation_colors = annotation_colors,
. annotation_legend = annotation_legend, annotation_names_row = annotation_names_row,
. annotation_names_col = annotation_names_col, filename = NA,
. main = main, fontsize = fontsize, fontsize_row = fontsize_row,
. fontsize_col = fontsize_col, hjust_col = hjust_col, vjust_col = vjust_col,
. angle_col = angle_col, fmat = fmat, fontsize_number = fontsize_number,
. number_color = number_color, labels_row = labels_row, labels_col = labels_col,
. gaps_col = gaps_col, gaps_row = gaps_row, ...)
3. draw_annotation_legend(annotation, annotation_colors, border_color,
. fontsize = fontsize, ...)
4. rectGrob(x = unit(0, "npc"), y = yy, hjust = 0, vjust = 1, height = 2 *
. text_height, width = 2 * text_height, gp = gpar(col = border_color,
. fill = annotation_colors[[i]]))
5. grob(x = x, y = y, width = width, height = height, just = just,
. hjust = hjust, vjust = vjust, name = name, gp = gp, vp = vp,
. cl = "rect")
6. gpar(col = border_color, fill = annotation_colors[[i]])
7. validGP(list(...))
8. check.length("fill")
9. stop(gettextf("'gpar' element '%s' must not be length 0", gparname),
. domain = NA)
10. .handleSimpleError(function (cnd)
. {
. watcher$capture_plot_and_output()
. cnd <- sanitize_call(cnd)
. watcher$push(cnd)
. switch(on_error, continue = invokeRestart("eval_continue"),
. stop = invokeRestart("eval_stop"), error = NULL)
. }, "'gpar' element 'fill' must not be length 0", base::quote(check.length("fill")))
最新发布