Coder Social home page Coder Social logo

tiagoolivoto / metan Goto Github PK

View Code? Open in Web Editor NEW
32.0 1.0 16.0 424.73 MB

Package for multi-environment trial analysis

Home Page: https://tiagoolivoto.github.io/metan/

License: GNU General Public License v3.0

R 96.48% TeX 3.52%
stability ammi ammi-model biplots gge rpgv hmrpgv waasb waas mtsi

metan's Introduction

metan's People

Contributors

bartosz-kozak avatar olivroy avatar tiagoolivoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

metan's Issues

Labels of plot_scores(AMMI_model, type = 2)

Congratulation for developing such a wonderful package.
I think I spotted a type in the labels of plot_scores(AMMI_model, type = 2). Both labels are PC1. I think x-axis label should be PC1 and y-axis label should be PC2.

library(metan)
AMMI_model <- performs_ammi(data_ge,
                            env = ENV,
                            gen = GEN,
                            rep = REP,
                            resp = GY,
                            verbose = FALSE)
plot_scores(AMMI_model, type = 2)

Problem with plot.gge or plot function

Hello, thank you for developing such a great package, I'm running into a problem in the plot function when I run it on the output of gge() function. The issue is lines pointing to the individual genotypes in the graph, I have more than 100 lines, and when I try to plot them, those lines make the figure very messy, the issue was solved in plot_scores for ammi analysis by using the command repel= FALSE but there is no such option in plot() command. Could you please help me with that? I have attached the figure. I have tried changing font size and shape size, but couldn't make these lines go away
Thank you

How to remove outliers in METAN

I found few outliers in my data using find_outlier function of METAN package. How can I remove these outliers?


Brief description of the problem

# insert reprex here

Same code of "metan" running on on one dataset, but not on similar second dataset

Dear Tiago,
Sorry to say that I don't know how to prepare "reprex". But I will be precise.

PROBLEM :-
Same code of "metan" to get MGIDI is running on one dataset (df.xlsx, attached) , but not on similar second dataset (df2.xlsx, attached).
The code I used is pasted here. It generates following message after line "$$$" in code is run. :::

"Error in cor(means, use = use) : no complete element pairs
In addition: Warning message:
Missing values observed in the table of means. Using complete observations to compute the correlation matrix. "

CODE :-

getwd()
setwd("C:/Users/hp/Desktop/MGIDI")
library(metan)
library(tidyverse)
library(tidyr)
library(dplyr)
library(rio)
df <- import("df2.xlsx", sheet=1)
str(df)
df <- df %>% mutate(across(where(is_character),as_factor))
str(df)
mod <-
gamem(df,
gen = GEN,
rep = REP,
resp = c('T1', 'T2','T3','T4','T5','T6','T7'),
verbose = F)
print(mod)
gmd(mod, "blupg")

$$$ mgidi_ind <- mgidi(mod, mineval=1,SI=33,ideotype = c("h, h, h, h, h, h, h"))
gmd(mgidi_ind, "MGIDI")

p1 <- plot(mgidi_ind, type = "contribution" )
p2 <- plot(mgidi_ind, SI=33,type = "index", title = "MGIDI for Control")
p2 + p1

DATA FILES ATTACHED::-

df.xlsx
df2.xlsx

Hope you will consider my limitation and help.

Regards.

Mislabeling of ENV and GEN in Which Won Where Biplot

have you an issue?

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.


using my own data set, I noticed a mislabeling of the ENV and GEN factors in the legend of the Which Won Where Biplot.

