MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Union, Sort at different levels of a list

  • To: mathgroup at
  • Subject: [mg65680] Union, Sort at different levels of a list
  • From: leigh pascoe <leigh at>
  • Date: Fri, 14 Apr 2006 04:32:04 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Hello Everyone,

I am having a problem with the syntax for Sorting at different levels of 
a list structure. My problem arises in genetics, where an individual 
locus is characterised by two alleles, say (i,j).
If I consider a general mating with parents (i,j) and (k,l) they will 
have possible offspring (i,k),(i,l),(j,k),and (j,l). I want to generate 
all the possibilities for a general mating with the offspring and tried 
the following.

{{1,1,x,1, 2},{{1,1},{1,2},{1,1},{1,2}}}},

This gives me the full list of possible parents and offspring (the x's 
are for visual clarity only). However I would like to simplify it. In 
general it is assumed that (i,j) is the same as (j,i), i.e. these are 
sets of alleles. It is also usually assumed that the parental 
combination (i,j),(j,k) is the same as (j,k),(i,j). The obvious function 
to use is Union after Sorting to reduce the number of classes, but I am 
having trouble getting the syntax correct for applying the functions at 
the appropriate level.

I tried another approach as follows

It gives the parental combinations as a nested list with the individual 
genotypes (doublets) sorted. Then


works for a given set of parents, but how can I thread it over the list 
of all parents pairs? And then apply Union to produce, for example in 
the two allele case, the parents with their offspring as

{{{1,1},{1,1}}, >{{1,1}}
{{1,1},{1,2}}, > {{1,1},{1,2}}
{{1,2},{1,2}}, > {{1,1},{1,2},{2,2}
{{1,2},{2,2}}, > {{1,2},{2,2}}
{{2,2},{2,2}}} > {{2,2}}

(I typed this in, the format is unimportant). This is the form that one 
normally sees the data in. Eventually I am aiming at writing a 
likelihood equation, but I am having trouble just listing all the 
possibilities. Any help much appreciated.


  • Prev by Date: Re: A conditional random number generation problem (please help me!)
  • Next by Date: Missing MathGroup Posts (Admin)
  • Previous by thread: Re: 3D ContourGraphics alternative
  • Next by thread: Re: Union, Sort at different levels of a list