diff --git a/R/alignped1.R b/R/alignped1.R index c1a9495d..2aada35d 100644 --- a/R/alignped1.R +++ b/R/alignped1.R @@ -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. diff --git a/R/alignped2.R b/R/alignped2.R index 38df9a03..825a431c 100644 --- a/R/alignped2.R +++ b/R/alignped2.R @@ -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. diff --git a/R/alignped3.R b/R/alignped3.R index fec2a132..70355db7 100644 --- a/R/alignped3.R +++ b/R/alignped3.R @@ -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. diff --git a/R/besthint.R b/R/besthint.R index bd122e66..23529751 100755 --- a/R/besthint.R +++ b/R/besthint.R @@ -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. diff --git a/R/pedigree.shrink.R b/R/pedigree.shrink.R index a5056594..dc6f1eb0 100644 --- a/R/pedigree.shrink.R +++ b/R/pedigree.shrink.R @@ -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) #' diff --git a/man/alignped1.Rd b/man/alignped1.Rd index fd548ae2..2ee78554 100644 --- a/man/alignped1.Rd +++ b/man/alignped1.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/alignped1.R \name{alignped1} \alias{alignped1} -\title{First routine alignement} +\title{First routine alignment} \usage{ alignped1(x, dad, mom, level, horder, packed, spouselist) } @@ -56,7 +56,7 @@ The third is when below is narrower, for instance an only child. } } \examples{ data(sample.ped) -ped <- with(sample.ped,pedigree(id, father, mother, sex, affected)) +ped <- with(sample.ped, pedigree(id, father, mother, sex, affected)) align.pedigree(ped) } diff --git a/man/alignped2.Rd b/man/alignped2.Rd index 27288168..81815ea5 100644 --- a/man/alignped2.Rd +++ b/man/alignped2.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/alignped2.R \name{alignped2} \alias{alignped2} -\title{Second routine alignement} +\title{Second routine alignment} \usage{ alignped2(x, dad, mom, level, horder, packed, spouselist) } @@ -34,7 +34,7 @@ onto rval. The rule thus is to not add any 1 element tree whose value } \examples{ data(sample.ped) -ped <- with(sample.ped,pedigree(id, father, mother, sex, affected)) +ped <- with(sample.ped, pedigree(id, father, mother, sex, affected)) align.pedigree(ped) } diff --git a/man/alignped3.Rd b/man/alignped3.Rd index 3b8d9d4d..724b4f1a 100644 --- a/man/alignped3.Rd +++ b/man/alignped3.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/alignped3.R \name{alignped3} \alias{alignped3} -\title{Third routine alignement} +\title{Third routine alignment} \usage{ alignped3(x1, x2, packed, space = 1) } @@ -37,7 +37,7 @@ Compute how far over we have to slide the right tree.} } \examples{ data(sample.ped) -ped <- with(sample.ped,pedigree(id, father, mother, sex, affected)) +ped <- with(sample.ped, pedigree(id, father, mother, sex, affected)) align.pedigree(ped) } diff --git a/man/alignped4.Rd b/man/alignped4.Rd index 7f051d8b..f8476bb0 100644 --- a/man/alignped4.Rd +++ b/man/alignped4.Rd @@ -2,45 +2,53 @@ % Please edit documentation in R/alignped4.R \name{alignped4} \alias{alignped4} -\title{Fourth routine alignement} +\title{Fourth routine alignment} \usage{ alignped4(rval, spouse, level, width, align) } \arguments{ -\item{align}{} +\item{rval}{A data structure containing necessary details for alignment.} + +\item{spouse}{A logical vector indicating spouse relationships.} + +\item{level}{The level of hierarchy in the pedigree.} + +\item{width}{The maximum width for alignment.} + +\item{align}{A vector of two alignment parameters, defaults to c(1.5, 2).} } \value{ -newpos +newpos A vector of new positions after 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 @@ -55,14 +63,14 @@ 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; \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. } } \examples{ data(sample.ped) -ped <- with(sample.ped,pedigree(id, father, mother, sex, affected)) +ped <- with(sample.ped, pedigree(id, father, mother, sex, affected)) align.pedigree(ped) } diff --git a/man/as.data.frame.pedigree.Rd b/man/as.data.frame.pedigree.Rd index 7ee79467..34a46add 100644 --- a/man/as.data.frame.pedigree.Rd +++ b/man/as.data.frame.pedigree.Rd @@ -20,7 +20,7 @@ Extract the internal data from a pedigree object into a data.frame } \examples{ data(sample.ped) -ped <- with(sample.ped,pedigree(id, father, mother, sex, affected)) +ped <- with(sample.ped, pedigree(id, father, mother, sex, affected)) as.data.frame.pedigree(ped) } diff --git a/man/besthint.Rd b/man/besthint.Rd index ca0bd68a..e91a94b8 100644 --- a/man/besthint.Rd +++ b/man/besthint.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/besthint.R \name{besthint} \alias{besthint} -\title{Best hint for alignement} +\title{Best hint for alignment} \usage{ besthint(ped, wt = c(1000, 10, 1), tolerance = 0) } diff --git a/man/fixParents.Rd b/man/fixParents.Rd index 809ffe60..9d0072ab 100644 --- a/man/fixParents.Rd +++ b/man/fixParents.Rd @@ -39,15 +39,23 @@ one parent id is given. } \examples{ -test1char <- data.frame(id=paste("fam", 101:111, sep=""), - sex=c("male","female")[c(1,2,1,2,1, 1,2, 2,1,2, 1)], - father=c(0,0,"fam101","fam101","fam101", 0,0, - "fam106","fam106","fam106", "fam109"), - mother=c(0,0,"fam102","fam102","fam102", 0,0, - "fam107","fam107","fam107", "fam112")) +test1char <- data.frame( + id = paste("fam", 101:111, sep = ""), + sex = c("male", "female")[c(1, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1)], + father = c( + 0, 0, "fam101", "fam101", "fam101", 0, 0, + "fam106", "fam106", "fam106", "fam109" + ), + mother = c( + 0, 0, "fam102", "fam102", "fam102", 0, 0, + "fam107", "fam107", "fam107", "fam112" + ) +) test1newmom <- with(test1char, fixParents(id, father, mother, - sex, missid="0")) -newped <- with(test1newmom, pedigree(id, dadid, momid, sex, missid="0")) + sex, + missid = "0" +)) +newped <- with(test1newmom, pedigree(id, dadid, momid, sex, missid = "0")) as.data.frame(newped) } diff --git a/man/kinship2.Rd b/man/kinship2.Rd index 5d83ee8e..fbbd6b13 100644 --- a/man/kinship2.Rd +++ b/man/kinship2.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/kinship2.R \docType{package} \name{kinship2} +\alias{kinship2-package} \alias{kinship2} \title{The kinship2 package for pedigree data} \description{ @@ -44,3 +45,26 @@ procedure when using the \code{/list} option of the \code{TABLE} statement. library(kinship2) } +\seealso{ +Useful links: +\itemize{ + \item \url{https://cran.r-project.org/package=kinship2} +} + +} +\author{ +\strong{Maintainer}: Jason Sinnwell \email{sinnwell.jason@mayo.edu} + +Authors: +\itemize{ + \item Terry Therneau +} + +Other contributors: +\itemize{ + \item Daniel Schaid [contributor] + \item Elizabeth Atkinson [contributor] + \item Carly Mester [contributor] +} + +} diff --git a/man/legendPlot.Rd b/man/legendPlot.Rd index 1408c025..56f909c0 100644 --- a/man/legendPlot.Rd +++ b/man/legendPlot.Rd @@ -51,13 +51,12 @@ represent colors and affection statuses } \examples{ -\dontrun{ 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"] -legendPlot(ped1, affected.label=c("cancer","available")) -} +legendPlot(ped1, affected.label = c("cancer", "available")) } \seealso{ diff --git a/man/ped2df.Rd b/man/ped2df.Rd index d12e4b97..c5d807ed 100644 --- a/man/ped2df.Rd +++ b/man/ped2df.Rd @@ -23,7 +23,7 @@ Convert a pedigree object to adata.frame } \examples{ data(sample.ped) -ped <- with(sample.ped,pedigree(id, father, mother, sex)) +ped <- with(sample.ped, pedigree(id, father, mother, sex)) ped2df(ped) } \seealso{ diff --git a/man/pedigree.Rd b/man/pedigree.Rd index 02dd4ef6..03b27c52 100644 --- a/man/pedigree.Rd +++ b/man/pedigree.Rd @@ -40,14 +40,19 @@ unaffected and affected, respectively. NAs are considered missing.} \item{status}{Censor/Vital status (0="censored", 1="dead")} \item{relation}{A matrix with 3 required columns (id1, id2, code) specifying -special relationship between pairs of individuals. Codes: 1=Monozygotic -twin, 2=Dizygotic twin, 3=Twin of unknown zygosity, 4=Spouse. (The last is -necessary in order to place a marriage with no children into the plot.) If -famid is given in the call to create pedigrees, then famid needs to be in -the last column of the relation matrix. Note for tuples of >= 3 with a -mixture of zygosities, the plotting is limited to showing pairwise zygosity -of adjacent subjects, so it is only necessary to specify the pairwise -zygosity, in the order the subjects are given or appear on the plot.} +special relationship between pairs of individuals. +Codes: +1=Monozygotic twin +2=Dizygotic twin +3=Twin of unknown zygosity +4=Spouse. +(The last is necessary in order to place a marriage with no children +into the plot.) If famid is given in the call to create pedigrees, then +famid needs to be in the last column of the relation matrix. +Note for tuples of >= 3 with a mixture of zygosities, the plotting is +limited to showing pairwise zygosity of adjacent subjects, so it is only +necessary to specify the pairwise zygosity, in the order the subjects are +given or appear on the plot.} \item{famid}{An optional vector of family identifiers. If it is present the result will contain individual pedigrees for each family in the set, which @@ -73,13 +78,18 @@ the following items: famid id findex mindex sex affected status relation Create a pedigree or pedigreeList object } \examples{ -data(minnbreast) bpeds <- with(minnbreast, pedigree(id, fatherid, - motherid, sex, affected=proband, famid=famid)) -bped.id8 <- bpeds['8'] +data(minnbreast) +bpeds <- with(minnbreast, pedigree(id, fatherid, + motherid, sex, + affected = proband, famid = famid +)) +bped.id8 <- bpeds["8"] print(bped.id8) ## show this pedigree with mixed zygosity quadruplets -rel8 <- data.frame(id1=c(137,138,139), id2=c(138,139,140), code=c(1,2,2)) -bped.id8 <- with(minnbreast[minnbreast$famid==8,], pedigree(id, fatherid, -motherid, sex, affected=proband, relation=rel8)) +rel8 <- data.frame(id1 = c(137, 138, 139), id2 = c(138, 139, 140), code = c(1, 2, 2)) +bped.id8 <- with(minnbreast[minnbreast$famid == 8, ], pedigree(id, fatherid, + motherid, sex, + affected = proband, relation = rel8 +)) print(bped.id8) } diff --git a/man/pedigree.legend.Rd b/man/pedigree.legend.Rd index ad2999e1..77a18935 100644 --- a/man/pedigree.legend.Rd +++ b/man/pedigree.legend.Rd @@ -31,7 +31,7 @@ resolution for the circle} \item{location}{similar to how the location of a base-R legend is given, used only if new=TRUE. A character string indicating which of the four corners to plot the legend, given by "bottomright", "bottomleft", "topleft", -or "topright".} +or "topright" or a vector of coordinates (numerical vector in the form x, y).} \item{new}{Logical. If TRUE, plot the legend on the current plot. Otherwise, plot on a separate plot.} @@ -52,16 +52,16 @@ Circular legend for a pedigree as a key to the affection statuses. } \examples{ -\dontrun{ data(sample.ped) fam1 <- sample.ped[sample.ped$ped == 1, ] -ped1 <- with(fam1, pedigree(id, father, mother, sex, affected = cbind(avail, - affected))) +ped1 <- with(fam1, pedigree( + id, father, mother, sex, + affected = cbind(avail, affected) +)) plot(ped1) pedigree.legend(ped1, location = "bottomright", radius = 0.8) pedigree.legend(ped1, location = "topleft", radius = 0.6, cex = 1.2) pedigree.legend(ped1, new = FALSE) -} } \seealso{ diff --git a/man/pedigree.shrink.Rd b/man/pedigree.shrink.Rd index ee48852a..8f96bc81 100644 --- a/man/pedigree.shrink.Rd +++ b/man/pedigree.shrink.Rd @@ -47,10 +47,11 @@ individuals (chosen at random if there are multiple of the same status): } \examples{ data(sample.ped) -pedAll <- with(sample.ped,pedigree(id, father, mother, sex, - affected=cbind(affected, avail), famid=ped) -ped1 <- pedAll['1'] -ped1trim <- pedigree.shrink(ped1, maxBits=12) +pedAll <- with(sample.ped, pedigree(id, father, mother, sex, + affected = cbind(affected, avail), famid = ped)) + +ped1 <- pedAll["1"] +ped1trim <- pedigree.shrink(ped1, maxBits = 12) } \seealso{