0

I have some very simple pedigree data that I would like to make visualise graphically. Example data here

I have tried with kinship2, but had no success - see here for previous issues with kinship2

I have also been trying with igraph but have not been able to get the graph quite right. I have managed, with the below code, to get a good representation of female linages.

library(igraph)
library(dplyr)

GGM_igraph <- read.csv("example_data.csv")
mothers=GGM_igraph[,c('Ring','Mother','famid')]
fathers=GGM_igraph[,c('Ring','Father','famid')]
links<-left_join(mothers, fathers)
g=graph.data.frame(links)

this script is from this question originally

G_Grouped = g
E(G_Grouped)$weight = 1

## Add edges with high weight between all nodes in the same group
for(i in unique(V(g)$famid)) {
  GroupV = which(V(g)$famid == i)
  G_Grouped = add_edges(G_Grouped, combn(GroupV, 5), attr=list(weight=10))
} 

## Now create a layout based on G_Grouped
set.seed(567)
LO = layout_with_fr(G_Grouped)

## Use the layout to plot the original graph
par(mar=c(0,0,0,0))

# then plot the graph
plot(g, vertex.color=links$famid, layout=LO,
     vertex.size = 8,
     vertex.label.cex=.7,
     vertex.label.color = "black",
     edge.arrow.size = 0.25,
     edge.arrow.mode = 1)

igraph output

What I would like to do is: 1) include the males in the same graph as a number of them had offspring with more than one female over their life time 2) manually assign colours to each family. At the momemnt it is automatic, which is then assigning the mothers (most who don't have a family as they are founders) a random colour and also it is reusing some colours as there is not enough in the default pallette.

TomCLewis
  • 145
  • 2
  • 10
  • From your graph, it looks like example_data contains 60 or 70 records. Maybe you could reduce those down to a few dozen and include them in your question in `dput` format. It would probably help quite a bit to have some sample data to work with. – WaltS May 20 '20 at 20:52
  • Hi @WaltS. Thanks for the feedback. I am not familiar with `dput` format object or how to include them in a question. The code I have got in the question will load the dataset, all that is needed to add a file path. I have reduced the dataset as suggested. As I am not familiar with it, it would be great to understand the benifits of the `dput` compared to how I have it already. Cheers – TomCLewis May 22 '20 at 14:54

0 Answers0