I have a dataframe consisting of pedigree data, with columns ID, DADID, MOMID, SEX and a few others for use in r packages kinship2 and optiSel. Currently my data is in factor form (the IDs are described by the individual's names rather than numbers) and this causes a problem when trying to format the resulting pedigrees from optiSel.
I'm not sure how familiar any of you are with optiSel, but it has a subPed function that creates a small pedigree from the large dataset given and uses values from the Kinship2 package to adjust the aesthetics of the plotted pedigree.
My issue arose when I tried to plot a larger pedigree, because the names overlapped eachother significantly and made it impossible to read. I couldn't adjust the width or length of the text nor the plot itself because of incompatibility of the kinship2 dataframe requirements vs optiSel. Kinship2 I believe requires the IDs to be in numeric form, so my goal is to find a quick function to change my characters to numbers that are consistent amidst all relationships in my pedigree data.
More specifically, I have one individual in a row under column ID
that appears in another row under column DADID
, and when I change their name to a number, I need these numbers to be equal (consistent with that character identity).
I cannot seem to find a quick way of doing this, as there are over 700 individuals in my pedigree data thus far.
sped<-subPed(pedigree, keep = c("Customs Ajax AAD"), prevGen = 2, succGen = 2)
pedplot(sped, cex = 0.2)
#The resulting pedigree from this is extremely small, but I can't make it any larger to see the names because there isn't sufficient room
pedplot(sped, cex = 0.2, width = 8)
#nothing changes because the 'width' aest isn't compatible
#attempt to plot with kinship2 instead:
plot.pedigree(sped, id=sped$Indiv)
Error in plot.pedigree(sped, id = sped$Indiv) : Wrong length for id
#trying to change characters to numbers:
pednum<-as.numeric(pedigree$ID)
#this only changes those of one column, and doesn't integrate it
#rename and replace functions don't work