You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' Align Phenotype Vector to Matrix Format for OpenMx
426
+
#'
427
+
#' This function takes a pedigree data frame, a specified phenotype column, and a vector of IDs to keep, and returns a matrix formatted for use in OpenMx models. The resulting matrix has one row and columns corresponding to the specified IDs, with values taken from the phenotype column of the pedigree.
428
+
#' @param ped A data frame representing the pedigree, containing at least the columns specified by \code{phenotype} and \code{personID}.
429
+
#' @param phenotype A character string specifying the column name in \code{ped} that
430
+
#' contains the phenotype values to be aligned.
431
+
#' @param keep_ids A vector of IDs for which the phenotype values should be extracted and aligned. These IDs should correspond to the values in the \code{personID} of \code{ped}.
432
+
#' @param personID A character string specifying the column name in \code{ped} that contains the individual IDs. Default is "ID".
warning("After converting IDs to numeric, all IDs became NA. This indicates ID coercion collapsed IDs. Please ensure IDs aren't character or factor variables.")
warning("After converting IDs to numeric, some IDs became NA. This indicates ID coercion collapsed some IDs. Please ensure IDs aren't character or factor variables.")
70
+
keep_string<-TRUE
71
+
}
72
+
if(keep_string==TRUE) {
63
73
fam<-data.frame(
64
74
V1= names(wcc$membership),
65
75
V2=wcc$membership
66
76
)
67
-
} else {
77
+
} else {
68
78
fam<-data.frame(
69
79
V1= as.numeric(names(wcc$membership)),
70
80
V2=wcc$membership
71
81
)
72
82
}
73
83
74
84
names(fam) <- c(personID, famID)
85
+
86
+
if(famID%in% names(ped)) {
87
+
if(overwrite) {
88
+
overwrite_message<-"be overwritten."
89
+
ped[[famID]] <-NULL
90
+
} else {
91
+
overwrite_message<-"not be overwritten."
92
+
fam[[famID]] <-NULL
93
+
}
94
+
95
+
warning(sprintf("The famID variable '%s' already exists in the pedigree. The existing variable will %s", famID, overwrite_message))
0 commit comments