if (FALSE) {
# Not run:
library(BoneProfileR)
path_Hedgehog <- system.file("extdata", "Erinaceus_europaeus_fem_2-1_small.png",
package = "BoneProfileR")
bone <- BP_OpenImage(file=path_Hedgehog)
plot(bone, type="original")
bone <- BP_DetectBackground(bone=bone, analysis="logistic")
bone <- BP_DetectForeground(bone=bone, analysis="logistic")
bone <- BP_DetectCenters(bone=bone, analysis="logistic", method="Accurate")
# Note that some parts of the section are concave but it does not give problems in the analysis
# For section with very strong concavity, it is safer to use:
# bone <- BP_DetectCenters(bone=bone, analysis="logistic", method="AccurateConvex")
plot(bone, type="original")
plot(bone, type="mineralized")
plot(bone, type="unmineralized")
plot(bone, type="section")
plot(bone, type="colors")
plot(bone, type="3Dcolors")
bone <- BP_EstimateCompactness(bone, analysis="logistic", center="ontogenetic")
plot(bone, type="original")
plot(bone, type="mineralized")
plot(bone, type="observations")
bone <- BP_FitMLCompactness(bone, analysis="logistic")
plot(bone, type="model", analysis=1)
plot(bone, type="observations+model", analysis=1)
fittedpar <- BP_GetFittedParameters(bone, analysis="logistic")
bone <- BP_DuplicateAnalysis(bone, from="logistic", to="flexit")
bone <- BP_FitMLCompactness(bone,
fitted.parameters=c(fittedpar, K1=1, K2=1),
fixed.parameters=NULL, analysis="flexit")
compare_AIC(Logistic=BP_GetFittedParameters(bone, analysis="logistic", alloptim=TRUE),
Flexit=BP_GetFittedParameters(bone, analysis="flexit", alloptim=TRUE))
# pdf(file = "Figure 2.pdf", width = 8, height = 10, pointsize = 12)
layout(1:2)
plot(bone, type="observations+model", analysis="logistic", restorePar=FALSE, mar=c(4, 4, 2, 5))
plot(bone, type="observations+model", analysis="flexit", restorePar=FALSE, mar=c(4, 4, 2, 5))
layout(1)
# dev.off()
out4p <- plot(bone, type="observations+model", analysis="logistic")
out6p <- plot(bone, type="observations+model", analysis="flexit")
bone <- BP_FitBayesianCompactness(bone, analysis="logistic")
plot(bone, type="observations+model", CI="MCMC")
bone <- BP_FitBayesianCompactness(bone, analysis="flexit")
plot(bone, type="observations+model", CI="MCMC", analysis="flexit")
plot(bone, type="mcmc", parameter="P",
options.mcmc=list(xlim=c(0.55, 0.57), breaks=seq(from=0, to=1, by=0.001)))
plot(bone, type="mcmc", parameter="S",
options.mcmc=list(xlim=c(0.02, 0.05), breaks=seq(from=0.02, to=.05, by=0.001)))
plot(bone, type="mcmc", parameter="Min",
options.mcmc=list(xlim=c(0.05, 0.08), breaks=seq(from=0, to=1, by=0.001)))
plot(bone, type="mcmc", parameter="Max",
options.mcmc=list(xlim=c(0.95, 0.97), breaks=seq(from=0, to=1, by=0.001)))
outMCMC <- RM_get(x = bone, RM = "RM", RMname = "logistic", valuename = "mcmc")
summary(outMCMC)
outMCMC <- RM_get(x = bone, RM = "RM", RMname = "flexit", valuename = "mcmc")
summary(outMCMC)
# pdf(file = "Figure 3.pdf", width = 8, height = 10, pointsize = 12)
layout(1:2)
plot(bone, type="mcmc", parameter="K1", analysis="flexit",
options.mcmc=list(xlim=c(-1, 3), ylim=c(0,10),
breaks=seq(from=-1, to=3, by=0.001),
legend = FALSE, show.prior = FALSE, mar=c(4, 4, 1, 6)), restorePar=FALSE)
segments(x0=1, x1=1,
y0=0, y1=10, lty=4, lwd=3)
text(x=ScalePreviousPlot(x=0.95, y=0.95)$x,
y=ScalePreviousPlot(x=0.95, y=0.95)$y, labels="A", cex=3)
plot(bone, type="mcmc", parameter="K2", analysis="flexit",
options.mcmc=list(xlim=c(-1, 3), ylim=c(0,10),
breaks=seq(from=-1, to=3, by=0.001),
legend = FALSE, show.prior = FALSE, mar=c(4, 4, 1, 6)), restorePar=FALSE)
segments(x0=1, x1=1,
y0=0, y1=10, lty=4, lwd=3)
text(x=ScalePreviousPlot(x=0.95, y=0.95)$x,
y=ScalePreviousPlot(x=0.95, y=0.95)$y, labels="B", cex=3)
# dev.off()
bone <- BP_FitMLRadialCompactness(bone, analysis = "flexit")
plot(bone, type="radial", radial.variable=c("P", "S"), analysis = "flexit")
plot(bone, type="radial", radial.variable=c("P", "S", "Min", "Max"), analysis = "flexit")
out <- RM_get(x=bone, RMname="flexit", valuename = "optimRadial")$synthesis
mean(out[, "P"]); sd(out[, "P"])
range(out[, "S"])
quantile(out[, "S"])
# pdf(file = "Figure 4.pdf", width=7, height = 9, pointsize = 12)
layout(1:2)
plot(bone, type="radial", radial.variable="P", analysis = "flexit", restorePar=FALSE)
text(x=ScalePreviousPlot(x=0.95, y=0.95)$x,
y=ScalePreviousPlot(x=0.95, y=0.95)$y, labels="A", cex=3)
plot(bone, type="radial", radial.variable="S", analysis = "flexit", restorePar=FALSE)
text(x=ScalePreviousPlot(x=0.95, y=0.95)$x,
y=ScalePreviousPlot(x=0.95, y=0.95)$y, labels="B", cex=3)
# dev.off()
#' # How many times this package has been download
library(cranlogs)
BoneProfileR <- cran_downloads("BoneProfileR", from = "2021-10-07",
to = Sys.Date() - 1)
sum(BoneProfileR$count)
plot(BoneProfileR$date, BoneProfileR$count, type="l", bty="n",
xlab="Download date", ylab="Number of downloads")
}
Run the code above in your browser using DataLab