# insert reprex here
![image](https://user-images.githubusercontent.com/44632920/80032668-08e2b180-84db-11ea-94be-e53080ab45ef.png)

Hello

have you an issue?

Hello Tiago, I think your package "metan" is really good!!!. I am doing the short tutorial (https://tiagoolivoto.github.io/metan/) with my own data (csv file called "metan", I attach the file). Nevertheless, I have an issue in the BLUP model:
model2 <- waasb(data_ge,
env = ENV,
gen = GEN,
rep = REP,
resp = everything())
R gives me this:

Convergence information

Number of iterations: 144
Final RMSE: 9.961795e-11
Number of axis: 1
Convergence: TRUE

Error in s$u[, 1:minimo] : subscript out of bounds
In addition: Warning messages:
1: Expected 2 pieces. Additional pieces discarded in 48 rows [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, ...].
2: Data imputation used to fill the GxE matrix

Could you help me?.
Thank you in advance,
Adelina.

[metan.xlsx](https://github.com/TiagoOlivoto/metan/files/4451456/metan.xlsx)_

AMMI Analysis

I make my AMMI analysis with metan but the results don´t coincide with agricolae and with the program in SAS. The PC are negative when should be positive and vice versa.

I don´t know what is happening, could be my mistake on the code?

Grettings, i hope your answer.

problem in running your example code

have you an issue?

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.


See the codes and error message:

gmd(MTSI_index2, "FA") %>% print_table()
Error in get_model_data(x, what, type, verbose) :
Invalid class in object x. See ?get_model_data for more information.

# insert reprex here

Inclusion of covariate to dependent trait while calculating BLUP values

I want to include Anthesis silking interval (ASI) as a covariate to grain yield while calculating BLUP values and plotting them.
gamem_met(Data, env = Loc_Code,
gen = ENTRY, rep = REP,
block = BLOCK, random= "gen", prob = 0.05, resp = "Grain Yield", verbose = TRUE)
How to include covariate ASI in this code

Problem with ge_stats

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)

error while analysis path analysis

pcoeff <- path_coeff_mat(cor_mat, resp = TGW)

Error in solve.default(cor.x, cor.y) :
system is computationally singular: reciprocal condition number = 8.72837e-18

MGIDI selection differential is false if averaged data is negative

Hi,

First, thanks a lot for the package and especially for MGIDI algorithm.
I applied mgidi function both on blup data, with trait values being centered on 0 for the whole population. Hence, I have negative values for the traits. When I output the sel_dif table, I find for some traits negative values in the column SDperc, despite a positive selection differential.
As an example, this is my sel_dif table:
image

Every time Xo (average value of the trait for the whole population) is negative, the resulting SDperc has the wrong sign.

The explanation is in the code of the MGIDI function L.302.
I think it would be more correct to use the absolute value for Xo in the denominator.

Thanks again,

Charlotte

rep and block arguments for gge

I think gge must have arguments rep and block similar to anova_ind(), anova_joint(), performs_ammi(), waas() and waasb(), to analyze data from trials conducted in an alpha-lattice design.

print_table(.) : could not find function "print_table"

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.

Brief description of the problem

#Each time i use the print_table I get: "Error in print_table(.) : could not find function "print_table"

gen_mod <- gamem(data_g, GEN, REP,
                 resp = c(ED, CL, CD, KW, TKW, NKR))
get_model_data(gen_mod, "blupg") %>% print_table()

Release metan 1.16.0

Prepare for release:

  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Error in corr_coef(data, ..., type = c("linear", "partial"), method = c("pearson", : could not find function "corr_coef"

Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.

Brief description of the problem

# insert reprex here

error when I run ge_stat() code of metan package

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

Shukla Stablility with wrong length of levels

Hi,
when calculating shukla stability using the Shukla() function, I ran into a problem where the results change depending on the subset of my data. I'm not sure if it's desired to take the initial number of levels from the data frame, as in line 55 with as.factor(), or if there's something wrong with using factor() instead to solve this problem?

mutate(across(everything(), as.factor))

Here is a reproducible example with the provided sample data:

out1 <- Shukla(data_ge2[data_ge2$ENV != "A1", ], #subsetting one environment
              env = ENV,
              gen = GEN,
              rep = REP,
              resp = PH)

data_ge3 <- data_ge2[data_ge2$ENV != "A1", ] #subsetting the same environment
data_ge3$ENV <- factor(data_ge3$ENV) #but relevel the factor

out2 <- Shukla(data_ge3,
               env = ENV,
               gen = GEN,
               rep = REP,
               resp = PH)
print(out1)
print(out2)

And here the results:

> print(out1)
Variable PH 
---------------------------------------------------------------------------
Shukla stability variance
---------------------------------------------------------------------------
# A tibble: 13 × 6
   GEN       Y ShuklaVar rMean rShukaVar ssiShukaVar
   <fct> <dbl>     <dbl> <dbl>     <dbl>       <dbl>
 1 H1     2.59  0.0383       1         7           8
 2 H10    2.16  0.0172      13         3          16
 3 H11    2.27  0.0230      10         4          14
 4 H12    2.35  0.0760       8        11          19
 5 H13    2.46  0.0845       7        13          20
 6 H2     2.54  0.0586       2         9          11
 7 H3     2.48  0.0820       5        12          17
 8 H4     2.48  0.0479       4         8          12
 9 H5     2.48  0.0159       6         2           8
10 H6     2.49  0.0352       3         6           9
11 H7     2.28  0.0258       9         5          14
12 H8     2.20  0.0607      11        10          21
13 H9     2.18 -0.000876    12         1          13

> print(out2)
Variable PH 
---------------------------------------------------------------------------
Shukla stability variance
---------------------------------------------------------------------------
# A tibble: 13 × 6
   GEN       Y ShuklaVar rMean rShukaVar ssiShukaVar
   <fct> <dbl>     <dbl> <dbl>     <dbl>       <dbl>
 1 H1     2.59   0.0574      1         7           8
 2 H10    2.16   0.0258     13         3          16
 3 H11    2.27   0.0345     10         4          14
 4 H12    2.35   0.114       8        11          19
 5 H13    2.46   0.127       7        13          20
 6 H2     2.54   0.0880      2         9          11
 7 H3     2.48   0.123       5        12          17
 8 H4     2.48   0.0719      4         8          12
 9 H5     2.48   0.0238      6         2           8
10 H6     2.49   0.0528      3         6           9
11 H7     2.28   0.0387      9         5          14
12 H8     2.20   0.0910     11        10          21
13 H9     2.18  -0.00131    12         1          13

Inclusion of covariate to dependent trait while calculating BLUP values

I want to include Anthesis silking interval (ASI) as a covariate to grain yield while calculating BLUP values and plotting them.
gamem_met(Data, env = Loc_Code,
gen = ENTRY, rep = REP,
block = BLOCK, random= "gen", prob = 0.05, resp = "Grain Yield", verbose = TRUE)
How to include covariate ASI in this code

metan temporarily out of CRAN

I apologize for the inconvenience, but, metan has been removed from CRAN temporally because a check problem not fixed in time. Formerly available versions can be obtained from the archive.

A new patch release that fixes the problem was just submitted and is awaiting a manual inspection by a CRAN's team member.

You can download the latest version (v1.5.1) of metan from Gighub with

devtools::install_github("TiagoOlivoto/metan")

Inconsistency with cv_blup function

Hi,

I am testing a sample dataset that has the same format as the oat dataset as demonstrated. This was a RCBD design with 3 replicates

str(dataset)
'data.frame': 791 obs. of 4 variables:
$ ENV : Factor w/ 13 levels "2017_P","2017_S",..: 10 10 10 10 10 10 10 10 10 10 ...
$ GEN : Factor w/ 30 levels "8xp","XR_A0",..: 23 24 30 2 10 26 11 3 12 27 ...
$ BLOCK: int 1 1 1 1 1 1 1 1 1 1 ...
$ GY : num 233 225 248 259 255 ...

When I use cv_blup, I get the following error message:

BLUP_model = cv_blup(dataset,
resp = GY,
gen = GEN,
env = ENV,
rep = BLOCK,
nboot = 200,
random="gen")

Error: Column error must be length 262 (the number of rows) or one, not 264
In addition: Warning message:
In pred - testing$Y :
longer object length is not a multiple of shorter object length

When I rerun it the command multiple times without changing anything else, the first line of the error message changes each time. For example:
Error: Column error must be length 261 (the number of rows) or one, not 265
Error: Column error must be length 262 (the number of rows) or one, not 266
Error: Column error must be length 262 (the number of rows) or one, not 263
Error: Column error must be length 262 (the number of rows) or one, not 266
Error: Column error must be length 262 (the number of rows) or one, not 265
Error: Column error must be length 261 (the number of rows) or one, not 267
Error: Column error must be length 262 (the number of rows) or one, not 265

Do you know what is happening here?

Thanks!

Custom names of function arguments do not work

Some functions argument do not take custom names as given in the following example

library(metan)
data("data_ge")
data_ge
# A tibble: 420 x 5
   ENV   GEN   REP      GY    HM
   <fct> <fct> <fct> <dbl> <dbl>
 1 E1    G1    1      2.17  44.9
 2 E1    G1    2      2.50  46.9
 3 E1    G1    3      2.43  47.8
 4 E1    G2    1      3.21  45.2
 5 E1    G2    2      2.93  45.3
 6 E1    G2    3      2.56  45.5
 7 E1    G3    1      2.77  46.7
 8 E1    G3    2      3.62  43.2
 9 E1    G3    3      2.28  47.8
10 E1    G4    1      2.36  47.9
# … with 410 more rows
> 
> anova_joint(
+     .data   = data_ge
+   , env     = ENV
+   , gen     = GEN
+   , rep     = REP
+   , resp    = GY
+   )
variable GY 
---------------------------------------------------------------------------
Joint ANOVA table
---------------------------------------------------------------------------
    Source     Df Sum Sq Mean Sq F value   Pr(>F)
       ENV  13.00 279.57 21.5057   62.33 0.00e+00
  REP(ENV)  28.00   9.66  0.3451    3.57 3.59e-08
       GEN   9.00  13.00  1.4439   14.93 2.19e-19
   GEN:ENV 117.00  31.22  0.2668    2.76 1.01e-11
 Residuals 252.00  24.37  0.0967      NA       NA
     CV(%)  11.63     NA      NA      NA       NA
 MSR+/MSR-   6.71     NA      NA      NA       NA
    OVmean   2.67     NA      NA      NA       NA
---------------------------------------------------------------------------

All variables with significant (p < 0.05) genotype-vs-environment interaction
Done!
Variable GY 
---------------------------------------------------------------------------
$anova
     Source         Df     Sum Sq     Mean Sq   F value
1       ENV  13.000000 279.573552 21.50565785 62.325457
2  REP(ENV)  28.000000   9.661516  0.34505416  3.568548
3       GEN   9.000000  12.995044  1.44389374 14.932741
4   GEN:ENV 117.000000  31.219565  0.26683389  2.759595
5 Residuals 252.000000  24.366674  0.09669315        NA
6     CV(%)  11.627790         NA          NA        NA
7 MSR+/MSR-   6.708789         NA          NA        NA
8    OVmean   2.674242         NA          NA        NA
        Pr(>F)
1 0.000000e+00
2 3.593191e-08
3 2.190118e-19
4 1.005191e-11
5           NA
6           NA
7           NA
8           NA

$model
Call:
   aov(formula = mean ~ GEN + ENV + GEN:ENV + ENV/REP, data = data)

Terms:
                      GEN       ENV   GEN:ENV   ENV:REP
Sum of Squares   12.99504 279.57355  31.21956   9.66152
Deg. of Freedom         9        13       117        28
                Residuals
Sum of Squares   24.36667
Deg. of Freedom       252

Residual standard error: 0.3109552
Estimated effects may be unbalanced

$augment
# A tibble: 420 x 11
   ENV   GEN   REP    mean   hat sigma fitted    resid
   <fct> <fct> <fct> <dbl> <dbl> <dbl>  <dbl>    <dbl>
 1 E1    G1    1      2.17 0.4   0.311   2.42 -0.255  
 2 E1    G1    2      2.50 0.400 0.311   2.40  0.101  
 3 E1    G1    3      2.43 0.4   0.311   2.27  0.154  
 4 E1    G2    1      3.21 0.400 0.311   2.96  0.249  
 5 E1    G2    2      2.93 0.400 0.312   2.94 -0.00492
 6 E1    G2    3      2.56 0.400 0.311   2.81 -0.244  
 7 E1    G3    1      2.77 0.4   0.311   2.95 -0.176  
 8 E1    G3    2      3.62 0.400 0.306   2.92  0.696  
 9 E1    G3    3      2.28 0.4   0.309   2.80 -0.521  
10 E1    G4    1      2.36 0.4   0.311   2.65 -0.286  
# … with 410 more rows, and 3 more variables: stdres <dbl>,
#   se.fit <dbl>, factors <chr>

$details
# A tibble: 10 x 2
   Parameters mean               
   <chr>      <chr>              
 1 Mean       "2.67"             
 2 SE         "NA"               
 3 SD         "NA"               
 4 CV         "NA"               
 5 Min        "0.67 (G10 in E11)"
 6 Max        "5.09 (G8 in E5)"  
 7 MinENV     "E11 (1.37)"       
 8 MaxENV     "E3 (4.06)"        
 9 MinGEN     "G10 (2.47) "      
10 MaxGEN     "G8 (3) "          

---------------------------------------------------------------------------



> 
> library(tidyverse)
> tb1 <-
+   data_ge %>% 
+   mutate(
+       Env     = ENV
+     , Gen     = GEN
+     , Rep     = REP
+   ) %>% 
+   select(Env, Gen, Rep, GY)
> 
> tb1
# A tibble: 420 x 4
   Env   Gen   Rep      GY
   <fct> <fct> <fct> <dbl>
 1 E1    G1    1      2.17
 2 E1    G1    2      2.50
 3 E1    G1    3      2.43
 4 E1    G2    1      3.21
 5 E1    G2    2      2.93
 6 E1    G2    3      2.56
 7 E1    G3    1      2.77
 8 E1    G3    2      3.62
 9 E1    G3    3      2.28
10 E1    G4    1      2.36
# … with 410 more rows
> 
> anova_joint(
+    .data   = tb1
+   , env     = Env
+   , gen     = Gen
+   , rep     = Rep
+   , resp    = GY
+ )
Error: Can't subset columns that don't exist.
x The columns `ENV`, `GEN`, and `REP` don't exist.
Run `rlang::last_error()` to see where the error occurred.
 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.