diff --git a/.DS_Store b/.DS_Store index 70545a3..58ed3fe 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/R/ComputeEdgelist.R b/R/ComputeEdgelist.R index 63e93c0..85a7e6c 100644 --- a/R/ComputeEdgelist.R +++ b/R/ComputeEdgelist.R @@ -73,62 +73,62 @@ ComputeEdgelist <- function(node.object, #### MSBR 2024-06-16 #### Revised MSBR 2025-11-22 to fix k inheritance bug - if(!(is.null(k)) & nn.method == 'aoz'){ - # df <- data.frame(x = node.object[[position.x]], y = node.object[[position.y]]) - # df$barcode <- rownames(df) - # df$x <- as.character(df$x) - # df$y <- as.character(df$y) - # df$x <- as.numeric(df$x) - # df$y <- as.numeric(df$y) - # df <- df[,c('x','y')] - # - # coords <- as.matrix(df)#cbind(data.list[[i]]$x,data.list[[i]]$y) - coords <- as.matrix(cbind(node.object$x,node.object$y)) - ord <- order(coords[,1]) - - n.neighbors <- k # inherits input 'k' - n.omp.t <- 1 - - n <- nrow(coords) - - - u.search.type <- 2 ##2 is very fast, 1 is slightly faster than 0, and 0 is the orginal slow one (2 and 0 should match, 1 is also corrected just different opposite sorting among the children) - - indx <- spNNGP:::mkNNIndxCB(coords, n.neighbors, n.omp.t) - - nn.indx <- indx$nnIndx - nn.indx.lu <- indx$nnIndxLU - nn.indx.run.time <- indx$run.time - - storage.mode(nn.indx) <- "integer" - storage.mode(nn.indx.lu) <- "integer" - - n.indx <- spNNGP:::mk.n.indx.list(nn.indx, n, n.neighbors) - names(n.indx) <- 1:nrow(coords) - - # build sparse Adjacency Matrix - n.indx.names <- names(n.indx) - # this unusual code let's me reference a list element's - # name INSIDE the apply function, neat - # THIS NEXT STEP AOZ WROTE - IT'S SLOW AND COULD BE SPED UP - adj.ij <- lapply(setNames(n.indx.names, n.indx.names), function(nameindex) { - data.frame(i=rep(as.integer(nameindex), length(n.indx[[nameindex]])), - j=n.indx[[nameindex]])}) - adj.ij <- data.table::rbindlist(adj.ij) - # clean and make it mutual - adj.ij <- na.omit(adj.ij) - adj.ij <- rbind(adj.ij, - data.frame(i=adj.ij$j, - j=adj.ij$i)) - # map back to original coord indexing - adj.ij$i <- ord[adj.ij$i] - adj.ij$j <- ord[adj.ij$j] - adj.ij <- as.data.frame(adj.ij) - colnames(adj.ij) <- c("from", "to") - edgelist <- adj.ij - - - } + # if(!(is.null(k)) & nn.method == 'aoz'){ + # # df <- data.frame(x = node.object[[position.x]], y = node.object[[position.y]]) + # # df$barcode <- rownames(df) + # # df$x <- as.character(df$x) + # # df$y <- as.character(df$y) + # # df$x <- as.numeric(df$x) + # # df$y <- as.numeric(df$y) + # # df <- df[,c('x','y')] + # # + # # coords <- as.matrix(df)#cbind(data.list[[i]]$x,data.list[[i]]$y) + # coords <- as.matrix(cbind(node.object$x,node.object$y)) + # ord <- order(coords[,1]) + # + # n.neighbors <- k # inherits input 'k' + # n.omp.t <- 1 + # + # n <- nrow(coords) + # + # + # u.search.type <- 2 ##2 is very fast, 1 is slightly faster than 0, and 0 is the orginal slow one (2 and 0 should match, 1 is also corrected just different opposite sorting among the children) + # + # indx <- spNNGP:::mkNNIndxCB(coords, n.neighbors, n.omp.t) + # + # nn.indx <- indx$nnIndx + # nn.indx.lu <- indx$nnIndxLU + # nn.indx.run.time <- indx$run.time + # + # storage.mode(nn.indx) <- "integer" + # storage.mode(nn.indx.lu) <- "integer" + # + # n.indx <- spNNGP:::mk.n.indx.list(nn.indx, n, n.neighbors) + # names(n.indx) <- 1:nrow(coords) + # + # # build sparse Adjacency Matrix + # n.indx.names <- names(n.indx) + # # this unusual code let's me reference a list element's + # # name INSIDE the apply function, neat + # # THIS NEXT STEP AOZ WROTE - IT'S SLOW AND COULD BE SPED UP + # adj.ij <- lapply(setNames(n.indx.names, n.indx.names), function(nameindex) { + # data.frame(i=rep(as.integer(nameindex), length(n.indx[[nameindex]])), + # j=n.indx[[nameindex]])}) + # adj.ij <- data.table::rbindlist(adj.ij) + # # clean and make it mutual + # adj.ij <- na.omit(adj.ij) + # adj.ij <- rbind(adj.ij, + # data.frame(i=adj.ij$j, + # j=adj.ij$i)) + # # map back to original coord indexing + # adj.ij$i <- ord[adj.ij$i] + # adj.ij$j <- ord[adj.ij$j] + # adj.ij <- as.data.frame(adj.ij) + # colnames(adj.ij) <- c("from", "to") + # edgelist <- adj.ij + # + # + # } return(edgelist) } \ No newline at end of file diff --git a/packageUpdateScript.R b/packageUpdateScript.R index 7cd32b8..b8b2a66 100644 --- a/packageUpdateScript.R +++ b/packageUpdateScript.R @@ -18,6 +18,6 @@ pkgdown::build_article(name = "07 Spatiotemporal NICHES",lazy = T) # Install from release ? install_github('msraredon/NICHES', - ref = 'v1.2.0', + ref = 'v1.2.1', auth_token = 'f7ea5d8790fe721ac0c9d5ef115d04068b19ed6d', force = T)