I have a dataset of peptide 15N/14N ratios from four experiments (where cells are grown under different conditions and were fed either 15N or 14N nitrate aka plant food if you are interested) and I want to normalize each of these ratios to the median 15N/14N value from all >6000 peptides from each experiment. Then, since these ratios (from 2 or more peptides) are used to calculate the protein 15N/14N abundance, I want to take the median value of all peptides belonging to one protein to calculate the overall protein 15N/14N abundance within that experiment.
Iâve managed to break the data set into small pieces (by protein and by experiment), which will lead to about 500 observations. A dummy â small â dataset could look like this (below), where V1 lists the peptides that make up a protein, V2 is the protein ID, V3 is the metric of interest (the 15N/14N ratio of each peptide), and V4 indicates which experiment was run. The stumbling block here is that I cannot index the median function. Here is what I have done so far. y<-read.table(ânameoffile.txtâ) h<-split(y,y$V4) for(n in names(h)) write.table(h[[n]], file=paste(y[[n]][,âV4â][4],â_â,n,â.TXTâ,sep=ââ)) Then I (not elegantly but OK with brute force method for four files) went into each file and calculated the median vls1<-read.table(âVLS5584_VLS5584.TXTâ) # for example, but did this four times for each file newcol=vls1[,3]/median(vls1[,3]) normvls1=cbind(vls1,newcol) nvls1prot<-split(normvls1,normvls1$V2) for(n in names(nvls1prot))write.table(nvls1prot[[n]],file=paste(nvls1prot[[n]][,"V4"][1],"_", n,".TXT",sep="")) Then I took this output in windows explorer and moved it to a new folder. Set working directory to that folder. And, lifted from a help page and tweaked to my liking.. for (i in 1:length(txtfiles)){ tmp = read.table(txtfiles[i]) xyz = data.frame(tmp) normHL = xyz[[5]] median[i] = median(normHL) } But after that, I get the following error message. Error in median[i] = median(normHL) : object of type 'closure' is not subsettable Thanks, Adam Kustka SEAEFVNYQVR B5YLU3 0.226 VLS5584 LLQTEPGTR B5YLU3 0.199 VLS5584 SEAEFVNYQVR B5YLU3 0.216 VLS5585 LLQTEPGTR B5YLU3 0.183 VLS5585 SEAEFVNYQVR B5YLU3 0.266 VLS5586 FAQMAVLGFIIPEK B5YLU3 .2 VLS5586 LLQTEPGTR B5YLU3 0.203 VLS5586 SEAEFVNYQVR B5YLU3 0.516 VLS5587 FAQMAVLGFIIPEK B5YLU3 0.764 VLS5587 IEGLGWRPK B5YLU3 .2 VLS5587 LLQTEPGTR B5YLU3 0.338 VLS5587 LLQTEPGTR B5YLU3 .2 VLS5587 FSCAYLVDNPR B5YLV4 0.131 VLS5584 ITCQDPSDDFPTYR B5YLV4 0.122 VLS5584 SPLPEDLMPEFSFR B5YLV4 0.105 VLS5584 ITCQDPSDDFPTYR B5YLV4 .2 VLS5585 FLEVPMYLK B5YLV4 .2 VLS5585 ITCQDPSDDFPTYR B5YLV4 0.113 VLS5585 ITCQDPSDDFPTYR B5YLV4 0.112 VLS5586 FSCAYLVDNPR B5YLV4 0.128 VLS5586 SPLPEDLMPEFSFR B5YLV4 0.126 VLS5586 FLEVPMYLKCLDR B5YLV4 0.406 VLS5586 LYYNVETLK B5YLV4 0.11 VLS5586 GEDGYLTTK B5YLV4 0.144 VLS5586 FLEVPMYLK B5YLV4 0.134 VLS5586 ITCQDPSDDFPTYR B5YLV4 .2 VLS5586 FSCAYLVDNPR B5YLV4 .2 VLS5586 FKDDFFLK B5YLV4 0.121 VLS5586 ITCQDPSDDFPTYRDLEK B5YLV4 0.138 VLS5586 FLEVPMYLK B5YLV4 0.123 VLS5586 CFDDAFVR B5YLV4 0.15 VLS5586 VFFTHGMYYTGGNLVAQVK B5YLV4 0.25 VLS5586 FKDDFFLK B5YLV4 0.141 VLS5586 CGFDEVHAR B5YLV4 0.108 VLS5586 YPENYNIEELPAAGQSYIHPDTYVQR B5YLV4 0.153 VLS5587 SPLPEDLMPEFSFR B5YLV4 0.153 VLS5587 FSCAYLVDNPR B5YLV4 0.137 VLS5587 LYYNVETLK B5YLV4 0.157 VLS5587 CGFDEVHAR B5YLV4 0.145 VLS5587 FLEVPMYLK B5YLV4 0.142 VLS5587 [[alternative HTML version deleted]]
______________________________________________ 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.