Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: MethodError: no method matching zero(::Type{Any}) when fitting multivariate Bayesian genomic regression #64

Closed
markcharder opened this issue Apr 15, 2020 · 8 comments

Comments

@markcharder
Copy link

I am hoping to fit a multiple trait Bayesian genomic prediction model using the JWAS package. I've managed to run the tutorials without any issues. However, when I apply the model to my own data, I get an error message. I've checked and re-checked the format of the data, which, as far as I can tell, is fine. In fact, the analysis will run for a single trait model but only throws the error for a multi-trait model.

Here is a snippet of some preliminary code that I ran recently:

using JWAS, CSV, DataFrames
phenotypes = CSV.read("phenotypes_filtered-jwas.csv", delim=",", header=true)
model_equation = "y3 = intercept + ID
                  y2 = intercept + ID"
model = build_model(model_equation)
add_genotypes(model,"genotypes_filtered-jwas.csv", separator=',', header=true)
out=runMCMC(model,phenotypes,methods="BayesC",output_samples_frequency=100, estimatePi=true)

This is what the phenotypes file looks like:

218×4 DataFrame
│ Row │ ID     │ y1      │ y2      │ y3      │
│     │ String │ Float64 │ Float64 │ Float64 │
├─────┼────────┼─────────┼─────────┼─────────┤
│ 1   │ a53    │ 387.20311.16671127.78 │
│ 2   │ a48    │ 1832.5812.66671814.44 │
│ 3   │ a54    │ 1329.9812.01641.95 │
│ 4   │ a49    │ 1095.5713.41352.56 │
│ 5   │ a57    │ 1896.08.833332248.22 │
│ 6   │ a58    │ 2461.0613.66672436.69 │
│ 7   │ a52    │ 1852.9413.61834.59 │
│ 8   │ a55    │ 393.05513.01144.82 │
│ 9   │ a50    │ 1328.0517.51314.9  │
│ 10  │ a59    │ 1635.0314.33331618.84 │
│ 11  │ a51    │ 1334.6418.16671321.43 │
│ 12  │ a60    │ 592.38211.83331725.38 │
│ 13  │ a39    │ 1559.6614.81544.21 │
│ 14  │ a44    │ 1277.0210.33331887.23 │
│ 15  │ a29    │ 780.16516.1667925.097203 │ a126   │ 995.95713.01180.98 │
│ 204 │ a211   │ 1052.8615.01299.83 │
│ 205 │ a125   │ 704.75412.83331381.87 │
│ 206 │ a113   │ 2502.717.666672477.93 │
│ 207 │ a120   │ 1288.713.51528.1  │
│ 208 │ a228   │ 3603.537.833333567.85 │
│ 209 │ a135   │ 2205.7714.83332615.53 │
│ 210 │ a129   │ 1293.4212.51911.46 │
│ 211 │ a132   │ 132.95716.0633.127 │
│ 212 │ a140   │ 598.3812.6667884.306 │
│ 213 │ a155   │ 527.88817.33331035.07 │
│ 214 │ a156   │ 388.52518.1667761.813 │
│ 215 │ a177   │ 2365.0119.83332341.59 │
│ 216 │ a190   │ 107.56517.6667313.297 │
│ 217 │ a210   │ 1107.3310.51636.44 │
│ 218 │ a246   │ 1785.4617.21767.78

This is what the genotypes file looks like:

218×13366 DataFrame. Omitted printing of 13346 columns
│ Row │ ID     │ m1    │ m2    │ m3    │ m4    │ m5    │ m6    │ m7    │ m8    │ m9    │ m10   │ m11   │ m12   │ m13   │ m14   │ m15   │ m16   │ m17   │ m18   │ m19   │
│     │ String │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │ Int64 │
├─────┼────────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤
│ 1   │ a53    │ 2211110201111110220     │
│ 2   │ a48    │ 2212200200122000220     │
│ 3   │ a54    │ 2212200200222000220     │
│ 4   │ a49    │ 2212200200122000220     │
│ 5   │ a57    │ 2212200200222000220     │
│ 6   │ a58    │ 2212200200122000220     │
│ 7   │ a52    │ 2212200222002000220     │
│ 8   │ a55    │ 2212200200200000220     │
│ 9   │ a50    │ 2212200200222000220     │
│ 10  │ a59    │ 2211110202001220220     │
│ 11  │ a51    │ 2210020202000220220     │
│ 12  │ a60    │ 2212200202001220220     │
│ 13  │ a39    │ 2220020202000220220     │
│ 14  │ a44    │ 2212220220222220220     │
│ 15  │ a29    │ 2212200220201000222203 │ a126   │ 2212202222220221022     │
│ 204 │ a211   │ 0222000222202222020     │
│ 205 │ a125   │ 2222220222002222022     │
│ 206 │ a113   │ 2020220222002020020     │
│ 207 │ a120   │ 2202020220222200222     │
│ 208 │ a228   │ 2222022220222220220     │
│ 209 │ a135   │ 2202200200222000220     │
│ 210 │ a129   │ 1101201211112111111     │
│ 211 │ a132   │ 2022021000221222220     │
│ 212 │ a140   │ 2202220220222220222     │
│ 213 │ a155   │ 2220020202001220220     │
│ 214 │ a156   │ 2202200200222000220     │
│ 215 │ a177   │ 2022022000220222220     │
│ 216 │ a190   │ 2022021000221222220     │
│ 217 │ a210   │ 2202201222002222012     │
│ 218 │ a246   │ 2202200200222000220

