##########################
##
## Perform the simulation analysis
##
## Load the test data.
data(minnbreast)
## Subset to some families and generate the pedigree data.frame
mbsub <- minnbreast[minnbreast$famid == 165 | minnbreast$famid == 432, ]
PedDf <- mbsub[, c("famid", "id", "fatherid", "motherid", "sex")]
colnames(PedDf) <- c("family", "id", "father", "mother", "sex")
## Generate the FAData.
fad <- FAData(pedigree=PedDf)
## Specify the trait.
tcancer <- mbsub$cancer
names(tcancer) <- mbsub$id
## Perform the kinship group test.
far <- kinshipGroupTest(fad, trait=tcancer, traitName="cancer", nsim=1000)
res <- result(far)
head(res)
## Plot the pedigree for the most significant kinship group
plotPed(far, id=res[1, "group_id"])
## The full pedigree for this affected individual and its kinship group is
## large:
nrow(buildPed(far, id=res[1, "group_id"]))
## We can however restrict it to a reduced pedigree containing only the
## kinship group and all individuals with a kinship >= the smallest kinship
## between the individual and any other affected individual in the pedigree:
nrow(buildPed(far, id=res[1, "group_id"], prune=TRUE))
## By specifying prune=TRUE we can restrict the pedigree plot to these
## individuals
plotPed(far, id=res[1, "group_id"], prune=TRUE)
## Get the ids of all individuals sharing kinship with any of the inddividuals
## in that kinship group:
shareKinship(far, id=res[1, "group_id"])
## Plot the simulation analysis result for the ratio test.
plotRes(far, id=res[1, "group_id"], type="hist")
Run the code above in your browser using DataLab