Skip to content

timflutre/PlantBreedGame

Repository files navigation

title
PlantBreedGame

Overview

PlantBreedGame is a software implementing a serious game to teach selective breeding via the example of a fictitious annual plant species to students at the master level. It takes the form of a Shiny application, benefiting from the R programming language and software environment for statistical computing.

This software is available under a free software license, the GNU Affero General Public License (version 3 and later); see the COPYING file. The copyright is owned by the Institut National de la Recherche Agronomique (INRA) and Montpellier SupAgro.

It is versioned using the git software, the central repository being hosted here on GitHub, and the institutional repository being hosted there on SourceSup. The README file is available at https://sourcesup.renater.fr/plantbreedgame/.

Example

You can discover an example online here. But if you want to install the game on your own computer or server, read on!

Installation

Note: for nix users, a flake is available in this repository (cf. Nix section)

Dependencies

Before using this game, you need to install R as well as various packages, listed in the file src/dependencies.R. Then it should work on Unix-like operating systems (GNU/Linux, Mac OS) as well as on Microsoft Windows.

Locally on your computer

  1. Retrieve the Shiny application, by downloading it as a ZIP archive (then unzip it and rename the directory).

Here is how to do it in a terminal for Unix-like operating systems:

wget https://github.com/timflutre/PlantBreedGame/archive/master.zip
unzip master.zip
mv PlantBreedGame-master PlantBreedGame

The package can also be installed after cloning the git repository:

git clone [email protected]:timflutre/PlantBreedGame.git
  1. Finally, open a R session, and execute the following commands:
library(shiny)
setwd("path/to/PlantBreedGame")
runApp()

A web page should automatically open in your default web browser, and you should be able to start playing. See the explanations below in the section "Usage".

To set up your own server

It is highly recommended to start by installing the application on your computer (see the previous section).

First, you need to have a Shiny server installed and running, say, in /srv/shiny-server. We only tested with the open source version, but it should also work with the pro version. For all this, have a look at the official documentation.

Second, you need to add an application to the server. Start by downloading, for instance in your home, our Shiny application as a ZIP archive or clone the git repository (see explanations in the previous section):

cd ~
wget https://github.com/timflutre/PlantBreedGame/archive/master.zip
unzip master.zip
mv PlantBreedGame-master PlantBreedGame