The error message that I get from running this model is as follows:

ERROR: MethodError: no method matching zero(::Type{Any})
Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T at missing.jl:105
  zero(::Type{Missing}) at missing.jl:103
  zero(::Type{LibGit2.GitHash}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LibGit2/src/oid.jl:220
  ...
Stacktrace:
 [1] zero(::Type{Any}) at ./missing.jl:105
 [2] _spgetindex at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/SparseArrays/src/sparsevector.jl:777 [inlined]
 [3] getindex at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/SparseArrays/src/sparsevector.jl:782 [inlined]
 [4] dot(::SparseArrays.SparseVector{Any,Int64}, ::Array{Float32,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/generic.jl:896
 [5] * at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/adjtrans.jl:245 [inlined]
 [6] Gibbs(::SparseArrays.SparseMatrixCSC{Any,Int64}, ::Array{Float32,1}, ::SparseArrays.SparseMatrixCSC{Any,Int64}) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/buildMME/solver.jl:151
 [7] macro expansion at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/MCMC/MT_MCMC_BayesianAlphabet.jl:143 [inlined]
 [8] macro expansion at /home/mark/.julia/packages/ProgressMeter/g1lse/src/ProgressMeter.jl:717 [inlined]
 [9] MT_MCMC_BayesianAlphabet(::Int64, ::JWAS.MME, ::DataFrame; Rinv::Array{Float32,1}, burnin::Int64, Pi::Dict{Array{Float64,1},Float64}, estimatePi::Bool, estimate_variance::Bool, estimateScale::Bool, sol::Array{Float32,1}, outFreq::Int64, output_samples_frequency::Int64, methods::String, missing_phenotypes::Bool, constraint::Bool, update_priors_frequency::Int64, output_file::String, causal_structure::Bool) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/MCMC/MT_MCMC_BayesianAlphabet.jl:139
 [10] runMCMC(::JWAS.MME, ::DataFrame; heterogeneous_residuals::Bool, chain_length::Int64, starting_value::Bool, burnin::Int64, output_samples_frequency::Int64, update_priors_frequency::Int64, methods::String, estimate_variance::Bool, Pi::Float64, estimatePi::Bool, estimateScale::Bool, single_step_analysis::Bool, pedigree::Bool, categorical_trait::Bool, missing_phenotypes::Bool, constraint::Bool, causal_structure::Bool, outputEBV::Bool, output_heritability::Bool, seed::Bool, printout_model_info::Bool, printout_frequency::Int64, big_memory::Bool, double_precision::Bool, output_samples_file::String, output_samples_for_all_parameters::Bool) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/JWAS.jl:286
 [11] top-level scope at REPL[11]:1

I would really appreciate if anybody can figure out what the issue might be. Sorry for such a long message.

Mark

@markcharder
Copy link
Author

Just a quick update to this issue. I've found that when I run the example multivariate model found here), I stumble upon the same issue. For example:

using JWAS,JWAS.Datasets,DataFrames,CSV

phenofile  = Datasets.dataset("example","phenotypes.txt")
pedfile    = Datasets.dataset("example","pedigree.txt")
genofile   = Datasets.dataset("example","genotypes.txt")

phenotypes = CSV.read(phenofile,delim = ',',header=true,missingstrings=["NA"])
pedigree   = get_pedigree(pedfile,separator=",",header=true);



model_equation2 ="y1 = intercept + x1 + x3 + ID + dam
                  y2 = intercept + x1 + x2 + x3 + ID
                  y3 = intercept + x1 + x1*x3 + x2 + ID";

model2 = build_model(model_equation2);

set_covariate(model2,"x1");

set_random(model2,"x2");
set_random(model2,"ID dam",pedigree);

add_genotypes(model2,genofile,separator=',');

out2=runMCMC(model2,phenotypes,methods="BayesC",estimatePi=true);

This produces the same error:

ERROR: MethodError: no method matching zero(::Type{Any})
Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T at missing.jl:105
  zero(::Type{Missing}) at missing.jl:103
  zero(::Type{LibGit2.GitHash}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LibGit2/src/oid.jl:220
  ...
Stacktrace:
 [1] zero(::Type{Any}) at ./missing.jl:105
 [2] _zeros_eltypes at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:204 [inlined]
 [3] _noshapecheck_map(::typeof(+), ::SparseArrays.SparseMatrixCSC{Any,Int64}, ::SparseArrays.SparseMatrixCSC{Float64,Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:159
 [4] map(::typeof(+), ::SparseArrays.SparseMatrixCSC{Any,Int64}, ::SparseArrays.SparseMatrixCSC{Float64,Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:1153
 [5] +(::SparseArrays.SparseMatrixCSC{Any,Int64}, ::SparseArrays.SparseMatrixCSC{Float64,Int64}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/SparseArrays/src/sparsematrix.jl:1648
 [6] addVinv(::JWAS.MME) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/buildMME/random_effects.jl:209
 [7] getMME(::JWAS.MME, ::DataFrame) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/buildMME/build_MME.jl:261
 [8] init_mixed_model_equations(::JWAS.MME, ::DataFrame, ::Bool) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/JWAS.jl:581
 [9] runMCMC(::JWAS.MME, ::DataFrame; heterogeneous_residuals::Bool, chain_length::Int64, starting_value::Bool, burnin::Int64, output_samples_frequency::Int64, update_priors_frequency::Int64, methods::String, estimate_variance::Bool, Pi::Float64, estimatePi::Bool, estimateScale::Bool, single_step_analysis::Bool, pedigree::Bool, categorical_trait::Bool, missing_phenotypes::Bool, constraint::Bool, causal_structure::Bool, outputEBV::Bool, output_heritability::Bool, seed::Bool, printout_model_info::Bool, printout_frequency::Int64, big_memory::Bool, double_precision::Bool, output_samples_file::String, output_samples_for_all_parameters::Bool) at /home/mark/.julia/packages/JWAS/4xynz/src/1.JWAS/src/JWAS.jl:252
 [10] top-level scope at REPL[19]:1

@fmorgante
Copy link

I get the same error with Julia 1.4.1, but it works as expected with Julia 1.1.1.

@rohanLuigi
Copy link
Contributor

I ran this example successfully with Julia 1.3.1

@reworkhow reworkhow reopened this Apr 28, 2020
@reworkhow
Copy link
Owner

@markcharder @fmorgante Thanks for letting me know. There was a bug with Julia 1.4. I have released JWAS 0.8.4. It should work in Julia1.4 now.

More details about the bug can be found here.
#59

@fmorgante
Copy link

@reworkhow thank you for fixing this! I also noticed that when setting center=false in add_genotypes() I get the following error (using the multivariate example above):

julia> add_genotypes(model2,genofile,separator=',', center=false);
The delimiter in genotypes.txt is ','.
The header (marker IDs) is provided in genotypes.txt.
ERROR: MethodError: objects of type Bool are not callable
Stacktrace:
 [1] #readgenotypes#52(::Char, ::Bool, ::Bool, ::Function, ::String) at /home/fmorgante/.julia/packages/JWAS/fZ8iA/src/1.JWAS/src/markers/readgenotypes.jl:108
 [2] #readgenotypes at /home/fmorgante/.julia/packages/JWAS/fZ8iA/src/1.JWAS/src/markers/readgenotypes.jl:0 [inlined]
 [3] #add_genotypes#51(::Char, ::Bool, ::Bool, ::Bool, ::Int64, ::Function, ::JWAS.MME, ::String, ::Bool) at /home/fmorgante/.julia/packages/JWAS/fZ8iA/src/1.JWAS/src/markers/readgenotypes.jl:61
 [4] #add_genotypes at ./none:0 [inlined] (repeats 2 times)
 [5] top-level scope at none:0

At the moment, I am on Julia 1.1.1.

Do you have any idea why?

@reworkhow
Copy link
Owner

reworkhow commented May 1, 2020

@fmorgante Can you update your JWAS now to the latest version to try?

@fmorgante
Copy link

@reworkhow It works now, thanks!

@markcharder
Copy link
Author

Just a note to say thank you to the developers and I am greatly looking forward to trying out the software again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants