Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
41 views
Kernel: R (R-Project)

Structure démique

Il y a de gros problèmes liés à la résolution spatiale utilisée. Ici j'ai utilisé des données worldclim pour représenter la structure démique (les dèmes sont assimilés aux coordonnées des centroides des cellules de la grille. La résolution initiale a été dégradée (dèmes plus gros), les valeurs de bio1 ne sont pas utilisées dans ce modèle.

library("raster") library("rgdal") bio1 <- raster("wc2.0_10m_prec_01_europe_agg_fact_5.tif") bio1 table(is.na(getValues(bio1))) plot(bio1)
class : RasterLayer dimensions : 60, 96, 5760 (nrow, ncol, ncell) resolution : 0.4166667, 0.4166667 (x, y) extent : -20, 20, 35, 60 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 data source : /home/user/Soutenance/preliminaries/wc2.0_10m_prec_01_europe_agg_fact_5.tif names : wc2.0_10m_prec_01_europe_agg_fact_5 values : -1.562582, 19.61809 (min, max)
FALSE TRUE 2813 2947
Image in a Jupyter notebook

Modèle

Loi de croissance logistique

  • r U[1,20]r \sim U[1,20]

  • kU[1,500]k \sim U[1,500]

Modèle de dispersion gaussienne (voir Nathan et al.)

  • aU[10,1000]a \sim U[10,1000]

Nombre de gamètes introduits initialement:

  • N0U[1,15]N_0 \sim U[1,15]

Prior predictive sampling

On regarde à la sortie du simulateur si les distributions a priori ont été très modifiées par le rejet des simulations pour lesquelles la démographie a collapsé ou bien n'a pas atteint les points d'échantillonnage:

library(ggplot2) library(plyr) file <- "results_10_000_fast.txt" df <- read.csv(file, sep="\t") # Multiple plot function # # ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) # - cols: Number of columns in layout # - layout: A matrix specifying the layout. If present, 'cols' is ignored. # # If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), # then plot 1 will go in the upper left, 2 will go in the upper right, and # 3 will go all the way across the bottom. # multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) { library(grid) # Make a list from the ... arguments and plotlist plots <- c(list(...), plotlist) numPlots = length(plots) # If layout is NULL, then use 'cols' to determine layout if (is.null(layout)) { # Make the panel # ncol: Number of columns of plots # nrow: Number of rows needed, calculated from # of cols layout <- matrix(seq(1, cols * ceiling(numPlots/cols)), ncol = cols, nrow = ceiling(numPlots/cols)) } if (numPlots==1) { print(plots[[1]]) } else { # Set up the page grid.newpage() pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout)))) # Make each plot, in the correct location for (i in 1:numPlots) { # Get the i,j matrix positions of the regions that contain this subplot matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE)) print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row, layout.pos.col = matchidx$col)) } } } # Prior predictive sampling distribution p1 <- ggplot(df, aes(x=r)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(1,20), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(1,20), lty = 2) p2 <- ggplot(df, aes(x=k)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(1,500), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(1,500), lty = 2) p3 <- ggplot(df, aes(x=N0)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(3,15), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(3,15), lty = 2) p4 <- ggplot(df, aes(x=a)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(100,1000), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(100,1000), lty = 2) multiplot(p1,p2,p3,p4)
Image in a Jupyter notebook

Distribution des FTD à l'observé pour chaque locus.

loci_names <- names(df)[-c(1,2,3,4)] ftds <- df[,loci_names] stacked_ftds <- stack(ftds) names(stacked_ftds) <- c("FTD", "marker") ggplot(stacked_ftds, aes(x=FTD)) + geom_density(aes(group=marker, colour=marker))
Image in a Jupyter notebook

Vous en pensez quoi ?

Rejection and posteriors estimation

# Rejection quantiles <- lapply(ftds, quantile, 0.3) library (plyr) qt <- ldply (quantiles, data.frame) sample <- df[apply(df [loci_names], 1, function(x) all(x < qt[,2])),] head(sample) p5 <- ggplot(sample, aes(x=r)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(1,20), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(1,20), lty = 2) p6 <- ggplot(sample, aes(x=k)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(1,500), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(1,500), lty = 2) p7<- ggplot(sample, aes(x=N0)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(3,15), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(3,15), lty = 2) p8 <- ggplot(sample, aes(x=a)) + geom_density(kernel="gaussian") + stat_function(fun=dunif, args = list(100,1000), geom = "area", fill= "green", alpha = 0.35) + stat_function(fun=dunif, args = list(100,1000), lty = 2) multiplot(p5,p6,p7,p8)
Image in a Jupyter notebook

Je trouve que l'estimation de N0 est bizarre. Je m'attendais pas à ça, pour la seul et bonne raison que la diversité allélique aux loci n'est pas de 3 😕 je vais voir si il y a un problème de prog, et je vous dis ça. J'espère que c'est un problème de nombre de simulation.