We apply methClust to cells along the Wallace line. 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 > 90 & world_map$long < 160, ]
world_map <- world_map[world_map$lat > -18 & world_map$lat < 20, ]


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 Wallace Line presence absence data

latlong <- get(load("../data/LatLongCells_frame.rda"))
idx1 <- which(latlong[,2] > -18 & latlong[,2] < 20)
idx2 <- which(latlong[,1] > 90 & latlong[,1] < 160)
idx <- intersect(idx1, idx2)
length(idx)
## [1] 703
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)!=0)]
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
}

Example presence-absence data of bird species

par(mfrow = c(6,2))
PlotAssemblageIdx(1)

PlotAssemblageIdx(10)

PlotAssemblageIdx(100)

PlotAssemblageIdx(500)

PlotAssemblageIdx(700)

PlotAssemblageIdx(1000)

PlotAssemblageIdx(1100)

PlotAssemblageIdx(1200)

PlotAssemblageIdx(1300)

PlotAssemblageIdx(1400)

PlotAssemblageIdx(1500)

PlotAssemblageIdx(1600)

Application of methClust and visualization

We apply methClust on the presence-absence data of relevant bird species along the Wallace Line.

topics <- meth_topics(birds_pa_data_3, 1 - birds_pa_data_3, 
            K=2, tol = 0.1, use_squarem = FALSE)
save(topics, file = "../output/Wallacea/methClust_2.rda")

This R Markdown site was created with workflowr