noriakis / ggkegg

Analyzing and visualizing KEGG information using the grammar of graphics
https://noriakis.github.io/software/ggkegg
MIT License
201 stars 16 forks source link

There are some images that don't match the KEGG website #21

Closed sunliangxing closed 4 months ago

sunliangxing commented 4 months ago

Hi I am using ggkegg to draw and when I use rno04010, I notice that the drawing is different from the kegg website above. And I downloaded the 2x image and found that it is still not the same as drawn. Here is the code that I used to draw the image.

library(ggkegg)
g<-pathway("rno04010")
value<-c()
value1<-c()
name_gene<-c()
name_pro<-c()
m=1
for(m in 1:length(names(V(g)))){
  a<-strsplit(names(V(g))[m],split=" ")[[1]]
  b<-gene[which(geneKEGG[which(geneKEGG%in%a)]==gene[,genekeggcol]),genelogcol]
  c<-pro[which(proKEGG[which(proKEGG%in%a)]==pro[,prokeggcol]),prologcol]
  if(length(b)==0){
    b<-NA
    d<-NA
  }else if(length(b)>1){
    b<-mean(b)
  }
  if(length(c)==0){
    c<-NA
    e<-NA
  }else if(length(c)>1){
    c<-mean(c)
  }
  value<-c(value,b)
  name_gene<-c(name_gene,d)
  value1<-c(value1,c)
  name_pro<-c(name_pro,e)
}
V(g)$fill1<-value
V(g)$fill2<-value1
f<-max(abs(value),na.rm = T)
h<-max(abs(value1),na.rm = T)
p1<-ggraph(g,layout="manual",x=x*2,y=y*2)+
  geom_node_rect(aes(xmin=xmin*2,xmax=(xmin+width/2)*2,ymin=ymin*2,ymax=ymax*2,
                     filter=!is.na(fill1),fill1=fill1))+
  geom_node_rect(aes(xmin=(xmin+width/2)*2,xmax=(xmin+width)*2,ymin=ymin*2,ymax=ymax*2,
                     filter=!is.na(fill2),fill2=fill2))+
  scale_fill_multi(aesthetics = c("fill1", "fill2"),
                   name = list("Transcript", "Protein"),
                   colours = list(c("#397D7D","#D43605"),
                                  c("#4ADCFF","#FDB462")),
                   breaks=list(c(-f,-f/2,0,f/2,f),c(-h,-h/2,0,h/2,h)),
                   labels=list(c(-round(f,2),-round(f/2,2),0,round(f/2,2),round(f,2)),
                               c(-round(h,2),-round(h/2,2),0,round(h/2,2),round(h,2))),
                   limits=list(c(-f,f),c(-h,h)),

                   guide = guide_colorbar(title.theme = element_text(size=26),
                                          title.vjust = 0.5,
                                          label.theme = element_text(size = 18),
                                          barheight = unit(180, "pt"),barwidth = unit(50, "pt")))+
  overlay_raw_map(high_res=TRUE)+
  theme_void()
ggkeggsave("test.png",p1)

Here's what I've mapped out rno04010_log2FC Here are the 2x images rno04010@2x_20240222_113834 I don't know if these subtle issues will have any effect. Looking forward to your reply!

noriakis commented 4 months ago

Hi, thanks for reporting. The overlay_raw_map function makes some colors used in KEGG image transparent by default for overlaying. Could you please try setting transparent_colors=c("#FFFFFF"), for restricting to the white color only?

  overlay_raw_map(high_res=TRUE, transparent_color="#FFFFFF")
sunliangxing commented 4 months ago

Yes you are right. Thank you!