@@ -41,6 +41,53 @@ standardizeColnames <- function(df, verbose = FALSE) {
4141
4242 return (df )
4343}
44+ # ' Restore Original Column Names in a Pedigree Dataframe
45+ # '
46+ # ' This function restores the original column names of a pedigree dataframe
47+ # ' based on user-specified names. It is useful for reverting standardized column
48+ # ' names back to their original names after processing.
49+ # ' @param ped A pedigree dataframe with standardized column names.
50+ # ' @param famID The original name for the family ID column. Default is "fam
51+ # ' ID".
52+ # ' @param personID The original name for the person ID column. Default is "ID".
53+ # ' @param momID The original name for the mother ID column. Default is "momID".
54+ # ' @param dadID The original name for the father ID column. Default is "dadID".
55+ # ' @param gen The original name for the generation column. Default is "gen".
56+ # ' @param patID The original name for the paternal ID column. Default is "patID".
57+ # ' @param matID The original name for the maternal ID column. Default is "matID".
58+ # ' @param spID The original name for the spouse ID column. Default is "spID".
59+ # ' @param twinID The original name for the twin ID column. Default is "twinID".
60+ # ' @param zygosity The original name for the zygosity column. Default is "zygosity".
61+ # ' @param sex The original name for the sex column. Default is "sex".
62+ # ' @return A pedigree dataframe with restored original column names.
63+ restorePedColnames <- function (ped ,
64+ famID = " famID" ,
65+ personID = " ID" ,
66+ momID = " momID" ,
67+ dadID = " dadID" ,
68+ gen = " gen" ,
69+ patID = " patID" ,
70+ matID = " matID" ,
71+ spID = " spID" ,
72+ twinID = " twinID" ,
73+ zygosity = " zygosity" ,
74+ sex = " sex"
75+ ) {
76+
77+ names(ped )[names(ped ) == " ID" ] <- personID
78+ names(ped )[names(ped ) == " momID" ] <- momID
79+ names(ped )[names(ped ) == " dadID" ] <- dadID
80+ names(ped )[names(ped ) == " famID" ] <- famID
81+ names(ped )[names(ped ) == " gen" ] <- gen
82+ names(ped )[names(ped ) == " patID" ] <- patID
83+ names(ped )[names(ped ) == " matID" ] <- matID
84+ names(ped )[names(ped ) == " spID" ] <- spID
85+ names(ped )[names(ped ) == " twinID" ] <- twinID
86+ names(ped )[names(ped ) == " zygosity" ] <- zygosity
87+ names(ped )[names(ped ) == " sex" ] <- sex
88+ ped
89+ }
90+
4491
4592
4693# Repair Pedigree
0 commit comments