From 525112b0a015865ce6d739713e9c7bcc6f3caae3 Mon Sep 17 00:00:00 2001 From: Lidan Wu Date: Fri, 11 Apr 2025 17:50:38 +0000 Subject: [PATCH 1/3] fix spatColn in TxErrorDetection --- R/runTranscriptErrorDetection.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/runTranscriptErrorDetection.R b/R/runTranscriptErrorDetection.R index edf66df..20de50e 100644 --- a/R/runTranscriptErrorDetection.R +++ b/R/runTranscriptErrorDetection.R @@ -65,7 +65,7 @@ runTranscriptErrorDetection <- function(chosen_cells, transID_coln = transID_coln, transGene_coln = transGene_coln, score_coln = score_coln, - spatLocs_colns = c("x", "y", "z"), + spatLocs_colns = spatLocs_colns, model_cutoff = model_cutoff, score_cutoff = score_cutoff, svm_args = svm_args) From f85952f54d522411ce16563b0124cc960266f005 Mon Sep 17 00:00:00 2001 From: Lidan Wu Date: Mon, 19 May 2025 16:13:19 +0000 Subject: [PATCH 2/3] support msg --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c6f9b06..98d13b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,4 +11,4 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} issue-message: "Thank you for contacting us about our tools! To receive faster assistance, kindly email support.spatial@bruker.com with detailed information about your issue. If applicable, attach a screenshot of any encountered errors and include a copy of the modified script in Notepad. Our customer support team will help facilitate a review and resolution of the issue." - footer: "Thank you for choosing NanoString,\nNanoString Dev Team" + footer: "Thank you for choosing Bruker Spatial Biology,\nBruker Spatial Biology Dev Team" From 6027843064e00341e24164b12bc5bdf53d7fd89c Mon Sep 17 00:00:00 2001 From: Lidan Wu Date: Thu, 21 Aug 2025 05:19:21 +0000 Subject: [PATCH 3/3] other utils --- .gitignore | 2 +- R/decide_ReSegment_Operations.R | 27 --------------------- R/file_utilities.R | 7 ++---- R/group_transcripts_in_space.R | 16 ------------ R/other_utilities.R | 43 +++++++++++++++++++++++++++++++++ README.md | 4 +-- _pkgdown.yml | 2 +- man/igraph_delete_edges.Rd | 2 +- man/run_igraph_leiden.Rd | 2 +- 9 files changed, 51 insertions(+), 54 deletions(-) create mode 100644 R/other_utilities.R diff --git a/.gitignore b/.gitignore index 138866d..a7abd73 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ .RData .Ruserdata inst/doc -docs +docs/ diff --git a/R/decide_ReSegment_Operations.R b/R/decide_ReSegment_Operations.R index 8de5960..2267de1 100644 --- a/R/decide_ReSegment_Operations.R +++ b/R/decide_ReSegment_Operations.R @@ -434,30 +434,3 @@ check_config_leiden <- function(config){ return(config) } - -#' @title run_igraph_leiden -#' @description Run Leiden clustering with version-compatible resolution argument. -#' @param graph An igraph object representing the graph to cluster. -#' @param ... Additional arguments passed to `cluster_leiden()`, such as -#' `objective_function`, `resolution_parameter`, `beta`, `initial_membership`, -#' and `n_iterations`. -#' @return A clustering object returned by `cluster_leiden()`. -#' @details This function wraps `igraph::cluster_leiden()` and ensures compatibility -#' with both older (<2.1.0) and newer versions of the `igraph` package by renaming -#' the `resolution_parameter` argument to `resolution` if needed. -#' @importFrom igraph cluster_leiden -run_igraph_leiden <- function(graph, ...) { - args <- list(...) - - # Rename resolution_parameter to resolution if igraph >= 2.1.0 - if (packageVersion("igraph") >= "2.1.0") { - if ("resolution_parameter" %in% names(args)) { - args$resolution <- args$resolution_parameter - args$resolution_parameter <- NULL - } - } - - # Call cluster_leiden with modified arguments - do.call(igraph::cluster_leiden, c(list(graph), args)) -} - diff --git a/R/file_utilities.R b/R/file_utilities.R index f883167..fc48652 100644 --- a/R/file_utilities.R +++ b/R/file_utilities.R @@ -29,10 +29,7 @@ myFun_fov_load <- function(path_to_fov) { } else if (grepl("\\.csv$", base_path, ignore.case = TRUE)) { con <- if (is_gz) gzfile(path_to_fov) else path_to_fov each_transDF <- read.csv(con, sep = ',', header = TRUE) - } else if (grepl("\\.txt$", base_path, ignore.case = TRUE)) { - con <- if (is_gz) gzfile(path_to_fov) else path_to_fov - each_transDF <- read.csv(con, sep = '\t', header = TRUE) - } else if (grepl("\\.tsv$", base_path, ignore.case = TRUE)) { + } else if (grepl("\\.txt$|\\.tsv$", base_path, ignore.case = TRUE)) { con <- if (is_gz) gzfile(path_to_fov) else path_to_fov each_transDF <- read.csv(con, sep = '\t', header = TRUE) } else { @@ -138,7 +135,7 @@ prepare_perFOV_transDF <- function(each_transDF, raw_locs <- each_transDF[, orig_spatLocs_colns] # flip y coordinates (2nd) to have images shown from top to bottom - if(invert_y){ + if(invert_y==TRUE){ raw_locs[[orig_spatLocs_colns[2]]] <- 0-raw_locs[[orig_spatLocs_colns[2]]] } diff --git a/R/group_transcripts_in_space.R b/R/group_transcripts_in_space.R index 8bbeb2d..97b6a75 100644 --- a/R/group_transcripts_in_space.R +++ b/R/group_transcripts_in_space.R @@ -493,19 +493,3 @@ myFun_3point_singleCell <- function(dfCoord_subset, } -#' @title igraph_delete_edges -#' @description Delete edges from an igraph object with version compatibility -#' @param graph An igraph object from which edges will be deleted. -#' @param edges A vector of edge IDs or an edge selector to delete. -#' -#' @return An igraph object with the specified edges removed. -#' @details This function wraps `igraph::delete_edges()` and ensures compatibility -#' with older versions (<2.0.0) of `igraph` that used `delete.edges()`. -igraph_delete_edges <- function(graph, edges) { - if (packageVersion("igraph") >= "2.0.0") { - igraph::delete_edges(graph, edges) - } else { - igraph::delete.edges(graph, edges) - } -} - diff --git a/R/other_utilities.R b/R/other_utilities.R new file mode 100644 index 0000000..e48c414 --- /dev/null +++ b/R/other_utilities.R @@ -0,0 +1,43 @@ +#' @title run_igraph_leiden +#' @description Run Leiden clustering with version-compatible resolution argument. +#' @param graph An igraph object representing the graph to cluster. +#' @param ... Additional arguments passed to `cluster_leiden()`, such as +#' `objective_function`, `resolution_parameter`, `beta`, `initial_membership`, +#' and `n_iterations`. +#' @return A clustering object returned by `cluster_leiden()`. +#' @details This function wraps `igraph::cluster_leiden()` and ensures compatibility +#' with both older (<2.1.0) and newer versions of the `igraph` package by renaming +#' the `resolution_parameter` argument to `resolution` if needed. +#' @importFrom igraph cluster_leiden +run_igraph_leiden <- function(graph, ...) { + args <- list(...) + + # Rename resolution_parameter to resolution if igraph >= 2.1.0 + if (packageVersion("igraph") >= "2.1.0") { + if ("resolution_parameter" %in% names(args)) { + args$resolution <- args$resolution_parameter + args$resolution_parameter <- NULL + } + } + + # Call cluster_leiden with modified arguments + do.call(igraph::cluster_leiden, c(list(graph), args)) +} + + +#' @title igraph_delete_edges +#' @description Delete edges from an igraph object with version compatibility +#' @param graph An igraph object from which edges will be deleted. +#' @param edges A vector of edge IDs or an edge selector to delete. +#' +#' @return An igraph object with the specified edges removed. +#' @details This function wraps `igraph::delete_edges()` and ensures compatibility +#' with older versions (<2.0.0) of `igraph` that used `delete.edges()`. +igraph_delete_edges <- function(graph, edges) { + if (packageVersion("igraph") >= "2.0.0") { + igraph::delete_edges(graph, edges) + } else { + igraph::delete.edges(graph, edges) + } +} + diff --git a/README.md b/README.md index 51f7cf6..1e567e9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # FastReseg An R package for detection and correction of cell segmentation error based on spatial profile of transcripts -#### [Manuscript](https://www.biorxiv.org/content/10.1101/2024.12.05.627051v1.abstract): +#### [Manuscript](https://www.nature.com/articles/s41598-025-08733-5): -Wu L, Beechem JM, Danaher P. FastReseg: using transcript locations to refine image-based cell segmentation results in spatial transcriptomics. *bioRxiv* 2024.12.05.627051; doi: https://doi.org/10.1101/2024.12.05.627051 +Wu, L., Beechem, J.M. & Danaher, P. Using transcripts to refine image based cell segmentation with FastReseg. Sci Rep 15, 30508 (2025). https://doi.org/10.1038/s41598-025-08733-5 ### Dev notes `FastReseg` package processes spatial transcriptome data through 5 different modules: diff --git a/_pkgdown.yml b/_pkgdown.yml index 65636bf..dbf6574 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -112,7 +112,7 @@ external-articles: title: Working principles and Manuscript description: Manuscript for FastReseg describing working principles, performance characterization and parameter impacts. - href: https://www.biorxiv.org/content/10.1101/2024.12.05.627051v1.abstract + href: https://www.nature.com/articles/s41598-025-08733-5 articles: - title: Manuscript diff --git a/man/igraph_delete_edges.Rd b/man/igraph_delete_edges.Rd index 2c2b1fd..e24816d 100644 --- a/man/igraph_delete_edges.Rd +++ b/man/igraph_delete_edges.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/group_transcripts_in_space.R +% Please edit documentation in R/other_utilities.R \name{igraph_delete_edges} \alias{igraph_delete_edges} \title{igraph_delete_edges} diff --git a/man/run_igraph_leiden.Rd b/man/run_igraph_leiden.Rd index 63d3380..2a98717 100644 --- a/man/run_igraph_leiden.Rd +++ b/man/run_igraph_leiden.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/decide_ReSegment_Operations.R +% Please edit documentation in R/other_utilities.R \name{run_igraph_leiden} \alias{run_igraph_leiden} \title{run_igraph_leiden}