gbradburd / conStruct

method for modeling continuous and discrete population genetic structure
35 stars 14 forks source link

Installing covariance_fix issue #39

Closed lesserof2weevils closed 3 years ago

lesserof2weevils commented 3 years ago

Hi,

Having some weird issues with installing the covariance_fix issue with install_github("gbradburd/conStruct", ref="covariance_fix"). When this runs, I'm linked out of R to a CNet article about installing command line tools

I've updated my Xcode command line tools etc through the Mac AppStore. Any ideas?

Screen Shot 2021-03-01 at 8 01 43 pm

Cheers, James

petrelharp commented 3 years ago

Hm. What does pkgbuild::check_build_tools(debug=TRUE) say?

lesserof2weevils commented 3 years ago

It brings up the same error. I can use install_GitHub to install other packages but it just seems to struggle with conStruct

gbradburd commented 3 years ago

When you try devtools::has_devel() what does it say? And/or are you able to install Rstan and run its examples?

lesserof2weevils commented 3 years ago

Same issue with has_devel()

Screen Shot 2021-03-02 at 9 19 51 am

For Rstan running the example ran into an error, so I've reinstalled Rstan and StanHeaders following this: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

However installing Stan ran into this issue:

Screen Shot 2021-03-02 at 9 31 59 am

gbradburd commented 3 years ago

Ok so I suspect this has to do with the update to Mac's OS in Catalina. The issue is not with conStruct specifically, but with rstan (in which conStruct's model is implemented) generally. Have you tried following any of the online threads for installing rstan on Catalina (or beyond)? E.g., here, here, or here? If you can get rstan installed and working, you shouldn't have any issues with conStruct.

lesserof2weevils commented 3 years ago

Thank you for the links, I also came across those threads during some furious googling. I'm now on conStruct v 1.0.5, which I'm assuming has the covariance_fix in it?

gbradburd commented 3 years ago

I didn't iterate the version number after that fix (which, in retrospect, I regret). You can check to see if you have the correct version by trying conStruct:::calc.covariance, which should give this output:

calc.covariance <- function(freqs){
    x <- t(freqs)
    allelic.covariance <- (1 - 1/nrow(freqs)) * stats::cov(x,use="pairwise.complete.obs") - 
                                    (1/2) * outer( colMeans(x,na.rm=TRUE), 1-colMeans(x,na.rm=TRUE), "*" ) -
                                    (1/2) * outer(1-colMeans(x,na.rm=TRUE), colMeans(x,na.rm=TRUE), "*") + 1/4
    diag(allelic.covariance) <- 0.25
    return(allelic.covariance)
}
lesserof2weevils commented 3 years ago

Fantastic, yep, it calls and is all there! Thanks for all the help!