We run methClust on the birds presence absence data in the continent of Australia.
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 > 110 & world_map$long < 160, ]
world_map <- world_map[world_map$lat > -50 & world_map$lat < -10, ]
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
latlong <- get(load("../data/LatLongCells_frame.rda"))
idx1 <- which(latlong[,2] > -50 & latlong[,2] < -10)
idx2 <- which(latlong[,1] > 110 & latlong[,1] < 160)
idx <- intersect(idx1, idx2)
length(idx)
## [1] 791
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
}
par(mfrow = c(3,2))
PlotAssemblageIdx(1)
PlotAssemblageIdx(10)
PlotAssemblageIdx(100)
PlotAssemblageIdx(500)
PlotAssemblageIdx(700)
PlotAssemblageIdx(800)
We apply methClust on the presence-absence data of relevant bird species in Australia.
topics <- meth_topics(birds_pa_data_3, 1 - birds_pa_data_3,
K=7, tol = 1, use_squarem = FALSE)
save(topics, file = "../output/Australia/methClust_7.rda")
PlotAssemblageIdx2 <- function(dat){
dat <- cbind.data.frame(latlong2, dat)
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
}
This R Markdown site was created with workflowr