Circuitscape / Circuitscape.jl

Algorithms from circuit theory to predict connectivity in heterogeneous landscapes
https://circuitscape.org
MIT License
128 stars 35 forks source link

Error when calling Circuitscape through another program #151

Closed mjgould closed 6 years ago

mjgould commented 6 years ago

Hi Circuitscape.jl team,

I'm optimization resistance surfaces for my landscape genetics project using the R package "ResistanceGA." This package was originally written to calculate landscape distances using LCP or the original CIRCUITSCAPE. There is a dev version that now incorporates CIRCUITSCAPE in Julia. One of the functions in the pacakges prepares objects needed for running the optimization functions. When I run the following code:

 cs.inputs = jl.prep(n.Pops = length(sample.locales), # spatialPoints object
                      response = lower(gd), # genetic distances
                      CS_Point.File = sample_dir, # sample points for CIRCUITSCAPE
                      cholmod = TRUE,
                      JULIA_HOME = julia_home, # Location of CIRCUITSCAPE
                      parallel = TRUE,
                      cores = 6)

I receive the following error:

[1] "Running test #1: Run Circuitscape from Julia"
Error: Error happens in Julia.
MethodError: no method matching isless(::SubString{String}, ::Int64)
Closest candidates are:
  isless(!Matched::Missings.Missing, ::Any) at C:\Users\mjgould\.julia\v0.6\Missings\src\Missings.jl:74
  isless(!Matched::AbstractFloat, ::Real) at operators.jl:98
  isless(!Matched::Real, ::Real) at operators.jl:266
  ...
