TiagoOlivoto / metan

Package for multi-environment trial analysis
https://tiagoolivoto.github.io/metan/
GNU General Public License v3.0
35 stars 17 forks source link

Problem with ge_stats #16

Closed WheatSopka closed 2 years ago

WheatSopka commented 2 years ago

Hello! The function runs well only with variable GW.

library(openxlsx)
library(metan)
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
#> |=========================================================|
#> | Multi-Environment Trial Analysis (metan) v1.16.0        |
#> | Author: Tiago Olivoto                                   |
#> | Type 'citation('metan')' to know how to cite metan      |
#> | Type 'vignette('metan_start')' for a short tutorial     |
#> | Visit 'https://bit.ly/pkgmetan' for a complete tutorial |
#> |=========================================================|

Data_numeric1 <- read.xlsx("C:/Users/stupk/Documents/R/Example.xlsx", "Lines", colNames = TRUE)

Data_numeric1$YEAR <- as.factor(Data_numeric1$YEAR)
Data_numeric1$GEN <- as.factor(Data_numeric1$GEN)
Data_numeric1$REP <- as.factor(Data_numeric1$REP)

stab_ind <- ge_stats(Data_numeric1, env = YEAR, gen =  GEN,rep =  REP, resp = c(HIGH, BUSH, SAFE,GY))
#> Error in rowSums((gamma.n)^2): 'x' must be a matrix with at least two dimensions

stab_ind <- ge_stats(Data_numeric1, env = YEAR, gen =  GEN,rep =  REP, resp = GW)
#> Evaluating trait GW |============================================| 100% 00:00:05 

Created on 2022-03-15 by the reprex package (v2.0.1)


[Example.xlsx](https://github.com/TiagoOlivoto/metan/files/8249601/Example.xlsx)
TiagoOlivoto commented 2 years ago

Dear @WheatSopka, Since I don't have access to Data_numeric1 I can't figure out what may be happening.

With the example data data_ge the function doesn't return any error. Could you please run inspect(Data_numeric1) and see if any warning is returned?

library(metan)
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
#> |=========================================================|
#> | Multi-Environment Trial Analysis (metan) v1.16.0        |
#> | Author: Tiago Olivoto                                   |
#> | Type 'citation('metan')' to know how to cite metan      |
#> | Type 'vignette('metan_start')' for a short tutorial     |
#> | Visit 'https://bit.ly/pkgmetan' for a complete tutorial |
#> |=========================================================|
inspect(data_ge)
#> # A tibble: 5 x 9
#>   Variable Class   Missing Levels Valid_n   Min Median   Max Outlier
#>   <chr>    <chr>   <chr>   <chr>    <int> <dbl>  <dbl> <dbl>   <dbl>
#> 1 ENV      factor  No      14         420 NA     NA    NA         NA
#> 2 GEN      factor  No      10         420 NA     NA    NA         NA
#> 3 REP      factor  No      3          420 NA     NA    NA         NA
#> 4 GY       numeric No      -          420  0.67   2.61  5.09       0
#> 5 HM       numeric No      -          420 38     48    58          0
#> No issues detected while inspecting data.

model <- 
  ge_stats(data_ge,
           env = ENV,
           gen = GEN,
           rep = REP,
           resp = c(GY, HM))
#> Evaluating trait GY |======================                      | 50% 00:00:10 Evaluating trait HM |============================================| 100% 00:00:20 

Created on 2022-03-23 by the reprex package (v2.0.1)

TiagoOlivoto commented 2 years ago

Since the problems seem to be related to the dataset and no clear and reproducible bug has been reported, I'm closing this now. Please, feel free to reopen if you find it necessary.

nivelive commented 1 year ago
setwd("D:/PhD/Ragi")
library(readxl)
library(metan)
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2
#> |=========================================================|
#> | Multi-Environment Trial Analysis (metan) v1.17.0        |
#> | Author: Tiago Olivoto                                   |
#> | Type 'citation('metan')' to know how to cite metan      |
#> | Type 'vignette('metan_start')' for a short tutorial     |
#> | Visit 'https://bit.ly/pkgmetan' for a complete tutorial |
#> |=========================================================|
Metan_analysis <- read_excel("Metan_analysis.xlsx", 
                             col_types = c("text", "text", "text", 
                                           "numeric", "numeric", "numeric", 
                                           "numeric", "numeric", "numeric", 
                                           "numeric", "numeric", "numeric", 
                                           "numeric"))
View(Metan_analysis)
stab <- ge_stats(Metan_analysis, ENV, GEN, REP)
#> Error in rowSums((gamma.n)^2): 'x' must be an array of at least two dimensions

Created on 2023-02-01 with reprex v2.0.2