View source: R/fillGroupMembersWithSexRatio.R
fillGroupMembersWithSexRatio | R Documentation |
The sex ratio is the ratio of females to males.
fillGroupMembersWithSexRatio(
candidates,
groupMembers,
grpNum,
kin,
ped,
minAge,
numGp,
sexRatio
)
candidates |
character vector of IDs of the animals available for use in the group. |
groupMembers |
list initialized and ready to receive groups with the desired sex ratios that are created within this function |
grpNum |
is a list |
kin |
list of animals and those animals who are related above a threshold value. |
ped |
dataframe that is the |
minAge |
integer value indicating the minimum age to consider in group formation. Pairwise kinships involving an animal of this age or younger will be ignored. Default is 1 year. |
numGp |
integer value indicating the number of groups that should be formed from the list of IDs. Default is 1. |
sexRatio |
numeric value indicating the ratio of females to males x from 0.5 to 20 by increments of 0.5. |
A list containing one character vector of animal IDs such that the
sex ratio of the group is as close as possible to the ratio
specified by sexRatio
.
examplePedigree <- nprcgenekeepr::examplePedigree
ped <- qcStudbook(examplePedigree, minParentAge = 2, reportChanges = FALSE,
reportErrors = FALSE)
kmat <- kinship(ped$id, ped$sire, ped$dam, ped$gen, sparse = FALSE)
currentGroups <- list(1)
currentGroups[[1]] <- examplePedigree$id[1:3]
candidates <- examplePedigree$id[examplePedigree$status == "ALIVE"]
threshold <- 0.015625
kin <- getAnimalsWithHighKinship(kmat, ped, threshold, currentGroups,
ignore = list(c("F", "F")), minAge = 1)
# Filtering out candidates related to current group members
conflicts <- unique(c(unlist(kin[unlist(currentGroups)]),
unlist(currentGroups)))
candidates <- setdiff(candidates, conflicts)
kin <- addAnimalsWithNoRelative(kin, candidates)
ignore <- NULL
minAge <- 1
numGp <- 1
harem <- FALSE
sexRatio <- 0
withKin <- FALSE
groupMembers <- nprcgenekeepr:::makeGroupMembers(numGp,
currentGroups,
candidates,
ped,
harem = harem,
minAge = minAge)
groupMembersStart <- groupMembers
grpNum <- nprcgenekeepr:::makeGrpNum(numGp)
groupMembers <- fillGroupMembersWithSexRatio(
candidates, groupMembers, grpNum, kin, ped, minAge, numGp, sexRatio = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.