Stacktrace:
 [1] <(::SubString{String}, ::Int64) at .\operators.jl:194
 [2] find(::Circuitscape.##48#49, ::Array{Any,1}) at .\array.jl:1516
 [3] read_point_map(::String, ::Circuitscape.RasterMeta) at C:\Users\mjgould\.julia\v0.6\Circuitscape\src\io.jl:206
 [4] load_raster_data(::Type{T} where T, ::Dict{String,String}) at C:\Users\mjgould\.julia\v0.6\Circuitscape\src\io.jl:398
 [5] raster_pairwise(::Type{T} where T, ::Dict{String,String}) at C:\Users\mjgould\.julia\v0.6\Circuitscape\src\raster\pairwise.jl:18
 [6] _compute(::Type{T} where T, ::Dict{String,String}) at C:\Users\mjgould\.julia\v0.6\Circuitscape\src\run.jl:40
 [7] macro expansion at

I researched the error a little bit, and not surprisingly, I didn't find anything directly related. However, I did find a page about the "Missings" and if I understood the description, it says that it's related to missing values in the data. I do have NAs in my raster files. I'm purely guessing, but could this be an issue or is there something else at work?

Thanks for your help!

ranjanan commented 6 years ago

Hi @mjgould thank you for trying the new Circuitscape. I have a feeling that your focal pairs file might be parsed as a string mistakenly. I need to test this out though. Could you please upload an example to a Dropbox or Google Drive link so I can access and test this? Thanks a lot in advance.

mjgould commented 6 years ago

Thanks for your help, @ranjanan. Here's the link: https://drive.google.com/open?id=1HJhw_REuy49GaOjldoitqsXk8WIGBTsk. Let me know when you have access! If the example doesn't work, then I can send you a link to the R project through email.

ranjanan commented 6 years ago

Actually @mjgould would it be possible for you to write these settings in a config file and add it to the drive folder? That would make it significantly easier for me to fix and debug. I think there's something wrong with my R installation.

mjgould commented 6 years ago

Sure, I can get that to you, @ranjanan. I went back to using R 3.4.4 because 3.5.x had a few bugs in it and was incompatible with quite a few packages.

mjgould commented 6 years ago

@ranjanan, So I thought I knew what I was doing but it turns I don't! What would be the best way to construct the config file?

ranjanan commented 6 years ago

Oh that's okay. Could you tell me what Circuitscape mode you're using, what your resistance map is, what your point file is, etc?

mjgould commented 6 years ago

Sure thing. I'm sorry for automatically assuming you know why I was using Circuitscape! Sometimes it's easy to forget that other people aren't focused on your own research, too! I've included a "Read_Me" document in the google drive folder. Let me know if you need more information.

ranjanan commented 6 years ago

Thanks for the explanation @mjgould. Unfortunately, I have not used @wpeterman's ResistanceGA package, but I did notice that the "samples.txt" files had a number of text inputs such as this:

"AZ2011BB104"   -110.864286 31.674388
"AZ2011BB106"   -111.631238 34.709195
"AZ2011BB110"   -110.04988  32.791576
"AZ2011BB111"   -112.436182 34.395821
"AZ2011BB113"   -109.263628 31.766072
"AZ2011BB117"   -109.392286 31.704635
"AZ2011BB118"   -109.84647  32.591373
"AZ2011BB123"   -110.736497 31.82687

Are these supposed to be this way? Most point files I've seen only have numbers in them.

mjgould commented 6 years ago

The first column is the name of the individual bear. The subset data should only have numeric names without quotation marks. Maybe redownload the data files from Google drive just in case I reuploaded the file after you had downloaded the files.

On Tue, Oct 9, 2018, 10:42 PM Ranjan Anantharaman notifications@github.com wrote:

Thanks for the explanation @mjgould https://github.com/mjgould. Unfortunately, I have not used @wpeterman https://github.com/wpeterman's ResistanceGA package, but I did notice that the "samples.txt" files had a number of text inputs such as this:

"AZ2011BB104" -110.864286 31.674388 "AZ2011BB106" -111.631238 34.709195 "AZ2011BB110" -110.04988 32.791576 "AZ2011BB111" -112.436182 34.395821 "AZ2011BB113" -109.263628 31.766072 "AZ2011BB117" -109.392286 31.704635 "AZ2011BB118" -109.84647 32.591373 "AZ2011BB123" -110.736497 31.82687

Are these supposed to be this way? Most point files I've seen only have numbers in them.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Circuitscape/Circuitscape.jl/issues/151#issuecomment-428435884, or mute the thread https://github.com/notifications/unsubscribe-auth/AVj1ctFToulFnMH-VmXR7oIKMdHcM8Qqks5ujXrDgaJpZM4XG6lK .

ranjanan commented 6 years ago

I see. I just saw the updated samples file. Are you getting the exact same error with this sample file? Also, can you try deleting the first row (with lat, long) and try again?

mjgould commented 6 years ago

I have a new error with this sample file that I have included below. In my original data, there are no column headers in the samples file but there are character strings for the names of the individuals.

Error: Error happens in Julia. BoundsError: attempt to access 50×50 Array{Int32,2} at index [-16, -216] Stacktrace: [1] compute_graph_data_no_polygons(::Circuitscape.RasData{Float64,Int32}, ::Circuitscape.RasterFlags) at C:\Users\mjgould.julia\v0.6\Circuitscape\src\raster\pairwise.jl:218

[2] _pt_file_no_polygons_path(::Circuitscape.RasData{Float64,Int32}, ::Circuitscape.RasterFlags, ::Dict{String,String}) at C:\Users\mjgould.julia\v0.6\Circuitscape\src\raster\pairwise.jl:60

[3] raster_pairwise(::Type{T} where T, ::Dict{String,String}) at C:\Users\mjgould.julia\v0.6\Circuitscape\src\raster\pairwise.jl:29

[4] _compute(::Type{T} where T, ::Dict{String,String}) at C:\Users\mjgould.julia\v0.6\Circuitscape\src\run.jl:40

[5] macro expansion at .\util.jl:293 [inlined]

[6] compute(::String) at C:\Users\mjgould.julia\v0.6\Circuitscape\src\run.jl:29

[7] docall(::Ptr{Void}) at C:\Program Files\R\R-3.4.4\library\JuliaCall\julia\setup.jl:157

On Wed, Oct 10, 2018 at 8:29 AM Ranjan Anantharaman < notifications@github.com> wrote:

I see. I just saw the updated samples file. Are you getting the exact same error with this sample file? Also, can you try deleting the first row (with lat, long) and try again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Circuitscape/Circuitscape.jl/issues/151#issuecomment-428594391, or mute the thread https://github.com/notifications/unsubscribe-auth/AVj1cjh__wMxBFcX7M3quuvWMzbay9bwks5ujgQ0gaJpZM4XG6lK .

-- Matthew J. Gould PhD Candidate New Mexico State University

ranjanan commented 6 years ago

Darn. Okay, I think I have to reproduce your setup for this to make any sense. Could you tell me which version of R circ-test.R works on? Can it reproduce the error if I just run the script?

mjgould commented 6 years ago

Shoot, sorry for all the trouble, Ranjan. I'm currently using R version 3.4.4 (2018-03-15) and Rstudio version 1.1.456.

I've uploaded an R project title "Circuitscape_Test" as a zip file to the Google Drive folder. The only directory address you'll have to change is where Circuiscape.jl is located on your computer. Otherwise, you should be able to reproduce the error by running the script.

On Wed, Oct 10, 2018 at 9:07 AM Ranjan Anantharaman < notifications@github.com> wrote:

Darn. Okay, I think I have to reproduce your setup for this to make any sense. Could you tell me which version of R circ-test.R works on? Can it reproduce the error if I just run the script?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Circuitscape/Circuitscape.jl/issues/151#issuecomment-428609420, or mute the thread https://github.com/notifications/unsubscribe-auth/AVj1csrLQwZsKbLdn8AaF4NUnUmEpqdRks5ujg0qgaJpZM4XG6lK .

-- Matthew J. Gould PhD Candidate New Mexico State University

ranjanan commented 6 years ago

@mjgould just an update: I finally managed to reproduce this bug on my system after setting up R and RStudio appropriately. I'll fix this bug by the weekend. Thanks for your patience!

ranjanan commented 6 years ago

@mjgould so I found that there's a problem in the points map. At least one focal node location lies outside the habitat map that you have specified. I've now added a patch (#156) so it should display that error message when you run the R script

ranjanan commented 6 years ago

Do you mind if I use your samples.txt as a test case please?

mjgould commented 6 years ago

Sure thing, Ranjan.

On Fri, Oct 12, 2018 at 9:17 PM Ranjan Anantharaman < notifications@github.com> wrote:

Do you mind if I use your samples.txt as a test case please?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Circuitscape/Circuitscape.jl/issues/151#issuecomment-429506727, or mute the thread https://github.com/notifications/unsubscribe-auth/AVj1cuINbg_ZClm9n9WBMElARIcHTRkkks5ukVs3gaJpZM4XG6lK .

-- Matthew J. Gould PhD Candidate New Mexico State University

ranjanan commented 6 years ago

@mjgould thanks a lot for your patience on this. If you do `Pkg.checkout("Circuitscape"); Pkg.checkout("Circuitscape", "v0.6"), you should be able get this fix. I'm closing this issue for now. Feel free to open a new one if you run into any more issues! :-)

mjgould commented 5 years ago

Hey Ranjan,

Sorry for getting back to you so late. I've been out of the office on some work-related travel and had to pause my research. Thanks for all your help, and once I get back into this bit of research I'll let you know if anything comes up. Once again, thanks for all your help!

On Fri, Oct 19, 2018 at 2:08 PM Ranjan Anantharaman < notifications@github.com> wrote:

@mjgould https://github.com/mjgould thanks a lot for your patience on this. If you do `Pkg.checkout("Circuitscape"); Pkg.checkout("Circuitscape", "v0.6"), you should be able get this fix. I'm closing this issue for now. Feel free to open a new one if you run into any more issues! :-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Circuitscape/Circuitscape.jl/issues/151#issuecomment-431484305, or mute the thread https://github.com/notifications/unsubscribe-auth/AVj1ciifZUd8-xtcW8JOYUS-fthqavHOks5umjFLgaJpZM4XG6lK .

-- Matthew J. Gould PhD Candidate New Mexico State University