[R] new question
arun
smartpink111 at yahoo.com
Wed Mar 27 05:34:33 CET 2013
Hi,
Try this: (Used the old data folder)
Compares the spec counts of sub directory with each other.
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)
}
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)
}
file.list.names<-GetFileList(directory,23) [[1]]
lista<-GetFileList(directory,23) [[2]]
FacGroup<-c(1,1,0,2,2,0,0)
ListFacGroup<-ReadDir(FacGroup)
lst1<-lapply(ListFacGroup,function(x) {x<-within(x,{spec<- as.character(spec)}); x1<- x[x$FDR<0.01,c("Seq","Mod","z","spec")]; x1$counts<-sapply(x1$spec,function(x2) length(unlist(strsplit(x2,","))));x1})
lst2<-lapply(as.data.frame(combn(names(lst1),2),stringsAsFactors=FALSE),function(x) { x1<-merge(lst1[[x[1]]],lst1[[x[2]]],by=c("Seq","Mod","z"));names(x1)[c(5,7)]<- paste0("counts_",c(x[1],x[2]));x1[2,5]<-8;x2<-data.frame(apply(cbind(x1[,5],x1[,7]),1,function(y) {chisq.test(y)$p.value})); colnames(x2)<- paste0("Counts_",x[1],x[2]);x2})
####In the above code:, I replaced a count datapoint to make it significant for the purpose of separating the significant from others ( x1[2,5]<- 8).
lst3<-lapply(lst2,function(x) {x1<-list(x[!x[,1]<0.05,],x[x[,1]<0.05,]);names(x1)<-rep(colnames(x),each=2);x1})
lst3[[5]]
#$Counts_a2c3
#[1] 1 1 1 1 1
#$Counts_a2c3
#[1] 0.01963066
A.K.
________________________________
From: Vera Costa <veracosta.rt at gmail.com>
To: arun <smartpink111 at yahoo.com>
Sent: Tuesday, March 26, 2013 4:26 PM
Subject: Re: new question (if you could help...)
But you could do the code of t test and chisq.test or not? Thank you
No dia 26 de Mar de 2013 20:16, "arun" <smartpink111 at yahoo.com> escreveu:
More information about the R-help
mailing list