mirror of
https://github.com/MillironX/beefblup.git
synced 2024-12-22 09:08:16 +00:00
Make column names more robust
This commit is contained in:
parent
91fc553c4c
commit
4b66ad8b1f
1 changed files with 21 additions and 0 deletions
|
@ -58,6 +58,9 @@ function beefblup(path::String, savepath::String, h2::Float64)
|
|||
# Import data from a suitable spreadsheet
|
||||
data = DataFrame(CSV.File(path))
|
||||
|
||||
# Make sure the data is in the proper format
|
||||
renamecolstospec!(data)
|
||||
|
||||
# Sort the array by date
|
||||
sort!(data, :birthdate)
|
||||
|
||||
|
@ -293,5 +296,23 @@ function additiverelationshipmatrix(id::AbstractVector, damid::AbstractVector, s
|
|||
return A
|
||||
end
|
||||
|
||||
"""
|
||||
renamecolstospec(::DataFrame)
|
||||
|
||||
Renames the first four columns of the beefblup data sheet so that they can be referred to by
|
||||
name instead of by column index, regardless of user input.
|
||||
"""
|
||||
function renamecolstospec!(df::DataFrame)
|
||||
# Pull out the fixed-effect and observation name
|
||||
othernames = propertynames(df)[5:end]
|
||||
|
||||
# Put specification column names and user-defined names together
|
||||
allnames = cat([:id, :birthdate, :dam, :sire], othernames, dims=1)
|
||||
|
||||
# Rename in the DataFrame
|
||||
rename!(df, allnames, makeunique=true)
|
||||
return df
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue