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

masking error #32

Open
jmhallas opened this issue Aug 25, 2023 · 3 comments
Open

masking error #32

jmhallas opened this issue Aug 25, 2023 · 3 comments

Comments

@jmhallas
Copy link

jmhallas commented Aug 25, 2023

Hello,

Thank you for you help with inputting ancestry values. I am running into another issue regarding masking.

I have tried using my own raster using the following code to mask by California state boundaries. I get the following error

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘mask’ for signature ‘"RasterStack", "data.frame"’

Code I am using below

require(rgdal)
CA <- readOGR(dsn = "/Users/jhallas/Documents/cdfw/lcdeer/popgen_analysis/California_State_Boundary/", layer = "California_State_Boundary")
gridsize <- 0.01
r <- raster(CA,res=gridsize)
rr <- rasterize(CA, r)

plot(qk4, long.lat, method = "map.max", cex = .4,  
     interpol = FieldsKrigModel(10),
    raster.filename = rr,
     main = "Ancestry coefficients",
     xlab = "Longitude", ylab = "Latitude", 
     col.palette = my.palette)

This fails, but works with raster.filename excluded.

Any advise is greatly appreciated.

Thank you for your time.
tess_prelim

Josh

@francoio
Copy link
Collaborator

raster.filename must be a path to an external raster file, not to an R object

@francoio
Copy link
Collaborator

For an example, see the vignette https://bcm-uga.github.io/TESS3_encho_sen/articles/main-vignette.html. A raster file of Europe is downloaded for drawing a map of Q.

@jmhallas
Copy link
Author

jmhallas commented Oct 26, 2023

Thanks for the suggestion. I was able to mask the kriging. Is there a way to extend the range of the Kriging analysis? This is the range of the mask I would like to use.
tess_mask.pdf

However, when I run my analysis the lower right hand extant of the mask gets clipped.
tess_prelim1.pdf

This is the code I am running.

q.matrix <- as.matrix(qk47_info_noNA[1:4])
qk4 <- tess3r::as.qmatrix(q.matrix)

plot(qk4, long.lat, method = "map.max", cex = .4,  
     interpol = FieldsKrigModel(10),
     raster.filename = "/Users/jhallas/Documents/cdfw/lcdeer/popgen_analysis/California_State_Boundary/CA.asc",
     xlim= c(-124.5, -112.5), 
     ylim=c(32, 42.1), 
     main = "Ancestry coefficients",
     xlab = "Longitude", ylab = "Latitude", 
     col.palette = my.palette)

Thank you for you time and advise.

-josh

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