---
title: "Development Plans"
author: "R. Mark Sharp"
date: "March 19, 2020"
output: 
   - rmarkdown::pdf_document
   - rmarkdown::latex_document
   - rmarkdown::html_vignette
   - rmarkdown::word_document
vignette: >
  %\VignetteEngine{knitr::knitr}
  %\VignetteIndexEntry{Development Plans}
  %\usepackage[UTF-8]{inputenc}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


## Possibilities
1. Amanda Vinson wrote this in an e-mail on 20170901:
  
    I'm very interested in hearing about your idea of adding algorithms related 
    to selecting/maintaining specific alleles in a colony. 
    I think your idea could be related to what I need to work on next, 
    which is an algorithm for assessing the long-term impact on colony genetic 
    diversity of removing specific animals/alleles.  
    This is a need we have here at the ONPRC due to assigning animals to  
    research, and I have been tasked with implementing the solution.

1. Remove individuals that can never breed again from genetic analyses.
(From page 29 of _PMx User Manual, version 1.0_).
It is generally recommended to remove living individuals that can never breed 
or will never be bred again (e.g., post reproductive, sterilized, poor health, 
hybrid) from the genetic mean kinship calculations, as these individuals can no 
longer pass on their genetic material to the next generation and their 
inclusion influences the mean kinship values of other individuals in the 
population. However, these non-reproductive individuals may occupy cage space 
and need to be managed in other ways. In addition, their demographic 
information is valuable. Managers therefore often chose to include these 
individuals in the demographic analysis but to exclude them from genetic 
analysis. 

1. It would be nice to have multiple "selected populations" that could be 
   set up and easily selected for various analyses and plots.

1. Talk to Amanda about developing a general way to handle animals without 
   two known parents that are not founders. There are the following lines of 
   code in orderReport.R

    `# ONPRC-born animals with no parentage`  
    `i <- (is.na(rpt\$origin) & (rpt\$totalOffspring == 0) &`
    `(rpt\$id %in% founders))`
    `noParentage <- rpt[i, ]`

1. Find some ways to use genetic marker data in the evaluation of genetic 
   value. This needs to be discussed.

1. Add breeding productivity measure calculations. For example, (a) number of
   offspring per year of exposure to male or female. (b) Number of months since
   last birth. (c) Number of months between births with range and standard
   deviation.

1.  Consider developing a simulation module to allow users to simulate breeding 
    decisions.
    a.  Need to be able to set the following values.
        a.  Number desired males produced each year
        b.  Frequency of matings that produce offspring that can successfully 
            breed
        c.  Number of animals of each sex and age removed from breeding each
            year. 
            This would not necessarily be constant, it could be a list with 
            sublist for each year.
        d.  Ability to choose among various mating strategies based on age, 
            mean kinship,
        e.  Practical numbers of each sex in a breeding group
        f.  Percent of year needed to adapt to new mating structure after a 
            change.
        g.  Loss due to mortality rate by age and sex
        h.  Ability to use arbitrary or historical data for mating success
    b.  Breeding methods based on mean kinship (MK)
        a.  Static MK
            a.  At each timestep, all individual MKs for animals of breeding age
                are calculated and 2 sex-specific lists 
                created that rank individuals from lowest MKs to highest.
            b.  Breeding groups are formed with breeding pairs having to have a 
                kinship coefficient (_f_) less than the average _f_ in the 
                population to avoid close inbreeding. 
                When a pair is rejected, remaining females, running from
                lowest MK to highest become the next potential mates. 
                If a suitable female is not found, that male is removed from 
                the pool of potential breeders and an attempt is made to pair 
                the next lowest MK male with the MK list of females.
            c.  Offspring are simulated and stored.
        b.  See jhered.esr129.full.pdf page 188 for other breeding strategies.

##  Notes
1. There are some functions that are defined and not used in the Shiny app. 
   They may be needed later.
    1. findLoops
    2. makeLoop
    3. countLoops
    4. createPedTree
    
   I expect they are direct ports from kinship2. 
   I will check.
   


