Search code examples
raggregate

GHap package in R, ghap.anctrain function-aggregate error


The ghap.anctrain function of GHap package for genomewide haplotype analysis in R shows the following error "Error in aggregate.formula(formula = geno ~ pop, data = dfp, FUN = mean): argument 'x' is missing -- it has been renamed from 'formula'" The error seems to be with the modification in aggregate.formula. Can this be solved? I am using R 4.3.1. The GHap package version is 3.0.0. Thank you for your comments!

I tried to use aggregate function along with ghap.anctrain, but the error keeps coming.


Solution

  • Lazy way to fix this :

    Download the sources of the package :

    https://cran.r-project.org/src/contrib/GHap_3.0.0.tar.gz

    Unzip the package and fix the line 168 in :

    "GHap_3.0.0.tar\GHap_3.0.0\GHap\R\anctrain.R"

    res <- aggregate(formula = geno ~ pop, data = dfp, FUN = mean)
    

    Replace "formula" with "x".

    res <- aggregate(x = geno ~ pop, data = dfp, FUN = mean)
    

    To finish, use source to call the fixed function in your script :

    source("path/to/the/fixed/anctrain.R")