gaynorr / AlphaSimR

R package for breeding program simulations
https://gaynorr.github.io/AlphaSimR/
Other
42 stars 18 forks source link

setMarkerHaplo/Geno removes trait names for gv #91

Closed janaobsteter closed 1 year ago

janaobsteter commented 1 year ago

Describe the bug If I simulate a trait and add names (e.g. "DailyGain") and then subsequently call pull- and setMarkerHaplo (or Geno) on a Pop class, the trait names are removed, but only for genetic values. They are still present for the phenotypes.

Steps To Reproduce

# Create founder haplotypes
founderPop = quickHaplo(nInd=10, nChr=1, segSites=15)
SP <- SimParam$new(founderPop)
SP$addTraitA(nQtlPerChr = 10, mean = 0, var = 1, name = "trait1")
SP$setVarE(varE = 1)
basePop <- newPop(founderPop)
basePop@gv
basePop@pheno

# Extract haplotypes for marker "1_1"
H = pullMarkerHaplo(basePop, markers="1_1")

# Set the first haplotype to 1
H[1,1] = 1L

# Set marker haplotypes
basePop = setMarkerHaplo(basePop, haplo=H)
basePop@gv
basePop@pheno

Expected behavior I'm guessing that the function recalculates the gv (but not the pheno) due to the changed genotype - but the names should be kept.

gaynorr commented 1 year ago

Thanks for catching this. Yes, this genetic values are recalculated incase a change hits alters the QTL genotype. It looks like I didn't handle trait names appropriately when this happens.