作者:好人___夏洁 | 来源:互联网 | 2023-09-14 16:02
setwd(C:Usersyuki_coolRWorkspace)library(ggplot2)library(gridExtra)##多张图片组合为一张图片上libr
setwd("C:/Users/yuki_cool/RWorkspace" ) library(ggplot2) library(gridExtra) ##多张图片组合为一张图片上 library(RColorBrewer)mypalette<-brewer.pal(7 ,"Reds" ) paste("aaa" ,"dddd" ,sep &#61; "" )LSQ_data <-read.table("C:/Users/yuki_cool/RWorkspace/JQL_chr_depth_summary.txt" ,header &#61; TRUE,sep&#61;&#39;\t&#39; )### 主题 样式 windowsFonts(A&#61;windowsFont(&#39;等线&#39; ), B&#61;windowsFont(&#39;微软雅黑&#39; )) par(family&#61;&#39;A&#39; ) pptblue<-rgb(r&#61;16 , g&#61;77 , b&#61;96 , maxColorValue &#61; 255 ) pptgrey<-rgb(r&#61;107 , g&#61;107 , b&#61;107 ,maxColorValue &#61; 255 ) pptred<-rgb(r&#61;233 , g&#61;77 , b&#61;96 , maxColorValue &#61; 255 ) ppttea<-rgb(r&#61;198 , g&#61;96 , b&#61;52 , maxColorValue &#61; 255 ) pptdark<-rgb(r&#61;69 , g&#61;87 , b&#61;101 , maxColorValue &#61; 255 ) pptbg<-rgb(r&#61;242 , g&#61;242 , b&#61;242 , maxColorValue &#61; 255 ) par(bg&#61;pptbg) par(bty&#61;&#39;l&#39; ) par(mar&#61;c(4 , 5 , 4 , 6 ))theme<-theme_bw()&#43;theme(legend.position &#61; &#39;top&#39; , #图例位置text&#61;element_text(face &#61; &#39;bold&#39; ), #字体panel.background&#61;element_rect(pptbg), #画布背景颜色plot.background&#61;element_rect(pptbg), #图形背景颜色plot.title &#61; element_text(hjust&#61;0.5 ,size&#61;16 ,vjust&#61;0.5 ), #标题位置panel.border&#61;element_blank(),#图形边界panel.grid.major&#61;element_blank(),#element_line(colour&#61;&#39;lightgrey&#39; ,linetype&#61;"dashed" ), #网格线panel.grid.minor&#61;element_blank(), #次级网格线legend.title&#61;element_text(size&#61;20 , colour&#61;&#39;black&#39; , vjust&#61;-0.5 ,face &#61; "bold" ), #图例标题legend.text&#61;element_text(size&#61;20 , colour&#61;&#39;black&#39; , face &#61; "bold" ), #图例文字legend.background &#61;element_rect(pptbg),#图例背景axis.text&#61;element_text(size&#61;12 ,colour&#61;"black" ,family&#61;&#39;A&#39; ), #坐标轴文字strip.text&#61;element_text(size&#61;12 ,colour&#61;"red" ,family&#61;&#39;A&#39; ),#分面文字strip.background&#61;element_blank(),#分面的背景axis.line &#61; element_line(size&#61;0.5 , colour &#61; &#39;black&#39; ), #轴颜色大小panel.spacing&#61;unit(30 ,&#39;mm&#39; )) #画布大小#####chromosome depth summary plot LSQ_dt <- na.omit(data.frame(chrome &#61; LSQ_data$chrome, mean_depth &#61; LSQ_data$chr_depth_sum))LSQ_plot <- ggplot(LSQ_dt, aes(x &#61; chrome, y &#61; mean_depth))&#43;geom_bar(stat &#61; "identity" , fill&#61;I(mypalette[1 ])) &#43; plot_theme&#43;labs( y &#61; "Mean depth" )LSQ_plot# # LST_plot <- ggplot(LST_dt, aes(x &#61; chrome, y &#61; mean_depth))&#43; # geom_bar(stat &#61; "identity")&#43; plot_theme &#43; # labs( y &#61; "Mean depth") # ggsave(plot &#61; fushengyi_plot, filename &#61; file.path(local_path, "chr_pic.png"), width &#61; 10, height &#61; 6) # #################################### # # # plot <- ggplot(LSQ_data, aes(depth, qc)) &#43;geom_point(aes(color&#61;"LSQ")) &#43; # geom_point(data &#61;YZF_data, aes(color&#61;"YZF") )&#43; # geom_point(data &#61;YZJ_data, aes(color&#61;"YZJ"))&#43; # geom_point(data &#61;LST_data, aes(color&#61;"LST"))&#43; # geom_point(data &#61;fushengrong_data, aes(color&#61;"FSR"))&#43; # geom_point(data &#61;fushengyi_data, aes(color&#61;"FSY"))&#43; # labs(color&#61;"Sample", x &#61; "sequence depth", y &#61; "Fraction of bases (%)", size &#61; 10) # # # qc_plot <- plot &#43; theme_bw() &#43; plot_theme # # # plot1 <- ggplot(LST_data, aes(depth, ac)) &#43;geom_line(aes(color&#61;"LST"),size &#61;1.5) &#43; # geom_line(data &#61;YZJ_data, aes(color&#61;"YZJ"),size &#61;1.5)&#43; # geom_line(data &#61;LSQ_data, aes(color&#61;"LSQ"),size &#61;1.5)&#43; # geom_line(data &#61;YZF_data, aes(color&#61;"YZF"),size &#61;1.5)&#43; # geom_line(data &#61;fushengrong_data, aes(color&#61;"FSR"),size &#61;1.5)&#43; # geom_line(data &#61;fushengyi_data, aes(color&#61;"FSY"),size &#61;1.5)&#43; # labs(color&#61;"Sample", x &#61; "cumulative sequence depth", y &#61; "Fraction of bases (%)") # # ac_plot <- plot1&#43; theme_bw() &#43; plot_theme # # pic<-grid.arrange(qc_plot, ac_plot, ncol &#61; 2) # # # ggsave(plot &#61; ac_plot, filename &#61; file.path(local_path, "ac_pic.png"), width &#61; 10, height &#61; 6)