Then, create a new directory for the application (let's call it breeding-game here):

mkdir /srv/shiny-server/breeding-game

and copy inside the content of the Shiny application you just downloaded:

cp -r ~/PlantBreedGame-master/* /srv/shiny-server/breeding-game

By default, the Shiny server runs as a unix user named shiny. You hence need to create a unix group, named for instance breeding, to which the shiny user can be added (the Shiny server may need to be restarted for this to be taken into account).

Everything inside the breeding-game directory should be readable and writable for users who are part of the breeding group. This is particularly the case for the data set (data directory, generated by running plantbreedgame_setup.Rmd, see the previous section).

chgrp -R breeding /srv/shiny-server/breeding-game
chmod -R ug+rw,o-rwx /srv/shiny-server/breeding-game

Now go to the URL of the breeding-game application made available by your Shiny server. If you encounter an error, look at the log, for instance:

less /var/log/shiny-server/breeding-game-shiny-20180129-100752-39427.log

Errors may be due to missing packages, otherwise report an issue (see below). Once all requested packages are installed, you should be able to start playing. See the explanations below in the section "Usage".

šŸ‹ Docker

Thank to docker, you can deploy this application without installing anything more than docker on your server.

To install docker please refer here: ubuntu, debian, other.

Deployment

A docker image of this application is available on Docker Hub: juliendiot/plantbreedgame.

Those images are tagged in 3 different ways:

  • latest: The latest stable version
  • development: The latest development version
  • X.X.X: The image corresponding the plantBreedGame version X.X.X

In the following commands, you can replace juliendiot/plantbreedgame:latest with the version you want to use.

1st method

For testing purpose, the simplest way to run the application using docker is with this command:

docker run -d --rm --name plantbreedgame -p 80:3838 juliendiot/plantbreedgame:latest

The application is then accessible on the host machine on port 80 at the path /PlantBreedGame, for example: localhost:80/PlantBreedGame on your personal computer.

Be careful ! Stopping this container will erase all the progress of the players.

2nd method

For actual game session, you need to specify to docker a persistent "volume" where it can save and keep the game data when the container is stoped.

With the command below:

docker run -d --rm --name plantbreedgame -p 80:3838 \
    -v /host/path/to/plantBreedGameData:/var/lib/plantBreedGame \
    juliendiot/plantbreedgame:latest

The game data will be saved in the host machine at /host/path/to/plantBreedGameData. You can select any location you want.

Usage

Game Initialisation

To start playing, the game need some specific data (eg. the genotypes and haplotypes of the initial population, a data-base...). This initialisation can be done through the game.

The first time you run the application, most of the game menus will show a message asking you to initialise the game. To do so you need to go to the Admin menu, and in Game Initialisation tab. There you will find some parametres you can tweak to customise the game and a button that will start the game initialisation. Once the initialisation is completed (which takes about 2 minutes), the page will automatically reload and you will be able to connect and play the game.

The game initialisation will automatically create an admin breeder with the default password 1234.

If the game have already been initialise, it is also possible to re-initialise it to start a new "fresh game". However in such case all the data of the game will be lost.

How to play

Once the application is installed and working, please read the game rules (tab How to play?) and start by downloading the initial data set as well as example files showing how requests should be formatted (all files listed at the bottom of the tab How to play?).

Before making any request, such as phenotyping, you need to log in (tab Identification). To get a sense of how the interface works, you can use the "test" breeder with the "tester" status which doesn't require any password and isn't subject to time restriction.

All your files, whether they are inputs for a request or outputs of a request, are available for download in the tab Identification (once logged in). But remember that regular players (not testers nor the game master) have time restrictions. This means that, even if a plant material request is successful, you will have to wait before using your new genotypes in other crosses or before requesting data on it. Similarly, even if a phenotyping/genotyping request is successfull, you will have to wait before downloading the output file.

For your selection to work, you need to analyze the initial data carefully. The Theory tab can be helpful.

The Evaluation tab can be used to compare new genotypes (from different players) with the initial lines.

If you want to organize a real playing session, you need to create as many breeders as there are players or player teams. For this, you need to log in as the "admin" breeder with the "game-master" status. Initially, its password is set to 1234, but this can (and should!) be changed via the tab Admin. This tab also allows a game master to create new breeders and sessions, among other things.

You can modify some key parameters of the game, e.g., effective population size, heritabilities, genetic correlation. For this, you need to edit the setup file plantbreedgame_setup.Rmd, notably by changing the parameters' values in the sections Simulate haplotypes and genotypes and Simulate phenotypes (e.g., subsection Simulation procedure for trait 1).

Nix ā„ļø

This repository uses a "nix flake" and direnv. If you have nix and direnv installed just cd in this repo, enable direnv (direnv allow) and all dependencies will be automatically installed and available in a dedicated environment.

You can then launch the application with:

nix run

To install nix you can visit: https://github.com/DeterminateSystems/nix-installer

Dependencies update

Most of the dependencies (eg. R and its packages) are handled with nix. To update the dependencies just run:

nix flake update

However, playwright (the tool used to test the UI) is handeled by npm but the web browser it uses are handled by nix and we need to use the same version of playwright in the node project as in nix, or else playwright will try to use browsers versions that aren't installed! (cf. nixos wiki).

There is an example of such error:

Test was interrupted.

    Error: browserType.launch: Executable doesn't exist at /nix/store/8hmp47k3dfdw38f82zj7yd7q351pzgh6-playwright-browsers-chromium/chromium-1080/chrome-linux/chrome

To make sure the same version are installed:

    1. Check the nix playwright's version:
    which playwright # to make sure we are targeting nix's playwright
    playwright --version
    1. Specify this version in package.json
    "devDependencies": {
      "@playwright/test": "X.X.X",
    },
    1. Run npm install --ignore-scripts to reinstall npm's playwright

Citation

As the authors invested time and effort in creating this game, please cite the following letter to the editor of Crop Science:

Flutre, T., Diot, J., and David, J. (2019). PlantBreedGame: A Serious Game that Puts Students in the Breederā€™s Seat. Crop Science. DOI 10.2135/cropsci2019.03.0183le

Acknowledgments

Thanks to Philippe Brabant (AgroParisTech) and Jean-Luc Jannink (Cornell) for their feedbacks.

Issues

When encountering a problem with the package, you can report issues on GitHub directly (here).

Contributing

You can contribute in various ways:

  • report an issue (online, see the above section);

  • suggest improvements (in the same way as issues);

  • propose a pull request (after creating a new branch).