vignettes/intro_shiny_app_use.Rmd
intro_shiny_app_use.Rmd
This tutorial demonstrates the major functions used within the Shiny application provided by the nprcmanager package. This is a brief tutorial that illustrates a typical workflow and does not explore all possible workflows.
Please provide any comments, questions, or bug reports through the GitHub issue tracker at https://github.com/rmsharp/nprcmanager/issues.
To get the most recent version you can install nprcmanager from GitHub with the following code.
All missing dependencies should be automatically installed.
You can start the Shiny application from the R console with
This will result in the opening screen where you tell the application how to find the pedigree you will be using.
Most of the screen is filled with information about formatting a text or Excel worksheet pedigree file.
Scrolling down to the middle of the opening screen exposes a table that describes a pedigree file and further instructions.
Scrolling down to the bottom of the opening screen exposes more pedigree file instructions, a table that describes a genotype file and instructions regarding use of a genotype file. This tutorial will not include instructions on using a genotype file.
In this introductory tutorial, we will use an Excel file containing a hypothetical pedigree of macques. We will work with the gray box on the left at the top of the screen.
A Microsoft Excel workbook with a single worksheet is the default file type; though comma (.csv), semi-colon (.txt), and tab (.txt) separated value files are all acceptable formats.
The Example_Pedigree.xlsx file we are using is from a CSV file created as shown below and then saved in an Excel format.
Select the Browse button and select the pedigree file from your file system.
It is important to make sure the minimum parent age is low enough for the animals in your pedigree. For our example pedigree, we are changing it from 4 years to 2 years of age since these macques may reproduce as early as two years of age. This is shown below in three progressive images with the center image demonstrating how the hovertext provides an explaination of how this value is used.
Selected Read and Check Pedigree will read in the file and test to see if the pedigree file has all of the columns needed and the pedigree is internally consistent.
Several error types, shown below, are detected the application.
Error | Definition |
---|---|
failedDatabaseConnection | Database connection failed: configuration or permissions are invalid |
missingColumns | Columns that must be within the pedigree file are missing. |
invalidDateRows | Values, which are supposed to be dates, cannot be interpreted as a date. |
suspiciousParents | Parents were too young on the date of birth of to have been the parent. |
femaleSires | Individuals listed as female or hemaphroditic and as a sire. |
maleDams | Individuals are listed as male and as a dam. |
sireAndDam | Individuals who are listed as both a sire and a dam. |
duplicateIds | IDs listed more than once. |
fatalError | Fatal Errors. |
changedCols | Columns that have been changed to conform to internal naming conventions and what they were changed to. |
The Pedigree Browser tab defaults to displaying 10 rows of the pedigree at a time, but you can choose to display 10, 25, 50, or 100 rows. You can choose to display UNKNOWN IDs in the rows displayed.
I have place red lines under the UNKNOWN IDs in the partial pedigree list below for clarity. These IDs have no meaning other than they all begin with the letter U and are following with a left alphnumeric string of five places. The form of this ID is set by the obfuscateId function.
In this example pedigree, when you deselect the Display Unknown IDs checkbox. The number of rows reduces from 3,694 to 2,322, because there were 1,372 UNKNOWN animals generated when constructing the pedigree to provide sire and dam placeholders for all animals.
The Pedigree Browser tab displays the full pedigree by default but allows you to select a subset of the pedigree by entering a list of animals of interest (focal animals).
You can enter in the animal IDs by typing them into the text box directly as shown below.
Also, you can import a list of focal animals by selecting the Browse button under Choose CSV file with focal animals. This file can be constructed by creating a simple text file with commas between animal IDs or by placing individual animal IDs on separate lines.
After entering your list of focal animals, you can select to trim the pedigree so that it will only include relatives of the focal animals you have selected.
A pedigree trimmed based on focal animals will have only the relatives of those animals remaining. In this instance there are only a total of 85 focal animals and their relatives.
The Pedigree Age Plot tab displays a standard pyramid plot for the pedigree as selected in the Pedigree Browser tab. This is showing 332 living animals from the entire example pedigree.
Selecting the Genetic Value Analysis tab and the Begin Analysis button will begin the gene dropping process, which you can monitor with the progress meter in the lower right corner of the display.
We are not aware of a systematic study of pedigree structure with this algorithm and have not performed extensive studies with pedigrees of various structures, but 1000 iterations has seemed to provide reproducible results.
As soon as the calculations are completed, a table showing the results of the analysis is displayed in 10 record increments. The calculations for 1000 iterations of the gene dropping algorithm took 1 minute 38 seconds with the example pedigree of 3,691 animals using a MacBook Pro (Mid 2014), 2.8 GHz Intel Core i7 with 16 GB of 1600 MHz DDR3 memory.
Again you can select how many rows to display at once by changing the values in the Show entries selection tool.
Searching down the table of results in the Value Designation column you can see starting at row 268 the values change from High Value to Low Value. Though not shown here, the value of Undetermined in the Value Designation column means the animal did not have parentage information.
The Summary Statisitics and Plots tab used results from the Genetic Value Analysis tab.
*********
The Export Kinship Matix button creates a CSV file that has a row and column for each individual in the genetic analyis plus a first row and first column each containing the IDs.
The first few rows of such a file are shown below.
The First-Order Relationships button creates a CSV file that has the following columns defined: an unnamed column for row number, id, parents, offspring, siblings, and total. The first few rows of such a file are shown below.
*********
The six plots provide histograms and boxplots for the kinship coefficients, the Z-scores of the kinship coefficients, and the genome uniqueness scores.
Selecting the Breeding Group Formation tab brings forward the screen shown below. In this screen you can form breeding groups using one of three ways based on your source of animals selected under Choose one group formation workflow:.
Further you must specify how you want to construct the breeding groups with regard to the groups’ sex ratios. The third of the three options (User specified sex ratio of breeders) causes the appearance of the field where you can fill in the sex ratio (F/M) that you want to have in the formed breeding groups. The sex ratio algorithm will form a group as nearly to the selected ratio as possible given the size of the group. Limits in the availability of either sex will restrict the size of the groups formed.
The Make Groups button appears once you select the source of animals you are going to use. However, you probably will be making additional selections using other controls on the screen.
The most common source of animals will be the high-value animals found by the genetic analysis.
You can either type in the number of groups that you want to form or select the number of groups using the arrows on the right edge of the Number of Groups Desired field, which is outlined in blue in the image below.
*********
You may select the Optional: Seed Groups with Specific Animals field if you decide to place some animals together within the groups because you know them to be compatible with each other.
This has been done in the example below using six groups with differing numbers of seed animals. Note the selection of having animals below the minimum parent age of two being grouped with their mother.
Each group has all of the seed animals that were assigned to it plus additional animals that could be added while satisfying the requirements imposed by the selected settings. I have indicated the seed animals for the first group with red rectangles.
Display of kinship values requires that the Include kinship in display of groups checkbox be selected prior to group formation.
A group of ten animals was formed in the next run after choosing to include kinship and selecting the Make Groups button.
The option to select a desired sex ratio allows you to select any ratio desired. However, the ratio obtained is limited by the availability of animals that meet all critera you have set.