2010-06-30

Drawing pedigree examples using the kinship R package

I have previously provided sort of an overview about plotting the pedigrees, then specifically using the Graphiviz, while I have lately used the TikZ LaTeX (see slides 11-15) system (see more example). The later gives great (beautiful) results, but at the cost of writing TikZ code - it is not that horible, just time consuming - the same applies to Graphviz. Is there a quick way to plot a pedigree if we already have the data in the file. It is possible to do it in R using the kinship package. Here is an example:
ped <- data.frame( id=c( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
fid=c( 0, 0, 0, 3, 3, 5, 3, 6, 6, 0, 9),
mid=c( 0, 0, 0, 2, 1, 4, 4, 7, 7, 0, 10),
sex=c( 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2),
aff=0)
ped[11, "aff"] <- 1

library(package="kinship")
ped <- with(ped, pedigree(id=id, dadid=fid, momid=mid, sex=sex, affected=aff))
plot(ped)
Which gives the following result. It is not great, but it is informative and easy to do. From a practical point of implementation all pedigree members need to have both parents known or no parents known.

2010-06-29

Relationship between correlation and cosine

See very nice blog post by John D Cook here.

Sweave.sh in Eclipse-StatET

Sébastien Bihorel sent the following instructions on how to use my sweave.sh shell script in Eclipse-StatET.
1- First, you need to know the path to your TEXINPUTS settings. Type R CMD env |grep TEXINPUTS in a shell. In my installation (opensuse 11.2), the shell returned the following
TEXINPUTS=.::/usr/lib/R/share/texmf:

export TEXINPUTS

3- Download Gregor Gorjanc's sweave.sh script at http://cran.r-project.org/contrib/extra/scripts/Sweave.sh. Copy it to /usr/local/bin, rename the file to sweave (mv sweave.sh sweave) and make the file executable (chmod +ax sweave) if it is not already.

4- Open Eclipse and create a new Program in External Tools Configuration using the following settings:
>Main:
- location: /usr/local/bin/sweave
- working directory: \${container_loc}
- Arguments: -ld \${resource_loc}

>Refresh:
no selection

>Build:
Build before launch: checked
The project containing the selected resource: checked
Include referenced projects: checked