Skip to content
Prev 317829 / 398506 Next

reading data

Hi,
I am not able to open your graph.? I am using linux.

Also, the codes in the function are not reproducible
?directT <- direct[grepl("^t", direct)]
?directC <- direct[grepl("^c", direct)]

It takes double the time to know what is going on.

dir()
#[1] "a1" "a2" "a3" "b1" "b2" "c1"

direct<- list.files(recursive=TRUE)[grepl("^a|^b",dir())]

?direct
#[1] "MSMS_23PepInfo.txt" "MSMS_23PepInfo.txt" "MSMS_23PepInfo.txt"
#[4] "MSMS_23PepInfo.txt" "MSMS_23PepInfo.txt"
directA<- list.files(recursive=TRUE)[grepl("^a",dir())]
directB<- list.files(recursive=TRUE)[grepl("^b",dir())]
lista<- lapply(direct,function(x) read.table(x,header=TRUE,stringsAsFactors=FALSE,sep="\t",fill=TRUE))

listaA<-lapply(directA, function(x) read.table(x,header=TRUE, sep = "\t",fill=TRUE))
listaB<-lapply(directB, function(x) read.table(x,header=TRUE, sep = "\t",fill=TRUE))

#here I am changing the names listaT, z, etc..

count different mm values
?cab <- vector()
??? for (i in 1:length(lista)) {
???????? dc<-lista[[i]][ifelse(lista[[i]]$b<0.01, TRUE, FALSE),]
??????? dc<-table(dc$mm)
??????? cab <- c(cab, names(dc))
? }

?#Relative freqs to construct the graph
??? cab <- unique(cab)
??? d <- matrix(ncol=length(cab))
?dci<- d[-1,]
??? dcf <- d[-1,]
?dti <- d[-1,]
?dtf <- d[-1,]

??? ########################################
?for (i in 1:length(listaA)) {

? #Relative freq of all data
? dcc<-listaA[[i]]
? dcc<-table(factor(dcc$mm, levels=cab))
? dci<- rbind(dci, dcc)
? rownames(dci)<-rownames(1:(nrow(dci)), do.NULL = FALSE, prefix = "a")


? #Relative freq of data with FDR<0.01
? dcc1<-listaA[[i]][ifelse(listaA[[i]]$FDR<0.01, TRUE, FALSE),]
? dcc1<-table(factor(dcc1$mm, levels=cab))
? dcf<- rbind(dcf,dcc1)
? rownames(dcf)<-rownames(1:(nrow(dcf)), do.NULL = FALSE, prefix = "a")
??????? }

?for (i in 1:length(listaB)) {

? #Relative freq of all data
? dct<-listaB[[i]]
? dct<-table(factor(dct$mm, levels=cab))
? dti<- rbind(dti, dct)
? rownames(dti)<-rownames(1:(nrow(dti)), do.NULL = FALSE, prefix = "b")


? #Relative freq of data with FDR<0.01
? dct1<-listaB[[i]][ifelse(listaB[[i]]$FDR<0.01, TRUE, FALSE),]
? dct1<-table(factor(dct1$mm, levels=cab))
? dtf<- rbind(dtf,dct1)
? rownames(dtf)<-rownames(1:(nrow(dtf)), do.NULL = FALSE, prefix = "b")
??????? }
? freq.i<-rbind(dci,dti)
? freq.f<-rbind(dcf,dtf)
? freq.rel.i<-freq.i/apply(freq.i,1,sum)
? freq.rel.f<-freq.f/apply(freq.f,1,sum) 


?freq.i
#?? 2 3
#a1 4 1
#a2 4 1
#a3 4 1
#b1 4 1
#b2 4 1
#b3 4 1
#b4 4 1
#result from my code.??
?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) 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

There is a difference in output from freq.i and res4.? There were only two files under 'group_b`.? So, check your codes.
A.K.
Message-ID: <1361216483.3693.YahooMailNeo@web142606.mail.bf1.yahoo.com>
In-Reply-To: <CAHc7oGErcM9QYcB8NA-bmA=ioH0mU6PuRwXrQsFiACn035etyA@mail.gmail.com>