We apply methClust to cells in Europe. We wish to check how the Wallace Line affects the communities of bird species.

Plotting Maps Function

latlong <- get(load("../data/LatLongCells_frame.rda"))
world_map <- map_data("world")
world_map <- world_map[world_map$region != "Antarctica",] # intercourse antarctica

world_map <- world_map[world_map$long > -15 & world_map$long < 50, ]
world_map <- world_map[world_map$lat > 36 & world_map$lat < 70, ]


p <- ggplot() + coord_fixed() +
  xlab("") + ylab("")

#Add map to base plot
base_world_messy <- p + geom_polygon(data=world_map, aes(x=long, y=lat, group=group), colour="light green", fill="light green")

cleanup <- 
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), 
        panel.background = element_rect(fill = 'white', colour = 'white'), 
        axis.line = element_line(colour = "white"), legend.position="none",
        axis.ticks=element_blank(), axis.text.x=element_blank(),
        axis.text.y=element_blank())

base_world <- base_world_messy + cleanup

base_world

Extracting Europe birds presence absence data

latlong <- get(load("../data/LatLongCells_frame.rda"))
idx1 <- which(latlong[,2] > 36 & latlong[,2] < 70)
idx2 <- which(latlong[,1] > -15 & latlong[,1] < 50)
idx <- intersect(idx1, idx2)
length(idx)
## [1] 1542
latlong2 <- latlong[idx,]
birds_pa_data <- readRDS("../data/birds_presab_land_breeding_counts.rds")
birds_pa_data_2 <- birds_pa_data[idx, ]
birds_pa_data_3 <- birds_pa_data_2[, which(colSums(birds_pa_data_2) > 10)]

Example presence-absence data of bird species

PlotAssemblageIdx <- function(idx){
  dat <- cbind.data.frame(latlong2, birds_pa_data_3[,idx])
colnames(dat) <- c("Latitude", "Longitude", "Value")
map_data_coloured <- 
  base_world +
  geom_point(data=dat, 
             aes(x=Latitude, y=Longitude, colour=Value), size=0.5) +
  scale_colour_gradient(low = "white", high = "black") 

map_data_coloured
}
par(mfrow = c(3,2))
PlotAssemblageIdx(1)

PlotAssemblageIdx(10)

PlotAssemblageIdx(100)

PlotAssemblageIdx(200)

PlotAssemblageIdx(300)

PlotAssemblageIdx(400)

Application of methClust and visualization

We apply methClust on the presence-absence data of relevant bird species in Europe.

topics <- meth_topics(birds_pa_data_3, 1 - birds_pa_data_3, 
            K=7, tol = 0.1, use_squarem = FALSE)
save(topics, file = "../output/Europe/methClust_7.rda")

This R Markdown site was created with workflowr