alignped4 | R Documentation |
This is the last of the four co-routines.
alignped4(rval, spouse, level, width, align)
align |
The alignped4 routine is the final step of alignment. It attempts to line
up children under parents and put spouses and siblings ‘close’ to each other,
to the extent possible within the constraints of page width.
The current code does necessary setup and then calls the quadprog
function.
There are two important parameters for the function:
One is the user specified maximum width. The smallest possible width is the
maximum number of subjects on a line, if the user suggestion is too low it is
increased to that 1+ that amount (to give just a little wiggle room).
The other is a vector of 2 alignment parameters $a$ and $b$.
For each set of siblings $x$ with parents at $p_1$ and $p_2$
the alignment penalty is :
$$
(1/k^a)\sumi=1k (x_i - (p_1 + p_2)^2
$$
where $k$ is the number of siblings in the set.
Using the fact that $\sum(x_i-c)^2 = \sum(x_i-\mu)^2 + k(c-\mu)^2$,
when $a=1$ then moving a sibship with $k$ sibs one unit to the left or
right of optimal will incur the same cost as moving one with only 1 or
two sibs out of place. If $a=0$ then large sibships are harder to move
than small ones, with the default value $a=1.5$ they are slightly easier
to move than small ones. The rationale for the default is as long as the
parents are somewhere between the first and last siblings the result looks
fairly good, so we are more flexible with the spacing of a large family.
By tethering all the sibs to a single spot they tend are kept close to
each other.
The alignment penalty for spouses is $b(x_1 - x_2)^2$, which tends to keep
them together. The size of $b$ controls the relative importance of sib-parent
and spouse-spouse closeness.
Part 1 We start by adding in these penalties.
The total number of parameters in the alignment problem
(what we hand to quadprog) is the set of sum(n)
positions.
A work array myid keeps track of the parameter number for each position so
that it is easy to find. There is one extra penalty added at the end.
Because the penalty amount would be the same if all the final positions were
shifted by a constant, the penalty matrix will not be positive definite;
solve.QP
does not like this.
We add a tiny amount of leftward pull to the widest line.
\item Part 2 If there are $k$ subjects on a line there will
be $k+1$ constraints for that line. The first point must be $\ge 0$, each
subesquent one must be at least 1 unit to the right, and the final point
must be $\le$ the max width.
newpos
plot.pedigree
, autohint
data(sample.ped)
ped <- with(sample.ped,pedigree(id, father, mother, sex, affected))
align.pedigree(ped)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.