#' #' This is a list of R functions with the main functionalities of #' the chagasnws package. #' #' The name chagasnws make reference to the Chagas Networks. #' #' The main package dependence is with the igraph package. #' #' This function epsilon estimates the epsilon association used to build #' association link between species. #' #' @param nij = Number of cells or units in which both species A and B ocurrs. #' @param ni = Number of cells or units in which the A species ocurrs. #' @param nj = Number of cells or units in which the B species ocurrs. #' @param n = Number of cell grids or units in which A and B can ocurr. #' @examples #' epsilon(5,20,36,1900) #' @author Leopoldo Valiente-Banuet #' @author Carlos Ibarra-CerdeƱa #' @references #' \url{https://peerj.com/current_paper} #' @seealso #' \url{http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0005725#s4} #' @export epsilon <- function ( nij, ni, nj, n) { message_sent = FALSE if ((!is.numeric(nij)) | (!is.numeric(ni)) | (!is.numeric(nj)) | (!is.numeric(n))) { message ("nij, ni, nj and N must be numeric") message_sent = TRUE } if ((nij > ni) | (nij > nj) | (nij > n)){ message ("nij must be numeric and lower than ni, nj and N") message_sent = TRUE } if ((ni > n) | (nj > n)){ message ("ni and nj must be numeric and lower than N") message_sent = TRUE } Prob.Bi <- ni / n Prob.Bi.condicional.Ij <- nij / nj if (message_sent == TRUE){ epsilon = NA } else { epsilon <- (nj * (Prob.Bi.condicional.Ij - Prob.Bi)) / sqrt(nj * Prob.Bi * (1 - Prob.Bi)) } return(epsilon) } # The functions included in this script can be used as full procedures o # cab be used as code snipets. # An example to produce the graphs of the networks with different values of epsilon # is shown as follows. # The rest of the script presents R funtions. # This function produces five network graphs for epsilons of 2, 4, 6, 8 and 10. generate_network_graphs <- function() { nij <- 3 # Minimum number of species coincidences epsilon <- 2 # Select all significant epsilons biger or lower than 2. # This values depend on the implementation. Here we connect to a PostgreSQL/PostGIS # database q <- paste("select idvector as source, idmammal as target, ni, ni, nij, n, epsilon from epsilons ", " where (epsilon >= ",epsilon," or epsilon <= -",epsilon,") and nij >= ",nij,";",sep="") datos <- dbGetQuery(con, q) # The networks graphs that we present corresponde to the next values of epsilons. epsilons_graficas <- c(2,4,6,8,10) for ( i in 1:length(epsilons_graficas)) { graph_name_file = paste('graph_',epsilons_graficas[i],'.png',sep="") png(filename = graph_name_file, width = 1000, height = 1000, bg="transparent", res=80) #par(mfrow=c(3,2)) par(cex=0.9) epsi <- epsilons_graficas[i] datos_i <- datos[datos$epsilon >= epsi | datos$epsilon <= -epsi,] graph_df = data.frame(triatomine = datos_i$source, mammal = datos_i$target, epsilon = datos_i$epsilon) species_target_network_tmp = c(unique(datos_i$source), unique(datos_i$target)) speciestxt <- paste(species_target_network_tmp,sep=" ",collapse = ", ") # Again her it depends on the implementation. For us it is a database table especiestraits # with al the information about factors like T. cruzi and Synanthropy. q_traits <- paste("SELECT idespecie, tcruzi, synanthropic, class from especiestraits where idespecie in (", speciestxt,");",sep="") species_traits <- dbGetQuery(con,q_traits) species_traits$size <- rep(5,length(species_traits$idespecie)) species_traits$color <- rep(colors()[257],length(species_traits$idespecie)) species_traits$shape <- rep("circle",length(species_traits$idespecie)) #species_styles <- get_network_nodes_style(graphica) graphica <- igraph::graph.data.frame(d=graph_df, vertices=species_traits) graphica <-as.undirected(graphica, mode="collapse") # undirected graph # colors and shapes colors_and_shapes <- get_network_nodes_style(graphica,5) shapes_class <- c("circle","square") # circles for Triatomine and squares for Mammals # Uses the color palette categorical_pal to choose the colors. colors_class <- c(categorical_pal(8)[1], # orange dark for synanthropic and T. cruzi positive categorical_pal(8)[4], # yellow for synanthropic species categorical_pal(8)[3], # green for species with T. cruzi categorical_pal(8)[2] # blue for the non synanthropic and non T. cruzi ) species_class_colors <- igraph::get.vertex.attribute(graphica, 'class') species_class_colors[species_class_colors == 'Vector'] = colors_class[4] species_class_colors[species_class_colors == 'Mammal'] = colors_class[4] species_class_shapes <- igraph::get.vertex.attribute(graphica,'class') species_class_shapes[species_class_shapes == 'Vector'] = shapes_class[1] species_class_shapes[species_class_shapes == 'Mammal'] = shapes_class[2] species_tcruzi <- igraph::get.vertex.attribute(graphica,'tcruzi') species_synant <- igraph::get.vertex.attribute(graphica,'synanthropic') species_class <- igraph::get.vertex.attribute(graphica,'class') species_specie <- igraph::get.vertex.attribute(graphica,'name') for (i in 1:length(species_tcruzi)){ if (species_class[i] == 'Vector'){ if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")){ species_class_colors[i] = colors_class[4] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")) { species_class_colors[i] = colors_class[2] } if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "'t")) { species_class_colors[i] = colors_class[3] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "t")) { species_class_colors[i] = colors_class[1] } } else if (species_class[i] == 'Mammal'){ if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")){ species_class_colors[i] = colors_class[4] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "t")){ species_class_colors[i] = colors_class[1] } if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "t")){ species_class_colors[i] = colors_class[3] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")){ species_class_colors[i] = colors_class[2] } } } graphica <- igraph::set.vertex.attribute(graphica,"shape", V(graphica), species_class_shapes) graphica <- igraph::set.vertex.attribute(graphica,"color", V(graphica), species_class_colors) E(graphica)$color <- categorical_pal(8)[8] E(graphica)$lty = 1 plot(graphica, layout=layout.kamada.kawai, ) dev.off() } # End of example of the precedure mode. # The rest in this script are R functions by themself. #' This function generates a graph for an estimated network and send it to print. #' The examples for this function are: #' plot_network() - to plot all the epsilons bigger or equal to two, for all the species, #' without filtering with the coocurrences. #' plot_network(sel_triatomines = c(289)) - #' To plot the Triatoma pallidipenis interaction network #' #' @param sel_triatomines - Defines which triatomines to include in a list. Default is all . #' @param sel_mammals - Define which mammals to include in a list. Default is all. #' @param d_nij - Defines the minimum co-ocurrences to include by cell. 3 is the default #' @param epsilonp - Defines the umbral of the epsilon to include. 2 is the minimum default. #' @param style - Defines if the network is represented with the default style. #' #' @return - Plots a metwork #' @import igraph #' #' @examples #' plot_network() #' plot_network(sel_triatomines = c(289)) # The interactions network of Triatoma pallidipennis #' @export plot_network <- function(sel_triatomines='All', sel_mammals='All',d_nij=3, epsilonp=2, style=TRUE) { if ((!missing(sel_triatomines)) | (!missing(sel_mammals))) { if ((!missing(sel_triatomines)) & (missing(sel_mammals))) { if ("numeric" %in% class(sel_triatomines)) { cus <- cooccurrs[cooccurrs$idtriatomine %in% sel_triatomines,] } else if ("list" %in% class(sel_triatomines)) { cus <- cooccurrs[cooccurrs$idtriatomine %in% unlist(sel_triatomines),] } else { print(class(sel_triatomines)) } } else if ((missing(sel_triatomines)) & (!missing(sel_mammals))) { if ("numeric" %in% class(sel_triatomines)) { cus <- cooccurrs[cooccurrs$idmammal %in% sel_mammals,] } else if ("list" %in% class(sel_triatomines)) { cus <- cooccurrs[cooccurrs$idmammal %in% unlist(sel_mammals),] } else { print(class(sel_mammals)) } } else if ((!missing(sel_triatomines)) & (!missing(sel_mammals))) { if ("numeric" %in% class(sel_triatomines)) { sps_a = sel_triatomines } else if ("list" %in% class(sel_triatomines)) { sps_a = unlist(sel_triatomines) } else if (("character" %in% class(sel_triatomines)) & (sel_triatomines == "All")) { sps_a = "All" } else { sps_a = "notAll" } if ("numeric" %in% class(sel_mammals)) { sps_b = sel_mammals } else if ("list" %in% class(sel_mammals)) { sps_b = unlist(sel_mammals) } else if (("character" %in% class(sel_mammals)) & (sel_mammals == "All")) { sps_b = "All" } else { sps_b = "notAll" } if ((class(sps_a) == "character" && sps_a == "All") && (class(sps_b) == "character" & sps_b == "All")) { cus <- cooccurrs } else if (class(sps_a) == "numeric" & class(sps_b) == "numeric") { cus <- cooccurrs[cooccurrs$idtriatomine %in% sps_a & cooccurrs$idmammal %in% sps_b,] } } } else { cus <- cooccurrs } idmammals_l <- c() idtriatominos_l <- c() epsilons_l <- c() for (i in 1:dim(cus)[1]){ if ((d_nij != 1) & (d_nij > 1)) { cus <- cus[cus$nij>=d_nij,] } epsilons_est <- epsilon(cus[i,]$nij, cus[i,]$ni, cus[i,]$nj, cus[i,]$n) if (epsilons_est >= epsilonp) { s <- length(epsilons_l) + 1 epsilons_l[s] <- epsilons_est idmammals_l[s] <- cus[i,]$idmammal idtriatominos_l[s] <- cus[i,]$idtriatomine } } graph_df = data.frame(idmammal = idmammals_l, idtriatomine = idtriatominos_l, epsilon = epsilons_l) species_traits <- get_species_traits(graph_df) graphica <- igraph::graph.data.frame(d=graph_df,vertices=species_traits) graphica <-as.undirected(graphica,mode="collapse") # means undirected graph colors_and_shapes <- get_network_nodes_style(graphica,5) legend(2000, 9.5, # places a legend at the appropriate place legend(1,1,fill = unique(as.vector(matrixValues[matrixValues>0])), legend=unique(as.vector(matrixValues[matrixValues>0]))) graphica <- igraph::set.vertex.attribute(graphica,"shape", V(graphica),colors_and_shapes[[2]]) graphica <- igraph::set.vertex.attribute(graphica,"color", V(graphica),colors_and_shapes[[1]]) send_network_to_plot(graphica, position = 0.0, scale = FALSE, scale_variable = "", main = '', factor_scale = 20) return <- graphica } #' This function gets the species attributes for the network nodes. #' #' # A dataframe for the graph. #' @param species_graph_df #' #' @return #' #' @examples #' get_species_traits(graph_df) #' get_species_traits <- function(species_graph_df = '') { triat <- triatomine mamm <- mammals names(triat) <- c('id','cl','gen','sp','lon','lat','tc','syn') names(mamm) <- c('id','cl','gen','sp','lon','lat','tc','syn') species_traits <- rbind(triat,mamm) species_traits <- species_traits[species_traits$id %in% species_graph_df$idtriatomine | species_traits$id %in% species_graph_df$idmammal,] species_traits <- species_traits[c('id','cl','sp','tc','syn')] names(species_traits) <- c('especie','class','specie_name','tcruzi','synanthropic') return(species_traits) } #' This function set the default nodes style in the graph. #' #' @param gu - the graph with all of their attributes #' @param size - the defatul size for the nodes #' #' @return #' @import igraph get_network_nodes_style <- function(gu,size=5) { shapes_class <- c("circle","square") # circles for Triatomine and squares for Mammals colors_class <- c(categorical_pal(8)[1], # orange dark for synanthropic and T. cruzi positive categorical_pal(8)[4], # yellow for synanthropic species categorical_pal(8)[3], # green for species with T. cruzi categorical_pal(8)[2] # blue for the non synanthropic and non T. cruzi ) species_class_colors <- igraph::get.vertex.attribute(gu,'class') species_class_colors[species_class_colors == 'triatomine'] = colors_class[4] species_class_colors[species_class_colors == 'mammal'] = colors_class[4] species_class_shapes <- igraph::get.vertex.attribute(gu,'class') species_class_shapes[species_class_shapes == 'triatomine'] = shapes_class[1]; species_class_shapes[species_class_shapes == 'mammal'] = shapes_class[2]; species_tcruzi <- igraph::get.vertex.attribute(gu,'tcruzi') species_synant <- igraph::get.vertex.attribute(gu,'synanthropic') species_class <- igraph::get.vertex.attribute(gu,'class') species_specie <- igraph::get.vertex.attribute(gu,'specie_name') for (i in 1:length(species_tcruzi)){ if (species_class[i] == 'triatomine'){ if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")){ species_class_colors[i] = colors_class[4] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")) { species_class_colors[i] = colors_class[2] } if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "'t")) { species_class_colors[i] = colors_class[3] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "t")) { species_class_colors[i] = colors_class[1] } } else if (species_class[i] == 'mammal'){ if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")){ species_class_colors[i] = colors_class[4] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "t")){ species_class_colors[i] = colors_class[1] } if ((species_synant[i] == 'FALSE' | species_synant[i] == "f") && (species_tcruzi[i] == 'TRUE' | species_tcruzi[i] == "t")){ species_class_colors[i] = colors_class[3] } if ((species_synant[i] == 'TRUE' | species_synant[i] == "t") && (species_tcruzi[i] == 'FALSE' | species_tcruzi[i] == "f")){ species_class_colors[i] = colors_class[2] } } } return(list(species_class_colors,species_class_shapes)) } #' Receive the network properly and show in the screen with scale and styles. #' #' @param gu - Graph to plot #' @param position - position of the legends in the network. #' @param main - title for the network #' @param scale - to scale or not to scale the nodes. #' @param scale_variable - the variable of the network properties to scale #' @param factor_scale - a number to make more or less evident the scaling #' @param clase - #' #' @return #' #' @examples #' @export send_network_to_plot <- function(gu, position = 0.3, main = "", scale = FALSE, scale_variable = 'betweenness', factor_scale = 5, clase = 'Vector' ) { n <- length(V(gu)) if (scale == TRUE){ # It can include network properties to scale the node sizes. centralities_local <- centralities_target_network species_class_names<-get.vertex.attribute(gu,'name') #names(centralities_vectors) orden_especies_vertices <- data.frame(idespecie=species_class_names) row_v <- data.frame() for (i in 1:length(centralities_local$idespecie)){ row_v <- rbind(row_v,centralities_local[centralities_local$idespecie==as.character(orden_especies_vertices$idespecie[i]),]) } row.names(row_v) <- NULL centralities_local_ordenadas <- row_v row.names(centralities_local_ordenadas) <- NULL scale_factor <- scale_variable if (clase == 'mammal') { V(gu)[V(gu)[class=="Mammal"]]$size <- eval(parse(text=paste("scale(centralities_local_ordenadas$",scale_factor,", scale=TRUE, center = FALSE) * ",factor_scale,"",sep=""))) } else if (clase == 'triatomine') { V(gu)[V(gu)[class=="Vector"]]$size <- eval(parse(text=paste("scale(centralities_local_ordenadas$",scale_factor,", scale=TRUE, center = FALSE) * ",factor_scale,"",sep=""))) } } set.seed(233) par(cex=0.5) title = main atributtes_lis <- set_network_nodes_style(gu,5) plot(gu, vertex.label.dist=c(rep(position, n)), layout=layout.kamada.kawai, main=title ) } #' This function plots the centroids of distributions of the triatomine and mammals species. #' To runs a Mexico shapefile contour map is needed. It is included as a dataset in the package chagasnws. #' #' @return #' #' @examples #' plot_centroides() #' plot_centroides('triatomine') #' plot_centroides('mammals') #' @export plot_centroids <- function(centroids="") { basic_colors_species = c("red","navy blue") data(mexico) plot.new() if (centroids == "") { plot(mexico, main="Species distribution centroids", xlim=c(-126,-77), ylim=c(10, 36)) add_interactions() styles_centroids_triat = style_centroids(triatomine$idtriatomine,'triatomine','both') points(triatomine$lon_centroid,triatomine$lat_centroid,pch=22,cex=1,col=unlist(styles_centroids_triat), bg=unlist(styles_centroids_triat)) styles_centroids_mamm = style_centroids(mammals$idmammal,'mammals','both') points(mammals_filtered$lon_centroid,mammals_filtered$lat_centroid,pch=21,cex=1,col=unlist(styles_centroids_mamm), bg=unlist(styles_centroids_mamm)) } else if (centroids == 'triatomine'){ plot(mexico, main="Triatomine species distributions centroids", xlim=c(-126,-77), ylim=c(10, 36)) points(triatomine$lon_centroid,triatomine$lat_centroid,pch=22,cex=1,col=basic_colors_species[1], bg=basic_colors_species[1]) } else if (centroids == 'mammals'){ plot(mexico, main="Mammals species distribution centroids", xlim=c(-126,-77), ylim=c(10, 36)) points(mammals_filtered$lon_centroid,mammals_filtered$lat_centroid,pch=21,cex=1,col=basic_colors_species[2], bg=basic_colors_species[2]) } } #' Creates and plot communities graphs. #' #' @return #' @export #' #' @examples create_and_plot_communities <- function() { # Get the species and species traits for the target network # This function returns idtriatomine, idmammal and epsilon for the species. # This function is not included because it depends on the implementation. # We have a here a connection to a db. # get_species_epsilons_target_network_f('epsilonsr',nij=nij) # species data cooccurrs <- get_species_epsilons_target_network_f('epsilonsr',nij=nij) # species data # This function retrieves the species traits, specifically tcruzi and synanthropic boolean traits # This function returns the idspecies, tcruzi, synathropic and class for all the species in the network # This function is not included because depends on the implementation. We have a here a connection to a db. get_species_traits_f(adjust_nodes = FALSE, source = 'general_network', node_class = 'Triatomine-Mammal') graphica <- graph.data.frame(d=species_epsilons_target_network,vertices=species_traits_target_network) # Creates an indirected graph graphica <-as.undirected(graphica,mode="collapse") # undirected graph # Adjacency matrix matriza <- get.adjacency(graphica) # Calls the community function according to Newman to separate in just two communities mem <- community.newman(graphica) V(graphica)$color <- ifelse(mem < 0, "grey", "green") # Assigned default colors to communities 1 and 2 V(graphica)$community <- ifelse(mem < 0, 1, 2) V(graphica)$community <- ifelse(mem < 0, 2, 1) # a la inversa # To weights the nodes V(graphica)$width <- 2 # To weight the nodes we can adjust the size we use some properties nodes in the graph # like is shown here. # E(graphica)$weight <- edge.betweenness(graphica) # V(graphica)$community == 1 V(graphica)[ V(graphica)[community == 1] ]$shape marks1 <- c(V(graphica)[ V(graphica)[community == 1] ]) marks2 <- c(V(graphica)[ V(graphica)[community == 2] ]) E(graphica)$color <- categorical_pal(8)[8] E(graphica)$lty = 1 # Synanthropic or intermediate nodes intermediacion <- E(graphica)[ V(graphica)[color=="grey"] %--% V(graphica)[color=="green"] ] $color <- colors_class[1] E(graphica)[ V(graphica)[color=="grey"] %--% V(graphica)[color=="green"] ]$lty <- 4 E(graphica)[ V(graphica)[color=="green"] %--% V(graphica)[color=="grey"] ] # Color assigned to the edges E(graphica)[color=="grey"]$color <- 'darkgrey' # Change the node shapes V(graphica)[ V(graphica)[class == 'Vector'] ]$shape <- shapes_class[1] V(graphica)[ V(graphica)[class == 'Mammal'] ]$shape <- shapes_class[2] # # Changes the color for the nodes according if they belong to the communities 1 and 2 # for (i in V(graphica)){ if (V(graphica)[i]$color == "grey"){ # Nodes in Community 1 if (V(graphica)[i]$synanthropic == TRUE){ if (V(graphica)[i]$tcruzi == TRUE){ V(graphica)[i]$color <- colors_class[1] } else if (V(graphica)[i]$tcruzi == FALSE){ V(graphica)[i]$color <- colors_class[3] } } else if (V(graphica)[i]$synanthropic == FALSE){ if (V(graphica)[i]$tcruzi == TRUE){ V(graphica)[i]$color <- colors_class[2] } else if (V(graphica)[i]$tcruzi == FALSE){ V(graphica)[i]$color <- colors_class[4] } } } else if (V(graphica)[i]$color == "green"){ # Nodes in Community 2 if (V(graphica)[i]$synanthropic == TRUE){ if (V(graphica)[i]$tcruzi == TRUE){ V(graphica)[i]$color <- colors_class[1] } else if (V(graphica)[i]$tcruzi == FALSE){ V(graphica)[i]$color <- colors_class[3] } } else if (V(graphica)[i]$synanthropic == FALSE){ if (V(graphica)[i]$tcruzi == TRUE){ V(graphica)[i]$color <- colors_class[2] } else if (V(graphica)[i]$tcruzi == FALSE){ V(graphica)[i]$color <- colors_class[4] } } } } # Scale the nodes size V(graphica)$size <- scale(abs(mem), 5, 12) # Create a tiff file with marks for the communities. set.seed(130) name_graph_comunidades <- paste("RplotComunidadesPeerJ_epsilon_",epsilon,"_nij_",nij,".tiff",sep="") tiff(filename = name_graph_comunidades, width = 1600, height = 1600, units = "px", pointsize = 12, compression = c("none"), bg = "white", res = NA, type = c("cairo", "Xlib", "quartz")) par(cex=0.9) l <- layout.kamada.kawai # Used Layout to graph the comminities marks <- list(marks1,marks2) # Add mark for gropus of nodes shapis <- list(1,1) par(cex=0.9) plot(graphica,layout=l, mark.groups = marks, mark.shape = shapis, mark.col = c(adjustcolor("#CC79A7",0.2), adjustcolor("#F0E442",0.2)), mark.border = c("#CC79A7","#F0E442"), margin(c(0.5))) dev.off() } #' Function to build the communities according to the references. #' #' @param g is a graph object #' #' @return #' @references #' https://pdfs.semanticscholar.org/1d27/44b83519657f5f2610698a8ddd177ced4f5c.pdf #' http://www.pnas.org/content/103/23/8577.abstract #' @examples community.newman <- function(g){ deg <- degree(g) ec <- ecount(g) B <- get.adjacency(g) - outer(deg, deg, function(x,y) x*y/2/ec) diag(B) <- 0 eigen(B)$vectors[,1] } #' Function to scale the nodes in the communities graphs. #' #' @param v #' @param a #' @param b #' #' @return #' scale <- function(v,a,b){ v <- v-min(v); v <- v/max(v); v <- v*(b-a); v+a } #' These are the main datasets of species co-occurences of triatomines and #' mammals asssociated with the Chagas disease in Mexico. #' #' A dataset containing the historic co-occurrences of triatome species and #' more than 500 mammals species in Mexico. #' #' The count of co-occurences is made over a 0.25 grad grid. #' These counts include the occurences of the species where #' both co-occurr in at least 3 cells of the grid. #' #' @format A data frame with 658 rows and 6 variables: #' \describe{ #' \item{idvector}{integer id for the triatomine species} #' \item{idmammal}{integer id for the mammal species} #' \item{ni}{number of cells of a grid or units in which } #' \item{nj}{number of cells of a grid or units in which } #' \item{nij}{number of cells of a grid or units in which } #' \item{n}{number of cells of a grid or units in which } #' } "cooccurrs" #' Dataset of triatomine vectors names occurring in Mexico. #' #' A dataset based on the historic occurrences of triatome species in Mexico. #' #' @format A data frame with 26 rows and 6 variables: #' \describe{ #' \item{idvector}{integer id for the triatomine species} #' \item{genus}{Genus of the triatomine species} #' \item{species}{Name of the species of triatomine} #' \item{lon_centroid}{Median longitude of the centroid of their species geographic range} #' \item{lat_centroid}{Median latitude of the centroid of their species geographic range} #' } "triatomine" #' Dataset of mammal species occurring in Mexico associated to the triatomines. #' #' A dataset based on the historic occurrences of mammals species in Mexico. #' #' @format A data frame with 26 rows and 6 variables: #' \describe{ #' \item{idvector}{integer id for the triatomine species} #' \item{genus}{Genus of the triatomine species} #' \item{species}{Name of the species of triatomine} #' \item{lon_centroid}{Median longitude of the centroid of their species geographic range} #' \item{lat_centroid}{Median latitude of the centroid of their species geographic range} #' } "mammals" #' Dataset from a Mexico shapefile to plot the centroid distributions #' and species interactions in a geographic representation. #' #' @format A data frame with 825 geometry IDs #' \describe{ #' } "mexico"