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

calRaster output not working with pdRaster #42

Open
salinedi0n opened this issue Oct 23, 2024 · 6 comments
Open

calRaster output not working with pdRaster #42

salinedi0n opened this issue Oct 23, 2024 · 6 comments

Comments

@salinedi0n
Copy link

Hello,

I'm a grad student using your package and am very grateful for it! Thank you!

I was wondering if you have experienced issues like this before -- the output of the calRaster function is not working with the pdRaster function.

I have an isoscape (with both the d2h values and standard error) together in the RasterBrick object "c200_both". The file with my known origin samples is "ultra_known_origins".

I can run the following fine:

calibrated <- calRaster(known = ultra_known_origins, isoscape = c200_both, interpMethod = 1, genplot = FALSE, verboseLM = TRUE)

It returns the object "calibrated" as type rescale and list of 3.

When I run:

unknowns_prob = pdRaster(calibrated, as.data.frame(Feather_d2h_for_R))

All I get back is "NULL".

Sometimes when I run the calRaster function, I get a warning that the function will make the object no longer an s4 object.

Do you know what I'm doing wrong?

Thank you for your time!

@bumbanian
Copy link
Collaborator

Hard to say for sure w/o a reproducible example that I can run, but my hunch is that it could be related to using a RasterBrick as input to calRaster. assignR transitioned away from the depreciated raster package a few versions back and although we're trying to continue to provide backwards compatibility you should use terra spatial objects for best performance and stability.

You could try:

c200_terra = rast(c200_both)

and then use the result as your isoscape input to calRaster. If that doesn't work please provide example data that I can use to reproduce the problem.

-Gabe

@salinedi0n
Copy link
Author

salinedi0n commented Oct 24, 2024 via email

@bumbanian
Copy link
Collaborator

bumbanian commented Oct 24, 2024 via email

@salinedi0n
Copy link
Author

The page didn't support the file types for creating the shapefiles, so I've invited you to a private repository where you can access the materials.

@bumbanian
Copy link
Collaborator

Carlie - Thanks, that made it easy to troubleshoot. I created a branch in your repo and pushed an update to your script that demonstrates the problem.

You're trying to run calRaster using a known origin dataset that appears to include individuals from only one location. calRaster fits a linear model relating the known origin sample values to the environmental isoscape values. The model can't be fit without at least two 'points' (known origin data from at least two locations...ideally many more). It looks like we haven't protected against this, I'll make a point of adding error checking to catch this in a future version.

Because the scaling between water isotope values and animal tissues often deviates from 1:1 (e.g., https://doi.org/10.1371/journal.pone.0035137) it's pretty risky to do isotope geolocation using known origin data from only one site. You could force this...for example by applying a fixed offset to the environmental isosocape values to produce your feather (I assume) isoscape, but that implies the scaling is 1:1. If you don't have your own Junco known origin data for additional sites you might look for additional sites in the literature or in the knownOrig database that is packaged w/ assignR. It looks like the only Junco species represented in the database is from the western USA, so you might have to consider falling back on data from other similar species.

@salinedi0n
Copy link
Author

Hi Gabe, thank you for the response. Yes, we unfortunately only have known origin junco samples from the one biological research station. Moving forward with guild- and range-similar species. I appreciate all the help!

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

2 participants