Skip to content

reading data

1 message · arun

#
Hi Vera,

Not sure I understand your question.


Your statement
"In my lista?I?can?t merge rows to have the group, because the idea is 
for each file count? frequencies of mm, when b<0.01. after that I 
want a graph like the graph in attach."

?files<-paste("MSMS_",23,"PepInfo.txt",sep="")
read.data<-function(x) {names(x)<-gsub("^(.*)\\/.*","\\1",x); lapply(x,function(y) read.table(y,header=TRUE,sep = "\t",stringsAsFactors=FALSE,fill=TRUE))}
lista<-do.call("c",lapply(list.files(recursive=T)[grep(files,list.files(recursive=T))],read.data))
names(lista)<-paste("group_",gsub("\\d+","",names(lista)),sep="")

res2<-split(lista,names(lista))
res3<- lapply(res2,function(x) {names(x)<-paste(gsub(".*_","",names(x)),1:length(x),sep="");x})

res4<-lapply(seq_along(res3),function(i) do.call(rbind,lapply(res3[[i]], function(x) x[x[["b"]]<0.01,])))
names(res4)<- names(res2)
res4


lapply(res4,function(x) table(x$mm))

#$group_a

#2 3 
#9 3 

#$group_b

#2 3 
#6 2 

#$group_c

#2 3 
#3 1 


If you want the separate counts per a1,a2,a3 within the group:
res4<-lapply(seq_along(res3),function(i) do.call(rbind,lapply(res3[[i]], function(x) table(x$mm[x[["b"]]<0.01]))))
?names(res4)<- names(res2)
?res4
#$group_a
?#? 2 3
#a1 3 1
#a2 3 1
#a3 3 1

#$group_b
?#? 2 3
#b1 3 1
#b2 3 1

#$group_c
?#? 2 3
#c1 3 1


I haven't gone through the rest of the codes as I was not sure about what you want.


A.K.