From 767ea23c903f75e87aacc2de46fa827b55c652f7 Mon Sep 17 00:00:00 2001 From: paoloinglese Date: Sun, 14 Apr 2024 18:18:15 +0100 Subject: [PATCH] 1.4.2 --- DESCRIPTION | 19 +++++++++---------- R/continuous_refimg.R | 4 +++- R/examples/msImage_plot.R | 13 ++++++++----- R/filter_csr.R | 1 + R/filter_global.R | 2 +- R/filter_split.R | 2 ++ R/msi.dataset_methods.R | 8 +++++--- R/sparseness_funcs.R | 2 ++ inst/CITATION | 2 +- man/CSRPeaksFilter.Rd | 3 +++ man/PCAImage-msi.dataset-method.Rd | 5 ++++- man/globalPeaksFilter.Rd | 2 +- man/plot.Rd | 13 ++++++++----- man/refImageContinuous.Rd | 5 ++++- man/scatter.ratio.Rd | 3 +++ man/splitPeaksFilter.Rd | 3 +++ 16 files changed, 58 insertions(+), 29 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a791fac..edce8ca 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,21 +1,20 @@ Package: SPUTNIK Type: Package -Title: Spatially automatic denoising for Ims toolkit +Title: Spatially Automatic Denoising for Imaging Mass Spectrometry Toolkit Version: 1.4.2 Author: Paolo Inglese [aut, cre], Goncalo Correia [aut, ctb] Maintainer: Paolo Inglese -Authors@R: c(person("Paolo", "Inglese", email = "p.inglese@outlook.com", role = c("aut", "cre")), - person("Goncalo", "Correia", role = c("aut", "ctb"))) -Description: A set of tools for the peak filtering of mass spectrometry - imaging data (MSI or IMS) based on spatial distribution of signal. Given a - region-of-interest (ROI), representing the spatial region where the informative +Authors@R: c(person("Paolo", "Inglese", email = "p.inglese@outlook.com", + role = c("aut", "cre")), person("Goncalo", "Correia", role = c("aut", "ctb"))) +Description: Set of tools for peak filtering of mass spectrometry + imaging data based on spatial distribution of signal. Given a + region-of-interest, representing the spatial region where the informative signal is expected to be localized, a series of filters determine which peak signals are characterized by an implausible spatial distribution. The filters - reduce the dataset dimensionality and increase its information vs noise ratio, + reduce the dataset dimension and increase its information vs noise ratio, improving the quality of the unsupervised analysis results, reducing data - dimensionality and simplifying the chemical interpretation. - "SPUTNIK: an R package for filtering of spatially related peaks in mass - spectrometry imaging data" + dimension and simplifying the chemical interpretation. + The methods are described in Inglese P. et al (2019) . Depends: R (>= 3.4.0) License: GPL (>= 3) Encoding: UTF-8 diff --git a/R/continuous_refimg.R b/R/continuous_refimg.R index 53c7930..605b9c0 100644 --- a/R/continuous_refimg.R +++ b/R/continuous_refimg.R @@ -34,6 +34,8 @@ #' has negative correlation with the selected image in \code{alignTo}. #' @param verbose logical (default = TRUE). Additional output text. #' +#' @return A continuous valued reference image (see \link{msImage}). +#' #' @details Function to extract the continuous reference image from a #' \code{\link{msi.dataset-class}} object. #' The continuous reference image represents the spatial location of the sample. @@ -46,7 +48,7 @@ #' #' @example R/examples/graph_funcs.R #' -#' @seealso msiDataset +#' @seealso msiDataset, msImage #' @export #' refImageContinuous <- function(msiData, diff --git a/R/examples/msImage_plot.R b/R/examples/msImage_plot.R index a848dcc..7205a2e 100644 --- a/R/examples/msImage_plot.R +++ b/R/examples/msImage_plot.R @@ -1,8 +1,11 @@ ## Load package -library("SPUTNIK") -## Create ms.image-class object -msIm <- msImage(values = matrix(rnorm(200), 40, 50), name = "test", scale = TRUE) +\donttest{ + library("SPUTNIK") -## Plot the image -## plot(msIm) + ## Create ms.image-class object + msIm <- msImage(values = matrix(rnorm(200), 40, 50), name = "test", scale = TRUE) + + ## Plot the image + plot(msIm) +} diff --git a/R/filter_csr.R b/R/filter_csr.R index d9910ad..0fedb67 100644 --- a/R/filter_csr.R +++ b/R/filter_csr.R @@ -34,6 +34,7 @@ #' @param ... additional parameters compatible with the \code{statspat.core} functions. #' See \link[spatstat.explore]{cdf.test} for "KS" and \link[spatstat.explore]{clarkevans.test}. #' for "ClarkEvans" +#' @return List of the p-values and adjusted p-values for the CSR test. #' #' @author Paolo Inglese \email{p.inglese14@imperial.ac.uk} #' diff --git a/R/filter_global.R b/R/filter_global.R index f21ef5b..76fa96b 100644 --- a/R/filter_global.R +++ b/R/filter_global.R @@ -23,7 +23,7 @@ #' @param cores integer (default = 1). Number of cores for parallel computing. #' @param verbose logical (default = \code{TRUE}). Additional output text. #' -#' @return \code{peak.filter} object. See link{applyPeaksFilter}. +#' @return \code{peak.filter} object. See \link{applyPeaksFilter}. #' #' @details A filter based on the similarity between the peak signals and a reference #' signal. The reference signal, passed as an \code{\link{ms.image-class}} object. diff --git a/R/filter_split.R b/R/filter_split.R index aa509d9..934d5ef 100644 --- a/R/filter_split.R +++ b/R/filter_split.R @@ -56,6 +56,8 @@ #' \item the merged peaks image should be more structured than the single #' peak images, accordingly to the selected \code{sparseness}. #' } +#' +#' @return \code{peak.filter} object. See \link{applyPeaksFilter}. #' #' @author Paolo Inglese \email{p.inglese14@imperial.ac.uk} #' diff --git a/R/msi.dataset_methods.R b/R/msi.dataset_methods.R index 5994bc1..4c5e19b 100644 --- a/R/msi.dataset_methods.R +++ b/R/msi.dataset_methods.R @@ -60,8 +60,10 @@ if (is.null(getGeneric('PCAImage'))) { #' @param object \link{msi.dataset-class} object. #' @param alignToSample boolean (default = TRUE). If TRUE, the principal component #' scores are aligned to the pixel mean intensity. +#' @param seed set the random seed (default = \code{NULL}). #' #' @return RGB raster representing the first 3 principal components +#' (see \link{msImage}). #' #' @importFrom grDevices rgb #' @import irlba @@ -72,8 +74,8 @@ if (is.null(getGeneric('PCAImage'))) { setMethod( f = "PCAImage", signature = signature(object = "msi.dataset"), - definition = function(object, alignToSample = TRUE) { - set.seed(123) + definition = function(object, alignToSample = TRUE, seed = NULL) { + set.seed(seed) pca <- prcomp_irlba(object@matrix, center = TRUE, scale. = TRUE, n = 3,) if (alignToSample) { if (cor(apply(object@matrix, 1, mean), pca$x[, 1]) < 0) { @@ -83,7 +85,7 @@ setMethod( colors <- apply(pca$x, 2, function(x) (x - min(x)) / (max(x) - min(x))) colors <- rgb(colors[, 1], colors[, 2], colors[, 3]) colors <- matrix(colors, object@nrow, object@ncol) - return (msImage(values = colors, name = 'PCA', scale = FALSE)) + return(msImage(values = colors, name = 'PCA', scale = FALSE)) } ) diff --git a/R/sparseness_funcs.R b/R/sparseness_funcs.R index ddc60d9..fc8649d 100644 --- a/R/sparseness_funcs.R +++ b/R/sparseness_funcs.R @@ -7,6 +7,8 @@ #' #' @param im 2-D numeric matrix representing the image pixel intensities. #' +#' @return calculated scatter ratio. +#' #' @references Otsu, N. (1979). A threshold selection method from gray-level #' histograms. IEEE transactions on systems, man, and cybernetics, 9(1), 62-66. #' diff --git a/inst/CITATION b/inst/CITATION index b860364..7f9a31a 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -7,5 +7,5 @@ bibentry( volume = "36", number = "1", pages = "178-180", - doi = "https://doi.org/10.1093/bioinformatics/bty622" + url = "https://doi.org/10.1093/bioinformatics/bty622" ) diff --git a/man/CSRPeaksFilter.Rd b/man/CSRPeaksFilter.Rd index 5d49581..b537d52 100644 --- a/man/CSRPeaksFilter.Rd +++ b/man/CSRPeaksFilter.Rd @@ -52,6 +52,9 @@ generated.} See \link[spatstat.explore]{cdf.test} for "KS" and \link[spatstat.explore]{clarkevans.test}. for "ClarkEvans"} } +\value{ +List of the p-values and adjusted p-values for the CSR test. +} \description{ \code{CSRPeaksFilter} returns the significance for the null hypothesis that the spatial distribution of the peak intensities follow a random pattern. A diff --git a/man/PCAImage-msi.dataset-method.Rd b/man/PCAImage-msi.dataset-method.Rd index bd79c04..fbe7fc0 100644 --- a/man/PCAImage-msi.dataset-method.Rd +++ b/man/PCAImage-msi.dataset-method.Rd @@ -7,16 +7,19 @@ image can be used to qualitatively evaluate the spatial heterogeneity of the sample.} \usage{ -\S4method{PCAImage}{msi.dataset}(object, alignToSample = TRUE) +\S4method{PCAImage}{msi.dataset}(object, alignToSample = TRUE, seed = NULL) } \arguments{ \item{object}{\link{msi.dataset-class} object.} \item{alignToSample}{boolean (default = TRUE). If TRUE, the principal component scores are aligned to the pixel mean intensity.} + +\item{seed}{set the random seed (default = \code{NULL}).} } \value{ RGB raster representing the first 3 principal components +(see \link{msImage}). } \description{ Generates an RGB msImage representing the first 3 principal components. This diff --git a/man/globalPeaksFilter.Rd b/man/globalPeaksFilter.Rd index 7d9e82f..36a9c10 100644 --- a/man/globalPeaksFilter.Rd +++ b/man/globalPeaksFilter.Rd @@ -40,7 +40,7 @@ scaled in [-1, 1] to match the same range of correlations.} \item{verbose}{logical (default = \code{TRUE}). Additional output text.} } \value{ -\code{peak.filter} object. See link{applyPeaksFilter}. +\code{peak.filter} object. See \link{applyPeaksFilter}. } \description{ \code{globalPeaksFilter} returns a list of peaks selected by their similarity diff --git a/man/plot.Rd b/man/plot.Rd index 63eb2bf..7838432 100644 --- a/man/plot.Rd +++ b/man/plot.Rd @@ -22,11 +22,14 @@ Visualize an MS image. } \examples{ ## Load package -library("SPUTNIK") -## Create ms.image-class object -msIm <- msImage(values = matrix(rnorm(200), 40, 50), name = "test", scale = TRUE) +\donttest{ + library("SPUTNIK") -## Plot the image -## plot(msIm) + ## Create ms.image-class object + msIm <- msImage(values = matrix(rnorm(200), 40, 50), name = "test", scale = TRUE) + + ## Plot the image + plot(msIm) +} } diff --git a/man/refImageContinuous.Rd b/man/refImageContinuous.Rd index 984f20f..bbba608 100644 --- a/man/refImageContinuous.Rd +++ b/man/refImageContinuous.Rd @@ -60,6 +60,9 @@ has negative correlation with the selected image in \code{alignTo}.} \item{verbose}{logical (default = TRUE). Additional output text.} } +\value{ +A continuous valued reference image (see \link{msImage}). +} \description{ \code{refImageContinuous} returns the reference image, calculated using the \code{method}. @@ -110,5 +113,5 @@ roiImg <- refImageBinaryOtsu(refImg) ## plot(ref.roi$ROI) } \seealso{ -msiDataset +msiDataset, msImage } diff --git a/man/scatter.ratio.Rd b/man/scatter.ratio.Rd index 40485d8..5766a00 100644 --- a/man/scatter.ratio.Rd +++ b/man/scatter.ratio.Rd @@ -9,6 +9,9 @@ scatter.ratio(im) \arguments{ \item{im}{2-D numeric matrix representing the image pixel intensities.} } +\value{ +calculated scatter ratio. +} \description{ \code{scatter.ratio} returns a measure of image scatteredness represented by the ratio between the number of connected components and the total number of diff --git a/man/splitPeaksFilter.Rd b/man/splitPeaksFilter.Rd index 42f24f7..81c4333 100644 --- a/man/splitPeaksFilter.Rd +++ b/man/splitPeaksFilter.Rd @@ -36,6 +36,9 @@ in the results.} \item{verbose}{logical (default = \code{TRUE}). Additional output text.} } +\value{ +\code{peak.filter} object. See \link{applyPeaksFilter}. +} \description{ \link{splitPeaksFilter} returns a list of estimated split peak indices. Each element of the list contains an array of the original peak indices that can