[R] Pairwise Comparrisons

Bert Gunter gunter.berton at gene.com
Thu Jan 24 19:16:49 CET 2013


You need to get familiar with BioConductoR and post on that list.
Almost certainly you are trying to reinvent the wheel, and may even be
constructing it square.

Cheers,
Bert

On Thu, Jan 24, 2013 at 8:25 AM, Benjamin Ward (ENV) <B.Ward at uea.ac.uk> wrote:
> 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.ward at uea.ac.uk
> The Sainsbury Lab (JIC): ben.ward at sainsbury-lab.ac.uk
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list