Skip to contents

Join predictor and heritability (h2) data objects to one dataframe

Usage

join_by_keys(x, y)

Arguments

x

first data object either predictors or h2

y

second data object

Value

a dataframe

Examples

f <- system.file("uon-trial-1.csv", package = "pbwrangler")
df <- read_workbooks(dir = NULL, file_to_read = f) %>%
  purrr::map(
    ., ~dplyr::mutate(
      ., year = "2024", loc = "UON", trial = "lbht"
    )
  )
#> Rows: 108 Columns: 32
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr  (8): unique, geno, flowering_date, flower_colour, flesh_colour, skin_co...
#> dbl (24): plot, entry, row, col, rep, ntp, npe, growth_speed, pgh, plant_uni...
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
df_out <- pre_process_trials(df) |> process_trials() %>%
  purrr::map(., run_data_processes) %>% `[[`(1) 
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Warning: NAs introduced by coercion
#> Joining with `by = join_by(old_family_code)`
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "flesh_colour", "skin_colour", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "flesh_colour", "skin_colour", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "flesh_colour", "skin_colour", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
#> Warning: Rows with out of scale values replaced with NA for variable nmtp: 54 
#> Warning: Rows with extreme values replaced with NA for variable atmw: 54 
#> Warning: Rows with extreme values replaced with NA for variable mtwp: 54 
#> Warning: Rows with extreme values replaced with NA for variable mtyna: 54 
#> Warning: pt crop detected
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
#> Warning: Some variables have been overwritten: c("atmw", "ppe", "mtyna")
#> Warning: pt crop detected
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
#> Warning: Rows with out of scale values replaced with NA for variable tbfsh1: 1 2 3 4 5 6 19 20 21 22 23 24 37 38 39 40 41 42 55 56 57 58 59 60 73 74 75 76 77 78 91 92 93 94 95 96 
#> Warning: Rows with out of scale values replaced with NA for variable tbskn1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 
#> Warning: pt crop detected
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
#> Warning: Some variables have been overwritten: c("atmw", "ppe", "mtyna")
#> Warning: pt crop detected
#> Warning: Some columns with invalid names: c("unique", "entry", "growth_speed", "flowering_date", "flower_colour", "overall_impression", "late_blight_60_days", "obs", "photo", "trial", "n_tubers")
# trial design object
TD <- create_td(df_out, design = "rowcol")
# fit 
fit_TD <- fit_td(TD, trait = "mtwp")
#> Using SpATS for fitting models.
# extract predictions

pred_TD <- extract_blups(fit_TD, pred = c("BLUEs", "seBLUEs"))

pred_TD[[1]][1:5,]
#>         genotype trial BLUEs_mtwp seBLUEs_mtwp
#> 1  CIP312084.731  lbht  10.377484     1.156141
#> 2 CIP3177011.028  lbht   9.831602     1.155003
#> 3 CIP3177023.046  lbht   6.642917     1.190464
#> 4 CIP3177038.001  lbht   4.890195     1.163434
#> 5 CIP3187009.044  lbht  13.939097     1.160588