Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/alignped1.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# TODO add params and example

#' First routine alignement
#' First routine alignment
#'
#' @description
#' This is the first of the four co-routines.
Expand Down
2 changes: 1 addition & 1 deletion R/alignped2.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# TODO add params and example

#' Second routine alignement
#' Second routine alignment
#'
#' @description
#' This is the second of the four co-routines.
Expand Down
2 changes: 1 addition & 1 deletion R/alignped3.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# TODO add params and example and return

#' Third routine alignement
#' Third routine alignment
#'
#' @description
#' This is the third of the four co-routines.
Expand Down
58 changes: 29 additions & 29 deletions R/alignped4.R
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# Automatically generated from all.nw using noweb
# TODO add params and example and return
# TODO: Add detailed descriptions for parameters, examples, and return values

#' Fourth routine alignement
#' Fourth routine alignment
#'
#' @description
#' This is the last of the four co-routines.
#'
#' @details
#' 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,
#' 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 \code{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).
#' 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 amount plus one (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 :
#' the alignment penalty is:
#' $$
#' (1/k^a)\sum{i=1}{k} (x_i - (p_1 + p_2)^2
#' (1/k^a)\sum_{i=1}^{k} (x_i - (p_1 + p_2)/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
#' 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
#' By tethering all the sibs to a single spot they tend to be 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
Expand All @@ -46,18 +46,18 @@
#' shifted by a constant, the penalty matrix will not be positive definite;
#' \code{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
#' \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
#' subsequent one must be at least 1 unit to the right, and the final point
#' must be $\le$ the max width. }
#'
#' @param rval
#' @param spouse
#' @param level
#' @param width
#' @param align
#' @param rval A data structure containing necessary details for alignment.
#' @param spouse A logical vector indicating spouse relationships.
#' @param level The level of hierarchy in the pedigree.
#' @param width The maximum width for alignment.
#' @param align A vector of two alignment parameters, defaults to c(1.5, 2).
#'
#' @return newpos
#' @return newpos A vector of new positions after alignment.
#'
#' @examples
#' data(sample.ped)
Expand Down Expand Up @@ -112,7 +112,7 @@ alignped4 <- function(rval, spouse, level, width, align) {
pmat[nrow(pmat), myid[maxrow, 1]] <- 1e-5
ncon <- n + maxlev # number of constraints
cmat <- matrix(0., nrow = ncon, ncol = n)
coff <- 0 # cumulative constraint lines so var
coff <- 0 # cumulative constraint lines so far
dvec <- rep(1., ncon)
for (lev in 1:maxlev) {
nn <- rval$n[lev]
Expand All @@ -136,13 +136,13 @@ alignped4 <- function(rval, spouse, level, width, align) {
solve.QP(pp, rep(0., n), t(cmat), dvec)
},
warning = function(w) {
message(Solve QP ended with a warning)
message()(w)
message("Solve QP ended with a warning")
message(w)
return(NA)
},
error = function(e) {
message(Solve QP ended with an error)
message(w)
message("Solve QP ended with an error")
message(e)
return(NA)
}
)
Expand All @@ -154,7 +154,7 @@ alignped4 <- function(rval, spouse, level, width, align) {
newpos <- rval$pos
# fit <- lsei(pmat, rep(0, nrow(pmat)), G=cmat, H=dvec)
# newpos[myid>0] <- fit$X[myid]

if (length(fit) > 1) {
newpos[myid > 0] <- fit$solution[myid]
}
Expand Down
2 changes: 1 addition & 1 deletion R/besthint.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO add param, return, examples, keywords, seealso

#' Best hint for alignement
#' Best hint for alignment
#'
#' @description
#' When computer time is cheap, use this routine to get a "best" pedigree.
Expand Down
2 changes: 1 addition & 1 deletion R/makefamid.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @param id Identifier for each subject in the set of pedigrees
#' @param father.id Identifier for the father. This will be 0 or "" for a
#' founder.
#' @param mother.id Identifer for the mother.
#' @param mother.id Identifier for the mother.
#'
#' @return An integer vector giving family groupings
#'
Expand Down
4 changes: 2 additions & 2 deletions R/pedigree.shrink.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#' @examples
#' data(sample.ped)
#' pedAll <- with(sample.ped, pedigree(id, father, mother, sex,
#' affected = cbind(affected, avail), famid = ped
#' ))
#' affected = cbind(affected, avail), famid = ped))
#'
#' ped1 <- pedAll["1"]
#' ped1trim <- pedigree.shrink(ped1, maxBits = 12)
#'
Expand Down
4 changes: 2 additions & 2 deletions man/alignped1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/alignped2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/alignped3.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 27 additions & 19 deletions man/alignped4.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/as.data.frame.pedigree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/besthint.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions man/fixParents.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/kinship2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading