2.每个数据的Y轴标签,前面已经截短了,如何显示?多谢朋友们!
- go_enrich_df <- read.table('go_enrich_df.txt', sep ='\t', header=T)
- ## numbers as data on x axis
- go_enrich_df$number <- factor(rev(1:nrow(go_enrich_df)))
- ## shorten the names of GO terms
- shorten_names <- function(x, n_word=4, n_char=40){
- if (length(strsplit(x, " ")[[1]]) > n_word || (nchar(x) > 40))
- {
- if (nchar(x) > 40) x <- substr(x, 1, 40)
- x <- paste(paste(strsplit(x, " ")[[1]][1:min(length(strsplit(x," ")[[1]]), n_word)], collapse=" "), "...", sep="")
- return(x)
- }
- else
- {
- return(x)
- }
- }
- labels <- (sapply(
- levels(factor(go_enrich_df$Term))[as.numeric(go_enrich_df$number)],
- shorten_names))
- names(labels) <- rev(1:nrow(go_enrich_df))
- library(ggplot2)
- p <- ggplot(data=go_enrich_df, aes(x=FoldEnrichment, y=Term, fill=PValue, size = GeneNumber)) +
- geom_point(shape=21, colour="black", alpha=0.95) +
- # facet_wrap(type ~ ) +
- facet_grid(type ~ .) +
- # scale_fill_gradient2(low="blue", high = "red") +
- # scale_fill_manual(values = CPCOLS) +
- theme_bw() +
- scale_y_discrete(labels=labels) +
- theme(axis.text=element_text(face = "bold", color="gray50")) +
- labs(y = "GO term /KEGG Pathway", title = "Enriched GO Terms /KEGG Pathway") # color = PValue, size = GeneNumber,
- p
go_enrich_df.txt
(3.73 KB)


雷达卡





京公网安备 11010802022788号







