-
-
Save juanchiem/68da029c181d310596ba5e81e2909e47 to your computer and use it in GitHub Desktop.
find genotypes that are repeatead in selected environments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pacman::p_load(tidyverse) | |
# Fake data | |
full_grid <- expand_grid( | |
gen = paste0("G", 1:3), | |
loc = paste0("L", 1:3), | |
season = paste0("S", 1:4) | |
) %>% | |
mutate(env = paste(loc, season)) | |
replications(~ gen * env, full_grid) | |
# Generate inbalance | |
red_grid <- sample_frac(full_grid, size = 0.8) | |
replications(~ gen * env, red_grid) | |
# Get available seasons | |
seasons <- red_grid %>% | |
distinct(season) %>% | |
pull %>% | |
sort | |
seasons | |
# Get last Nth seasons | |
last_nseasons <- tail(seasons, 1) | |
last_nseasons | |
# Get distinct environments within selected seasons | |
envs <- red_grid %>% | |
filter(season %in% last_nseasons) %>% | |
distinct(env) %>% | |
pull | |
envs | |
# Get genotypes that were present in all of those the environments | |
red_grid %>% | |
filter(env %in% envs) %>% | |
count(gen) %>% | |
filter(n == n_distinct(envs)) %>% | |
distinct(gen) %>% | |
pull |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment