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

Plot.SpdModleTest function Unable to display positive and negative area #57

Closed
CGL5230 opened this issue Nov 1, 2021 · 10 comments
Closed
Labels

Comments

@CGL5230
Copy link

CGL5230 commented Nov 1, 2021

Using the SPD model to analyze the carbon 14 data, the bbty parameter is “f” in the plot function is used to draw the positive and negative area, but the area cannot be displayed. However, the summary function can find the significant area.
library(openxlsx) data<-read.xlsx(file.choose()) caldates <- calibrate(x=data$BP, errors=data$SD, normalised=FALSE) bins <- binPrep(sites=data$SiteName, ages=data$BP, h=50) nsim=200 #Number of simulations expnull <- modelTest(caldates, errors=data$SD, bins=bins, nsim=nsim, runm=50,ncores = 3, timeRange=c(8000,1000), model="exponential", datenormalised=FALSE) #plot(expnull, xlim=c(8000,1000)) #round(expnull$pval,4) #p-value summary(expnull) plot( expnull, calendar = "BP", type = "spd", ylim = c(0,0.2), xlim = c(8000,1000), col.obs = "black", col.env = rgb(0, 0, 0, 0.2), lwd.obs = 0.5, xaxs = "i", yaxs = "i", bbty = "f", bbtyRet = TRUE, drawaxes = TRUE )
the result figure:
image
the summary result:
image

@ercrema
Copy link
Collaborator

ercrema commented Nov 1, 2021

Hi, I tested the code with another dateset and I am failing to reproduce the problem. I'm afraid that in order to help I would need have access to the data so I can reproduce the error. A couple of questions:

  1. Which version of rcarbon are you using?
  2. Does the problem arises when you simply run plot(expnull)?
  3. The argument col.env is actually available only for results of the permTest and not for the results modelTest. You should have received a warning message?
  4. Notice that bbtyRet = TRUE would work only when bbty = "b".

@CGL5230
Copy link
Author

CGL5230 commented Nov 1, 2021

Thank you for your reply.
Q1: The version 1.4.2
Q2: Actually, I got a warning message:"In modelTest(caldates, errors = data$SD, bins = bins, nsim = nsim, :
edgeSize reduced", but not irun plot function. It is at modelTest processing.
Q3: Actually, the first origin script is not including col.env. I do not receive a warning message.
Q4: I test change bbtyRet = FALSE, the problem still can not fix.
my data :
henan.xlsx
my code:
library(openxlsx)
data<-read.xlsx(file.choose())
caldates <- calibrate(x=data$BP, errors=data$SD, normalised=FALSE)
bins <- binPrep(sites=data$SiteName, ages=data$BP, h=50)
nsim=200 #Number of simulations
expnull <- modelTest(caldates, errors=data$SD, bins=bins, nsim=nsim, runm=50,ncores = 3,
timeRange=c(8000,1000), model="exponential", datenormalised=FALSE)
#plot(expnull, xlim=c(8000,1000))
plot(expnull)
#round(expnull$pval,4) #p-value
summary(expnull)

@ercrema
Copy link
Collaborator

ercrema commented Nov 1, 2021

That is very strange... I used your code and regions outside the simulation envelope are highlighted correctly... (see below)
After the plot(expnull), could you try running the following code?

polygon(x = c(7000,6000,6000,7000),y=c(0.1,0.1,0.15,0.15),col=rgb(0.7,0,0,0.2),border=NA)

and see if it draws a square rectangle? And if it doesn't could you try with this:

polygon(x = c(7000,6000,6000,7000),y=c(0.1,0.1,0.15,0.15),col=1,border=NA)

Screenshot_2021-11-01_13-49-55

@ercrema ercrema added the bug label Nov 1, 2021
@CGL5230
Copy link
Author

CGL5230 commented Nov 1, 2021

Yep...I try my code again and the picture as usual... But the rectangle could be draw by those code... I Confuse it....
image
image
may some issues about dependent package version? may be other?

@ercrema
Copy link
Collaborator

ercrema commented Nov 1, 2021

Very strange... I was hoping it was something to do with with alpha transparency but the fact that you can display the first rectangle means that this is not the case... Does this happen with other datasets? Could you try the following and see what happens ?

data(emedyd)
emedyd <- subset(emedyd,Region=='1')
caldates <- calibrate(x=emedyd$CRA, errors=emedyd$Error, normalised=FALSE)
bins <- binPrep(sites=emedyd$SiteName, ages=emedyd$CRA, h=50)
set.seed(123)
expnull <- modelTest(caldates, errors=emedyd$Error,nsim=100,ncores=3, runm=50,timeRange=c(16000,9000), model="exponential", datenormalised=FALSE)
plot(expnull)

@ercrema
Copy link
Collaborator

ercrema commented Nov 1, 2021

Also could you show me the results of your sessionInfo()

@CGL5230
Copy link
Author

CGL5230 commented Nov 1, 2021

Yes, i try. But the area seem disappear.. I really hope may be some environmental problem, AND i will pick other computer try do the math.
image
image

@ercrema
Copy link
Collaborator

ercrema commented Nov 1, 2021

Not really a solution but could you try the following:

bb<-plot(expnull,bbty = 'b')
boomBlocks <- bb$booms
bustBlocks <- bb$busts
for (i in 1:length(boomBlocks)){
      polygon(c(boomBlocks[[i]][[2]],rev(boomBlocks[[i]][[2]])),c(rep(+100,length(boomBlocks[[i]][[1]])),rep(-100,length(boomBlocks[[i]][[1]]))),col=rgb(0.7,0,0,0.2),border=NA)
}
for (i in 1:length(bustBlocks)){
      polygon(c(bustBlocks[[i]][[2]],rev(bustBlocks[[i]][[2]])),c(rep(+100,length(bustBlocks[[i]][[1]])),rep(-100,length(bustBlocks[[i]][[1]]))),col=rgb(0,0,0.7,0.2),border=NA)
}

@CGL5230
Copy link
Author

CGL5230 commented Nov 1, 2021

I seem like i find the reason... Maybe the environment of computer have some issues, maybe the windows10 update....
I really appreciate it for your help!
image

@ercrema
Copy link
Collaborator

ercrema commented Nov 1, 2021

Glad to see that is working now! :) I'll close the issue

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

No branches or pull requests

2 participants