From 8fca81baa62d54274ae0ecee7f8d23afb9894070 Mon Sep 17 00:00:00 2001 From: reyvnth Date: Fri, 31 May 2024 15:33:41 -0600 Subject: [PATCH] loe package deletion and make.KNNG update --- DESCRIPTION | 3 +-- NAMESPACE | 1 - R/expression_adjacency_matrix.R | 3 +-- R/makeKNNG.R | 23 +++++++++++++++++++++++ citation.cff | 18 ++++++++++++++++++ 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 R/makeKNNG.R create mode 100644 citation.cff diff --git a/DESCRIPTION b/DESCRIPTION index 7523866..adfd57b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Date: 2024-01-24 License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 URL: https://github.com/fanzhanglab/STew BugReports: https://github.com/fanzhanglab/STew/issues Depends: @@ -23,7 +23,6 @@ Remotes: JEFworks-Lab/MERINGUE, satijalab/Seurat Imports: - loe (>= 1.1), Matrix (>= 1.5.4), ggpubr (>= 0.6.0), future, diff --git a/NAMESPACE b/NAMESPACE index 06ab64c..5c9966d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,7 +31,6 @@ import(ggplot2) import(ggpubr) import(ggrepel) import(gridExtra) -import(loe) import(matrixStats) import(parallel) import(parameters) diff --git a/R/expression_adjacency_matrix.R b/R/expression_adjacency_matrix.R index b5bbd64..0f3cd14 100644 --- a/R/expression_adjacency_matrix.R +++ b/R/expression_adjacency_matrix.R @@ -9,8 +9,7 @@ #' #' @export #' -#'@import loe -#'Matrix +#'@import Matrix expression_adjacency_matrix <- function(obj, nk = 200, symm = FALSE, weight = TRUE, mode = "undirected", weighted = FALSE) { # Calculate the Euclidean distance between each pair of cells using the gene expression matrix mat <- t(obj$count_exp) diff --git a/R/makeKNNG.R b/R/makeKNNG.R new file mode 100644 index 0000000..670e991 --- /dev/null +++ b/R/makeKNNG.R @@ -0,0 +1,23 @@ +make.kNNG <- + function(DM, k=as.integer( 2*log(nrow(DM)) ), symm =FALSE, weight=FALSE ) {#begin function + N <- nrow(DM) + ADM <- matrix(0, N, N) + #Search kNN point + if(weight==TRUE){ + for (i in 1:N) { + nid <- order(DM[i,]) + ADM[ i, nid[2:(k+1)] ] <- DM[ i, nid[2:(k+1)] ] + } + }else{ + for (i in 1:N) { + nid <- order(DM[i,]) + ADM[i,nid[2:(k+1)] ] <- 1 + } + } + if(symm==TRUE){ + SADM <- ADM+t(ADM) + SADM[SADM==2*ADM] <- ADM[SADM==2*ADM] + ADM <- SADM + } + return(ADM) + } diff --git a/citation.cff b/citation.cff new file mode 100644 index 0000000..e85819a --- /dev/null +++ b/citation.cff @@ -0,0 +1,18 @@ +cff-version: 1.0.3 +message: "If you use this software, please cite it using the following reference." +authors: + - family-names: Guo + given-names: N. + - family-names: Vargas + given-names: J. + - family-names: Fritz + given-names: D. + - family-names: Krishna + given-names: R. + - family-names: Zhang + given-names: F. +title: "Uncover spatially informed variations for single-cell spatial transcriptomics with STew" +date-released: 2024 +url: "https://doi.org/10.1093/bioadv/vbae064" +journal: "Bioinformatics Advances" +doi: "10.1093/bioadv/vbae064"