Dear all, I'm trying to write a function, that will take as an argument, some aligned genome sequences, and using a sliding window, do pairwise comparisons of sequence similarity. Coding the sliding window I think I can manage but what I'm trying to get to grips with is getting it so as every pairwise comparison is made, no matter how many genomes are added, from 3 to N.
So if I had four genome sequences, G1, G2, G3, G4 the comparisons would be: G1:G1 G1:G2 G1:G3 G1:G4 G2:G2 G2:G3 G2:G4 G3:G3 G3:G4 G4:G4 I can think of a way this might be done with a very complicated loop, which would take the region in the window of each genome and then make all possible combination/comparrisons: So the loop would take G1, and then in turn compare against G2, G3, G4. Then it would take G2, and start again and pair it with everything from G1 to G4, then it would take G3 and compare with everything from G1 to G4, and then finally would take G4, and compare it with everything from G1 to G4. This is a wasteful way of doing it however, because for example, by the time the loop gets around to dealing with G4 as it's first argument I.e. the G4:GN comparisons, all comparisons with G4 in apart from G4:G4 have already been made I.e. G4:G1 is just G1: G4 backwards. So it's really wasteful and computing stuff that isn't necessary. So my question is, how can someone do pairwise comparisons in R this way, and ensure all combinations are compared, but it's not as wasteful as my obvious shotgun approach which computers many redundant comparisons? Ben W. University of East Anglia (ENV): b.w...@uea.ac.uk The Sainsbury Lab (JIC): ben.w...@sainsbury-lab.ac.uk [[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.