<p>We use <code>kinship2</code> R package to visualize pedigree files (.fam plink files). For some reasons, some characters from plink ped aren't supported (like "-9" for unknown genre or affected status).<br>
Here is the R script we use:  </p>

<pre><code>args&lt;-commandArgs(TRUE)
pedPath&lt;-args[1]
pdfFile&lt;-args[2]

library(kinship2)
pedfile &lt;- read.table(pedPath,sep="\t")
pedfile$V5 &lt;- apply(pedfile,1,function(data){if(data[5] == 1 || data[5] ==2){data[5]}else{3}}) 
pedfile$affected &lt;- apply(pedfile,1,function(data){if(as.numeric(data[6]) == 1){res &lt;- data[6]}else{if(as.numeric(data[6]) == 2){res &lt;- data[6]}else{res &lt;- NA}}})

familyIDs &lt;- as.character(unique(pedfile$V1))

pdf(file=pdfFile)
for(famID in familyIDs){
    ped &lt;- 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)
}
</code></pre>

<p>And we call it this way:  </p>

<pre><code>Rscript &lt;kinshipScript.R&gt; &lt;plink ped file&gt; &lt;pdf output&gt;
</code></pre>

CC BY-SA 4.0
2018-08-18T14:15:32.810Z
Now, if only I could convince people to include affected information in the actual .fam files. :-)
Mark Ebbert
CC BY-SA 4.0
2018-08-20T09:38:05.340Z
@MarkEbbert affected status is not really necessary but it still looks good on the pdf :)
Eric C.
CC BY-SA 4.0
2018-08-17T10:16:56.900Z
2018-08-17T10:16:56.900Z
Eric C.
<p>Is there a pedigree viewer that works with PLINK pedigree files? I saw an old post by <a href="https://www.biostars.org/p/60186/" rel="nofollow noreferrer">Pierre</a>, but I don't see the script on his blog.</p>

CC BY-SA 4.0
2018-08-17T10:04:38.660Z
We use R package kinship2 here: https://cran.r-project.org/web/packages/kinship2/index.html
Eric C.
<plink><pedigree>
Visualize PLINK pedigree files
# Visualize PLINK pedigree files

(Asked by: username_0 on 2018-08-16)

Is there a pedigree viewer that works with PLINK pedigree files? I saw an old post by [Pierre](https://www.biostars.org/p/60186/), but I don't see the script on his blog.

**Tags:** plink, pedigree
> **Comments:**
> **username_1**: We use R package kinship2 here: https://cran.r-project.org/web/packages/kinship2/index.html  

---

## 1 answers

### Answer by username_1 on 2018-08-17. Score: 3 | Accepted answer

We use kinship2 R package to visualize pedigree files (.fam plink files). For some reasons, some characters from plink ped aren't supported (like "-9" for unknown genre or affected status).
Here is the R script we use:  
args<-commandArgs(TRUE)
pedPath<-args[1]
pdfFile<-args[2]

library(kinship2)
pedfile <- read.table(pedPath,sep="\t")
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 <- NA}}})

familyIDs <- as.character(unique(pedfile$V1))

pdf(file=pdfFile)
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)
}

And we call it this way:  
Rscript

> **Comments:**
> **username_0**: Now, if only I could convince people to include affected information in the actual .fam files. :-)  
> **username_1**: @MarkEbbert affected status is not really necessary but it still looks good on the pdf :)  

---

