Created
March 29, 2018 08:40
-
-
Save alienzj/b6f34eeabf1a6f44ff1df4ea302174b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setwd("C:\\Users\\xuwenhao\\Desktop\\bwa output\\nwe_bwa\\polu_length_count\\3p_and_5p") | |
library(ggplot2) | |
library(gridExtra) | |
files=list.files(getwd()) | |
files <- files[grepl("w*\\.txt$", files)] | |
ways=unlist(strsplit(getwd(),"/")) | |
pdf(paste(ways[length(ways)],".pdf",seq=""),family="GB1")#改后缀 | |
plot_c <- list() | |
for (f in files) | |
{ | |
#b<-regexpr(".txt", f)#匹配 | |
#key <- substr(f, 0, b[1]-1)#抓取 | |
#mine=paste(key, ".pdf", sep = "") | |
#Villabruna_leng_tag_nhpolu-aln1024-n0.03-low-uni-5p1-3p1-leng-of-ancester-count.txt | |
samplenames=unlist(strsplit(f,"_")) | |
elements=unlist(strsplit(f,"-")) | |
name=paste(samplenames[1],elements[length(elements)-1],seq="-") | |
#do something... | |
#f = 'JK2911_S0_L002_R1_001.fastq.merged.fq.sorted.cleaned_rmdup_leng_tag_nhpolu-aln1024-n0.03-low-uni-3p-1-leng-of-ancester-count.txt' | |
#print(f) | |
M=read.table(f) | |
colnames(M) <- c("length", "number") | |
Length=M$length | |
Number=M$number | |
p=ggplot2::qplot(Length,data=M,geom="histogram",binwidth=3,weight=Number, | |
colour=I("white"),size=I(0.5), | |
fill=I("lightblue")) | |
p=p+ggplot2::labs(x="read length",y="number",title=name) | |
p=p+ggplot2::scale_x_continuous(limits=c(0,201),breaks=seq(0,200,20)) | |
#print(p) | |
#automatically save the plots | |
#dev.off() | |
plot_c <- c(plot_c, list(p)) | |
} | |
do.call(grid.arrange, c(plot_c, nrow=2)) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment