Skip to content

How to use PigPeaks with your own PigVision data?

Carolina Merca edited this page Nov 10, 2021 · 1 revision

First, go to the root and open the script Definitions.r, and make sure you are in agreement with the assumptions made. If not change them and save the script.

Then, open the csv file named Table_Indicators_CSV.csv which contains all the indicators available on PigVision for monitoring reproduction swine farms. There, choose which indicators you consider useful to monitor on your farm by setting TRUE on the column "indicators to keep", and FALSE on the ones that you do not want to monitor. Also, users can modify the labels in the column "indicators labels" if desired. All other columns are not subject to be changed.

Next, open the script Settings.r and fill in the information on "database connection settings". On the remaining script, accept the default arguments or change the ones you consider needed and save the script.

To successfully start using PigPeaks, open the script Data to Dashboard setup.r, follow the instructions written and run the codes in the following order:

1-extract data from database.r

This script, as the name says, extracts the farm's production data from PigVision. This assumes that the computer used has access to the PigVision program. Only need to do once and the data will be saved for all the retrospective phase.

2-create raw data arrays.r

With the data already extracted, this script groups the data into matrices, where each row is a day, and each column is a different sow. Also creates 2 data frames with every date (by day and by week) from start.date (chosen in Settings.r script).

3-tabulate indicators.r

This script organizes the data into indicators. Only the indicators chosen on the csv file are presented.

4-detection.r

By running this script the temporal aberration detection will be performed for each indicator chosen. First, a baseline is needed in order to train the detection algorithms with the typical background behavior against which the presence of abnormalities is investigated. Therefore, the baseline is created and, after that, cleaned to have an outbreak-free baseline. Next, the Exponentially Weighted Moving Average (EWMA) and Shewhart control charts are applied to the time-series.

5-dashboard.Rmd

This Rmd script creates the dashboard using flexdashboard R package, and the final result is a portable HTML page.

If after analyzing the dashboard the user wants to fine tune the system, open Definitions.r and Settings.r and make the changes desired. For a retrospective analysis, as the user already ran scripts "1" to "3", the data is already on the user's computer and organized into indicators. This means that only the scripts 4-detection.r and 5-dashboard.Rmd need to be run again.