diff --git a/DESCRIPTION b/DESCRIPTION index 20c0170..129fb66 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: RCon3D Title: Analysis of Confocal Images of Microbial Biofilms -Version: 1.2.5 +Version: 1.2.6 Authors@R: person("Jakob", "Russel", email = "russel2620@gmail.com", role = c("aut", "cre")) Description: Various 3D analyses of confocal images. E.g. Quantification, co-aggregation and identifying 3D aggregates. Depends: R (>= 3.2.5) @@ -21,4 +21,4 @@ Suggests: License: GPL (>= 3) | file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 6.1.1 +RoxygenNote: 7.2.1 diff --git a/R/quant.R b/R/quant.R index f57fd0c..02f6b3c 100644 --- a/R/quant.R +++ b/R/quant.R @@ -1,16 +1,17 @@ #' Quantifies the pixels in images #' -#' Quantifies the number of pixels for each channel in each layer (z-stack) +#' Quantifies the number of pixels for each channel in any direction (default z-stack) #' @param imgs The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions. #' @param channels Character vector with name(s) of channels. Channel names should be in the names of the array files #' @param naming Optional. Add metadata to the output dataframe by looking through names of array files. Should be a list of character vectors, each list element will be added as a variable. Example: naming=list(Time=c("T0","T1","T2")). The function inserts a variable called Time, and then looks through the names of the array files and inserts characters mathcing either T0, T1 or T2 #' @param cores Number of cores for parallel computing +#' @param axis Axis to aggregate over (1: x, 2: y, 3:z). Default 3 (z-axis) #' @keywords array image quantify #' @return A dataframe with number of pixels for each layer #' @import foreach doSNOW #' @export -quant <- function(imgs,channels,naming = NULL,cores = 1) { +quant <- function(imgs,channels,naming = NULL,cores = 1,axis=3) { # Loop for each channel qua.fin <- list() @@ -41,7 +42,7 @@ quant <- function(imgs,channels,naming = NULL,cores = 1) { ch_t <- readRDS(ch_files[k]) # Count for each layer - q <- apply(ch_t, 3, sum) + q <- apply(ch_t, axis, sum) # Output temp <- cbind(sub(paste0("_Array.*"),"",sub(".*/", "", ch_files[k])),channels[z],q,1:length(q)) diff --git a/man/clumps.Rd b/man/clumps.Rd index 840dd50..bbcd6e9 100644 --- a/man/clumps.Rd +++ b/man/clumps.Rd @@ -4,10 +4,22 @@ \alias{clumps} \title{Find 3D aggregates/clumps} \usage{ -clumps(imgs, channels, kern.neighbour = c(3, 3, 3), - type.neighbour = "box", kern.smooth = NULL, type.smooth = "box", - layers = NULL, pwidth = NULL, zstep = NULL, naming = NULL, - coords = FALSE, thresh = 0, points = NULL, cores = 1) +clumps( + imgs, + channels, + kern.neighbour = c(3, 3, 3), + type.neighbour = "box", + kern.smooth = NULL, + type.smooth = "box", + layers = NULL, + pwidth = NULL, + zstep = NULL, + naming = NULL, + coords = FALSE, + thresh = 0, + points = NULL, + cores = 1 +) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/clumps_dist.Rd b/man/clumps_dist.Rd index 7c0761d..d7965a5 100644 --- a/man/clumps_dist.Rd +++ b/man/clumps_dist.Rd @@ -4,8 +4,7 @@ \alias{clumps_dist} \title{Find distances between 3D aggregates/clumps} \usage{ -clumps_dist(clumps.x, clumps.y = clumps.x, pwidth = 1, zstep = 1, - cores = 1) +clumps_dist(clumps.x, clumps.y = clumps.x, pwidth = 1, zstep = 1, cores = 1) } \arguments{ \item{clumps.x}{Data.frame output from the \code{clumps} function (...$Aggregates)} diff --git a/man/clumps_plot.Rd b/man/clumps_plot.Rd index fc34ee2..3a71981 100644 --- a/man/clumps_plot.Rd +++ b/man/clumps_plot.Rd @@ -4,9 +4,17 @@ \alias{clumps_plot} \title{Plot 3D aggregates} \usage{ -clumps_plot(clumps.out, replica = 1, col = "agg", pwidth = NULL, - zstep = NULL, center = NULL, radius = NULL, thresh = 0, - thresh.m = FALSE) +clumps_plot( + clumps.out, + replica = 1, + col = "agg", + pwidth = NULL, + zstep = NULL, + center = NULL, + radius = NULL, + thresh = 0, + thresh.m = FALSE +) } \arguments{ \item{clumps.out}{Output from \code{clumps}} diff --git a/man/co_agg.Rd b/man/co_agg.Rd index 48f4692..ddf94f2 100644 --- a/man/co_agg.Rd +++ b/man/co_agg.Rd @@ -5,11 +5,34 @@ \alias{co_agg.default} \title{3D co-aggregation} \usage{ -co_agg(imgs, channels, size, npixel, R = 10, dstep = 1, pwidth, zstep, - cores = 1, kern.smooth = NULL, layers = NULL, naming = NULL) +co_agg( + imgs, + channels, + size, + npixel, + R = 10, + dstep = 1, + pwidth, + zstep, + cores = 1, + kern.smooth = NULL, + layers = NULL, + naming = NULL +) -co_agg.default(imgs, channels, size, npixel, dstep = 1, pwidth, zstep, - cores = 1, kern.smooth = NULL, layers = NULL, naming = NULL) +co_agg.default( + imgs, + channels, + size, + npixel, + dstep = 1, + pwidth, + zstep, + cores = 1, + kern.smooth = NULL, + layers = NULL, + naming = NULL +) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/cross_ratio.Rd b/man/cross_ratio.Rd index 8678aff..f9070f4 100644 --- a/man/cross_ratio.Rd +++ b/man/cross_ratio.Rd @@ -5,13 +5,36 @@ \alias{cross_ratio.default} \title{3D cross-ratio} \usage{ -cross_ratio(imgs, focal.channel, target.channels, size, npixel, R = 10, - dstep = 1, pwidth, zstep, cores = 1, kern.smooth = NULL, - layers = NULL, naming = NULL) +cross_ratio( + imgs, + focal.channel, + target.channels, + size, + npixel, + R = 10, + dstep = 1, + pwidth, + zstep, + cores = 1, + kern.smooth = NULL, + layers = NULL, + naming = NULL +) -cross_ratio.default(imgs, focal.channel, target.channels, size, npixel, - dstep = 1, pwidth, zstep, cores = 1, kern.smooth = NULL, - layers = NULL, naming = NULL) +cross_ratio.default( + imgs, + focal.channel, + target.channels, + size, + npixel, + dstep = 1, + pwidth, + zstep, + cores = 1, + kern.smooth = NULL, + layers = NULL, + naming = NULL +) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/layer_split.Rd b/man/layer_split.Rd index 44dbaeb..36ecff8 100644 --- a/man/layer_split.Rd +++ b/man/layer_split.Rd @@ -4,8 +4,17 @@ \alias{layer_split} \title{Split quantification in Top, Middle and Bottom} \usage{ -layer_split(qua, side.x, side.y, pt, add.t, add.b, channel = NULL, - trim = FALSE, layer.start = NULL) +layer_split( + qua, + side.x, + side.y, + pt, + add.t, + add.b, + channel = NULL, + trim = FALSE, + layer.start = NULL +) } \arguments{ \item{qua}{A dataframe from the \code{quant} function} diff --git a/man/loadIMG.Rd b/man/loadIMG.Rd index c91b136..c510ca4 100644 --- a/man/loadIMG.Rd +++ b/man/loadIMG.Rd @@ -4,8 +4,7 @@ \alias{loadIMG} \title{Load .tif images into R} \usage{ -loadIMG(path, channels, split = FALSE, multi = NULL, - multi.name = NULL) +loadIMG(path, channels, split = FALSE, multi = NULL, multi.name = NULL) } \arguments{ \item{path}{The path of either a folder with all .tif files to be loaded (if split=FALSE), or a folder where each image is in a separate subfolder with all z-stacks and channels in that folder (if split=TRUE)} diff --git a/man/morphIMG.Rd b/man/morphIMG.Rd index 9c4b8d7..1b781fd 100644 --- a/man/morphIMG.Rd +++ b/man/morphIMG.Rd @@ -4,8 +4,7 @@ \alias{morphIMG} \title{Apply mathematical morphology kernel on image and save as RDS} \usage{ -morphIMG(imgs, morph = NULL, kern = c(3, 3, 3), type = "box", - cores = 1) +morphIMG(imgs, morph = NULL, kern = c(3, 3, 3), type = "box", cores = 1) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/occupancy.Rd b/man/occupancy.Rd index 23544a0..622e567 100644 --- a/man/occupancy.Rd +++ b/man/occupancy.Rd @@ -5,13 +5,36 @@ \alias{occupancy.default} \title{3D Occupancy} \usage{ -occupancy(imgs, focal.channel, target.channel, size, npixel, R = 10, - dstep = 1, pwidth, zstep, cores = 1, kern.smooth = NULL, - layers = NULL, naming = NULL) +occupancy( + imgs, + focal.channel, + target.channel, + size, + npixel, + R = 10, + dstep = 1, + pwidth, + zstep, + cores = 1, + kern.smooth = NULL, + layers = NULL, + naming = NULL +) -occupancy.default(imgs, focal.channel, target.channel, size, npixel, - dstep = 1, pwidth, zstep, cores = 1, kern.smooth = NULL, - layers = NULL, naming = NULL) +occupancy.default( + imgs, + focal.channel, + target.channel, + size, + npixel, + dstep = 1, + pwidth, + zstep, + cores = 1, + kern.smooth = NULL, + layers = NULL, + naming = NULL +) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/quant.Rd b/man/quant.Rd index 581fec3..de17c41 100644 --- a/man/quant.Rd +++ b/man/quant.Rd @@ -4,7 +4,7 @@ \alias{quant} \title{Quantifies the pixels in images} \usage{ -quant(imgs, channels, naming = NULL, cores = 1) +quant(imgs, channels, naming = NULL, cores = 1, axis = 3) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} @@ -14,12 +14,14 @@ quant(imgs, channels, naming = NULL, cores = 1) \item{naming}{Optional. Add metadata to the output dataframe by looking through names of array files. Should be a list of character vectors, each list element will be added as a variable. Example: naming=list(Time=c("T0","T1","T2")). The function inserts a variable called Time, and then looks through the names of the array files and inserts characters mathcing either T0, T1 or T2} \item{cores}{Number of cores for parallel computing} + +\item{axis}{Axis to aggregate over (1: x, 2: y, 3:z). Default 3 (z-axis)} } \value{ A dataframe with number of pixels for each layer } \description{ -Quantifies the number of pixels for each channel in each layer (z-stack) +Quantifies the number of pixels for each channel in any direction (default z-stack) } \keyword{array} \keyword{image} diff --git a/man/smoothIMG.Rd b/man/smoothIMG.Rd index 6f95648..bda833f 100644 --- a/man/smoothIMG.Rd +++ b/man/smoothIMG.Rd @@ -4,8 +4,7 @@ \alias{smoothIMG} \title{Median smooth image and save as RDS} \usage{ -smoothIMG(imgs, kern.smooth = c(3, 3, 3), type.smooth = "box", - cores = 1) +smoothIMG(imgs, kern.smooth = c(3, 3, 3), type.smooth = "box", cores = 1) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/threshIMG.Rd b/man/threshIMG.Rd index 1778eb3..7fff3e3 100644 --- a/man/threshIMG.Rd +++ b/man/threshIMG.Rd @@ -4,10 +4,16 @@ \alias{threshIMG} \title{Apply thresholding on image and save as RDS} \usage{ -threshIMG(imgs, method = "Manual", cores = 1, breaks = 100, - opt = 0.1, thresh = rep(0, length(imgs)), BEM.opt = list(start = - list(a = -1e+06, b = 0.1, c = 1e+06), control = nls.lm.control(maxiter = - 1000))) +threshIMG( + imgs, + method = "Manual", + cores = 1, + breaks = 100, + opt = 0.1, + thresh = rep(0, length(imgs)), + BEM.opt = list(start = list(a = -1e+06, b = 0.1, c = 1e+06), control = + nls.lm.control(maxiter = 1000)) +) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.} diff --git a/man/xy_splits.Rd b/man/xy_splits.Rd index 0b1dc9c..d714cdb 100644 --- a/man/xy_splits.Rd +++ b/man/xy_splits.Rd @@ -4,8 +4,7 @@ \alias{xy_splits} \title{Analyses for each xy position} \usage{ -xy_splits(imgs, channels, do, upper.part = 0.5, layer.start = NULL, - cores = 1) +xy_splits(imgs, channels, do, upper.part = 0.5, layer.start = NULL, cores = 1) } \arguments{ \item{imgs}{The paths of array files; i.e. output from \code{loadIMG} or \code{findIMG} functions.}