R2-31 第七次作业-火山图

小伊伊 2017-12-19 22:43:30 阅读: 1134

library(ggplot2)

my_plot<-ggplot(

  mtcars,

  aes(

    x=factor(cyl),

    fill=factor(gear)

  )

)+

geom_bar(width = 0.5)+

labs(

  title = "Here is title", 

  subtitle = "Here is subtitle", 

  caption = "R2-31", 

  x = "cyl"

)


theme_new <-function(){

  theme_classic() +

  theme(

    panel.background=element_rect(fill='white'),

    panel.grid = element_blank(),

    legend.position = "",

    axis.line = element_line(color = "black"),

  )

}


my_plot+theme_new()

Rplot03.png

2:

library(ggplot2)

library(latex2exp)


theme_new <-function(){

  theme_classic() +

  theme(

    panel.background=element_rect(fill='white'),

    panel.grid = element_blank()

    legend.position = "",

    axis.line = element_line(color = "black")

  )

}



myvolcano<-read.table("E:/nature23643-s4.csv",header = T,sep = ",")



myvolcano$significant<-ifelse(abs(log2(myvolcano$FC))<1,"not","yes")


head(myvolcano)


myvolcano$lables<-ifelse(abs(log2(myvolcano$FC))<1,NA,as.character(myvolcano$gene.ID))


head(myvolcano)


mysig<-subset(myvolcano,significant=="yes")


head(mysig)


ydrop = -0.6

textdrop=0.3


p1<-ggplot(

  data = myvolcano,

  aes(x=log2(FC),y=-log2(q_value), size=significant))+

  geom_point(color="grey",alpha=0.4)+

  xlim(c(-3,3))+ylim(c(-1,16))+

  scale_size_manual(values = c(2,0))+

  geom_vline(xintercept = c(0),lty=4,col="black",lwd=0.5)+

  geom_hline(yintercept = -log2(1/32),lty=4,col="red",lwd=0.5)+

  #overlap

  geom_point(data = mysig,aes(x=log2(FC), y=-log2(q_value),color=lables ),

    size=4

  )+

  geom_text(

    aes(label=lables),

    size=3,

    hjust=0,

    vjust=-1,

    col="black",

    fontface="italic"

  )+

  annotate(

    "segment", 

    x = 1,

    xend = 2.5,

    y = ydrop,

    yend  = ydrop,

    color = "black",

    size = 1,

    arrow = arrow(

      angle = 18,

      ends = "last",

      type = "closed"

    )

  ) +

  annotate(

    "segment",

    x = -1,

    xend = -2.5,

    y = ydrop,

    yend  = ydrop,

    color = "black",

    size = 1,

    arrow = arrow(

      angle = 18,

      ends = "last",

      type = "closed"

    )

  ) +

  annotate(

    "text",

    x = 1.7,

    y = textdrop,

    label = "Upregulated",

    size = 4.5

  ) +

  annotate(

    "text",

    x = -1.7,

    y = textdrop,

    label = "Downregulated",

    size = 4.5

  )

p1+theme_new()+ggtitle("R2-31")

Rplot01.png


 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号