Family tree from a pedigree file

68 Views Asked by At

I have a pedigree file that looks like this:

FAMID ID MO FA SEX AGE BIRTH
F0001 C1 2 32
C2 1 34
C3 C1 C2 1 12
F0002 C4 2 44
C5 C4 Q1 1 13
C6 C4 Q1 1 12
Q1 1

Similar to this i have 100 F ID's and I want to create Family tree in R using a CSV file which similar data that is in the table presented.

This is the code I have used in R

# Install (if necessary) and load the kinship2 package
## install.packages("kinship2")
library(kinship2)

# Read the pedigree data from the CSV file
pedigree_data <- read.csv("CHS_Pedigree_new.csv")
View(pedigree_data)
# Ensure that the column names are in the correct case
colnames(pedigree_data) <- toupper(colnames(pedigree_data))

pedigree <- pedigree(
  id = pedigree_data$ID, 
  momid = pedigree_data$MO, 
  dadid = pedigree_data$FA, 
  sex = pedigree_data$SEX
)
# Plot the pedigree tree
plot(pedigree)

but this is giving me an error saying Impossible tree, I have rechecked all my code but I cannot get the specifics out of it.

0

There are 0 best solutions below