Hi, Try this:
directory<- "/home/arunksa111/dados" GetFileList <- function(directory,number){ setwd(directory) filelist1<-dir()[file.info(dir())$isdir] direct<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), full.names = FALSE, recursive = TRUE) direct<-lapply(direct,function(x) paste(directory,"/",x,sep="")) lista<-unlist(direct) output<- list(filelist1,lista) return(output) } file.list.names<-GetFileList(directory,23)[[1]] lista<-GetFileList(directory,23)[[2]] FacGroup<-c(0,1,0,2,2,0,3) ReadDir<-function(FacGroup){ list.new<-lista[FacGroup!=0] read.list<-lapply(list.new, function(x) read.table(x,header=TRUE, sep = "\t")) names(read.list)<-file.list.names[FacGroup!=0] return (read.list) } ListFacGroup<-ReadDir(FacGroup) z.boxplotgroup<- function(lst){ lst1<- lapply(lst,function(x) x[x$FDR<0.01,]) library(plyr) new.list<-lapply(split(lst1,gsub("\\d+","",names(lst1))),function(x) join_all(lapply(x,function(x) x),type="full")) par(mfrow=c(2,2)) b1<-lapply(names(new.list),function(x) lapply(new.list[x],function(y) boxplot(FDR~z,data=y,xlab="Charge",ylab="FDR",main=x))) } z.boxplotgroup(ListFacGroup) z.boxplot<- function(lst){ new.list<- lapply(lst,function(x) x[x$FDR<0.01,]) #print(new.list) par(mfrow=c(2,2)) b1<-lapply(names(new.list),function(x) lapply(new.list[x],function(y) boxplot(FDR~z,data=y,xlab="Charge",ylab="FDR",main=x))) } z.boxplot(ListFacGroup) pdf("Veraboxplot.pdf") z.boxplot(ListFacGroup) z.boxplotgroup(ListFacGroup) Joining by: Seq, Mod, z, score, FDR, Count, E, C, pos, spec, Pro dev.off() A.K. ________________________________ From: Vera Costa <veracosta...@gmail.com> To: arun <smartpink...@yahoo.com> Sent: Thursday, March 21, 2013 11:24 AM Subject: Re: new question Hi. Thank you your help and sorry only answer now. Ok, the boxplots is ok. But I need too by group... on par(mfrow(c(2,2))), I can have par(mfrow(c(3,2)), for example (or more) and have a boxplot for the group. You can help me to group them? About the other function I need to do other things, but now I need to think what to do... Thank you 2013/3/18 arun <smartpink...@yahoo.com> > > > z.boxplot<- function(lst){ > new.list<- lapply(lst,function(x) x[x$FDR<0.01,]) >print(new.list) > par(mfrow=c(2,2)) >b1<-lapply(names(new.list),function(x) lapply(new.list[x],function(y) >boxplot(FDR~z,data=y,xlab="Charge",ylab="FDR",main=x))) > >} > z.boxplot(ListFacGroup) #prints new.list > >If you want to turn off that: > > z.boxplot<- function(lst){ > new.list<- lapply(lst,function(x) x[x$FDR<0.01,]) >#print(new.list) > par(mfrow=c(2,2)) >b1<-lapply(names(new.list),function(x) lapply(new.list[x],function(y) >boxplot(FDR~z,data=y,xlab="Charge",ylab="FDR",main=x))) > > >} > z.boxplot(ListFacGroup) >A.K. > > > > > >________________________________ >From: Vera Costa <veracosta...@gmail.com> >To: arun <smartpink...@yahoo.com> >Sent: Monday, March 18, 2013 1:59 PM >Subject: Re: new question > > > >For example, if I run you code without "pdf...." and "dev.off" I have what I >want > >directory<- "C:/Users/Vera Costa/Desktop/dados.lixo" > #modified the function >GetFileList <- function(directory,number){ > setwd(directory) > filelist1<-dir() > > lista<-dir(directory,pattern = paste("MSMS_",number,"PepInfo.txt",sep=""), >full.names = TRUE, recursive = TRUE) > output<- list(filelist1,lista) > return(output) > } >file.list.names<-GetFileList(directory,23)[[1]] >lista<-GetFileList(directory,23)[[2]] >FacGroup<-c(0,1,0,2,2,0,3) >ReadDir<-function(FacGroup){ > list.new<-lista[FacGroup!=0] > read.list<-lapply(list.new, function(x) read.table(x,header=TRUE, sep = >"\t")) > names(read.list)<-file.list.names[FacGroup!=0] > return (read.list) > } >ListFacGroup<-ReadDir(FacGroup) >ListFacGroup > z.boxplot<- function(lst){ > new.list<- lapply(lst,function(x) x[x$FDR<0.01,]) > print(new.list) > #pdf("VeraBP.pdf") > par(mfrow=c(2,2)) > lapply(names(new.list),function(x) lapply(new.list[x],function(y) >boxplot(FDR~z,data=y,xlab="Charge",ylab="FDR",main=x))) > #dev.off() > } > z.boxplot(ListFacGroup) > > > > > >But I have the results too (I don't need it) > > >[[1]] >[[1]]$a2 >[[1]]$a2$stats > [,1] [,2] >[1,] 0.0000000000 0.0000000000 >[2,] 0.0000000000 0.0000000000 >[3,] 0.0001355197 0.0002175095 >[4,] 0.0010588777 0.0004350190 >[5,] 0.0016571381 0.0004350190 >[[1]]$a2$n >[1] 8 2 >[[1]]$a2$conf > [,1] [,2] >[1,] -0.0004559846 -0.0002685062 >[2,] 0.0007270240 0.0007035253 >[[1]]$a2$out >[1] 0.00494012 >[[1]]$a2$group >[1] 1 >[[1]]$a2$names >[1] "2" "3" > >[[2]] >[[2]]$c2 >[[2]]$c2$stats > [,1] [,2] >[1,] 0.0000000000 0.0000000000 >[2,] 0.0000000000 0.0000000000 >[3,] 0.0001355197 0.0002175095 >[4,] 0.0010588777 0.0004350190 >[5,] 0.0016571381 0.0004350190 >[[2]]$c2$n >[1] 8 2 >[[2]]$c2$conf > [,1] [,2] >[1,] -0.0004559846 -0.0002685062 >[2,] 0.0007270240 0.0007035253 >[[2]]$c2$out >[1] 0.00494012 >[[2]]$c2$group >[1] 1 >[[2]]$c2$names >[1] "2" "3" > >[[3]] >[[3]]$c3 >[[3]]$c3$stats > [,1] [,2] >[1,] 0.000000000 0.0000000000 >[2,] 0.000000000 0.0000000000 >[3,] 0.000000000 0.0000000000 >[4,] 0.002226409 0.0002086594 >[5,] 0.002226409 0.0004173187 >[[3]]$c3$n >[1] 6 4 >[[3]]$c3$conf > [,1] [,2] >[1,] -0.001436105 -0.0001648409 >[2,] 0.001436105 0.0001648409 >[[3]]$c3$out >[1] 0.00560348 >[[3]]$c3$group >[1] 1 >[[3]]$c3$names >[1] "2" "3" > >[[4]] >[[4]]$t2 >[[4]]$t2$stats > [,1] [,2] [,3] >[1,] 0 0.0000000000 0 >[2,] 0 0.0000000000 0 >[3,] 0 0.0002908668 0 >[4,] 0 0.0025929827 0 >[5,] 0 0.0052577771 0 >[[4]]$t2$n >[1] 1 10 5 >[[4]]$t2$conf > [,1] [,2] [,3] >[1,] 0 -0.001004691 0 >[2,] 0 0.001586424 0 >[[4]]$t2$out >[1] 0.0092051934 0.0007174888 >[[4]]$t2$group >[1] 2 3 >[[4]]$t2$names >[1] "1" "2" "3" >
Veraboxplot.pdf
Description: Adobe PDF document
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.