Dear all, please could you advise on a computationally quick way to compare and merge 2 long lists in R; the lists are of the following type, for example : <> in list 1 : chromosome, coordinateA, coordinateB, value1 chromosome, coordinateC, coordinateC, value2, etc <> in list 2 : chromosome, coordinateX, coordinateY, value6 chromosome, coordinateZ, coordinateT, value8, etc In the unified list, if coordinateA=coordinateX, and coordinateB=coordinateY, then we write : chromosome, coordinateA, coordinateB, value1, coordinateX, coordinateY, value6, otherwise, we write the individual values : chromosome, coordinateA, coordinateB, value1, chromosome, coordinateX, coordinateY, value6, thanks, bogdan [[alternative HTML version deleted]]
merge() most likely, but: are these really lists in the R sense? The correct answer depends on what the format actually is; you need to use dput() or some other unambiguous way of providing sample data. Without a reproducible example that includes some sample data provided using dput() (fake is fine), the code you used, and some clear idea of what output you expect, it's impossible to figure out how to help you. Here are some suggestions for creating a good reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Sarah On Thu, Sep 24, 2015 at 3:43 PM, Bogdan Tanasa <tanasa at gmail.com> wrote:> Dear all, > > please could you advise on a computationally quick way to compare and merge > 2 long lists in R; > the lists are of the following type, for example : > > <> in list 1 : > > chromosome, coordinateA, coordinateB, value1 > chromosome, coordinateC, coordinateC, value2, > etc > > <> in list 2 : > > chromosome, coordinateX, coordinateY, value6 > chromosome, coordinateZ, coordinateT, value8, > etc > > In the unified list, if coordinateA=coordinateX, and > coordinateB=coordinateY, then we write : > > chromosome, coordinateA, coordinateB, value1, coordinateX, coordinateY, > value6, > > otherwise, we write the individual values : > > chromosome, coordinateA, coordinateB, value1, > chromosome, coordinateX, coordinateY, value6, > > thanks, > > bogdan > > [[alternative HTML version deleted]] >and please don't post in HTML. -- Sarah Goslee http://www.functionaldiversity.org
Also, in addition to what Sarah told you, have you checked on the Bioconductor site, as this sounds like the sort of thing that they may well have something for already. ... and you've posted here often enough that you shouldn't still be posting HTML and you should know about toy examples! Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Thu, Sep 24, 2015 at 12:57 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:> merge() most likely, but: are these really lists in the R sense? > > The correct answer depends on what the format actually is; you need to > use dput() or some other unambiguous way of providing sample data. > > Without a reproducible example that includes some sample data provided > using dput() (fake is fine), the code you used, and some clear idea of > what output you expect, it's impossible to figure out how to help you. > Here are some suggestions for creating a good reproducible example: > http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example > > Sarah > > > On Thu, Sep 24, 2015 at 3:43 PM, Bogdan Tanasa <tanasa at gmail.com> wrote: >> Dear all, >> >> please could you advise on a computationally quick way to compare and merge >> 2 long lists in R; >> the lists are of the following type, for example : >> >> <> in list 1 : >> >> chromosome, coordinateA, coordinateB, value1 >> chromosome, coordinateC, coordinateC, value2, >> etc >> >> <> in list 2 : >> >> chromosome, coordinateX, coordinateY, value6 >> chromosome, coordinateZ, coordinateT, value8, >> etc >> >> In the unified list, if coordinateA=coordinateX, and >> coordinateB=coordinateY, then we write : >> >> chromosome, coordinateA, coordinateB, value1, coordinateX, coordinateY, >> value6, >> >> otherwise, we write the individual values : >> >> chromosome, coordinateA, coordinateB, value1, >> chromosome, coordinateX, coordinateY, value6, >> >> thanks, >> >> bogdan >> >> [[alternative HTML version deleted]] >> > and please don't post in HTML. > > -- > Sarah Goslee > http://www.functionaldiversity.org > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
Bogdan, I would look into bioconductor for packages handling this type choromosomal range data. cntools is one poped into my mind. Tao On Thursday, September 24, 2015 12:59 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote: merge() most likely, but: are these really lists in the R sense? The correct answer depends on what the format actually is; you need to use dput() or some other unambiguous way of providing sample data. Without a reproducible example that includes some sample data provided using dput() (fake is fine), the code you used, and some clear idea of what output you expect, it's impossible to figure out how to help you. Here are some suggestions for creating a good reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Sarah On Thu, Sep 24, 2015 at 3:43 PM, Bogdan Tanasa <tanasa at gmail.com> wrote:> Dear all, > > please could you advise on a computationally quick way to compare and merge > 2 long lists in R; > the lists are of the following type, for example : > > <> in list 1 : > > chromosome, coordinateA, coordinateB, value1 > chromosome, coordinateC, coordinateC, value2, > etc > > <> in list 2 : > > chromosome, coordinateX, coordinateY, value6 > chromosome, coordinateZ, coordinateT, value8, > etc > > In the unified list, if coordinateA=coordinateX, and > coordinateB=coordinateY, then we write : > > chromosome, coordinateA, coordinateB, value1, coordinateX, coordinateY, > value6, > > otherwise, we write the individual values : > > chromosome, coordinateA, coordinateB, value1, > chromosome, coordinateX, coordinateY, value6, > > thanks, > > bogdan > > [[alternative HTML version deleted]] >and please don't post in HTML. -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.