Closed nh13 closed 5 years ago
Here's a really ugly script to plot the .fam
file adapted from here
require(kinship2)
args<-commandArgs(TRUE)
pedPath<-args[1]
pdfFile<-args[2]
pedfile <- read.table(pedPath,sep=" ")
pedfile$V5 <- apply(pedfile,1,function(data){if(data[5] == 1 || data[5] ==2){data[5]}else{3}})
pedfile$affected <- apply(pedfile,1,function(data){if(as.numeric(data[6]) == 1){res <- data[6]}else{if(as.numeric(data[6]) == 2){res <- data[6]}else{res <-0}}})
familyIDs <- as.character(unique(pedfile$V1))
pdf(file=pdfFile, width=12, height=12)
for(famID in familyIDs){
ped <- pedigree(id=as.character(pedfile$V2[pedfile$V1==famID]),dadid=as.character(pedfile$V3[pedfile$V1==famID]),momid=as.character(pedfile$V4[pedfile$V1==famID]),sex=as.numeric(pedfile$V5[pedfile$V1==famID]),affected=as.numeric(pedfile$affected[pedfile$V1==famID]))
plot.pedigree(ped,cex=0.7,align=TRUE)
title(famID)
}
Though simple, plot-fam.R plots all the families in a fam file (see this section in the README).
I had to draw them out to visualize the example relationships. It would be great to include a image per def in the examples to verify.