| Title: | Miscellaneous tools for image analysis tasks |
|---|---|
| Description: | A miscellaneous toolbox for various image analysis tasks. Initially contains tools for downstream analysis of my ImageJ plugin Puncta Tracker and hence the ij name. Part of the y3628 analysis suite. |
| Authors: | Ye Yuan [aut, cre] (ORCID: <https://orcid.org/0000-0001-9641-9102>) |
| Maintainer: | Ye Yuan <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.4 |
| Built: | 2026-05-20 07:38:20 UTC |
| Source: | https://github.com/yeyuan98/ijAnalysis |
Parse spot array JSON data to metaRcrd.
.parse_meta(ser.coord, ser.dist).parse_meta(ser.coord, ser.dist)
ser.coord |
Serialized coord. |
ser.dist |
Serialized dist. |
A y3628::metaRcrd object.
# Does not apply. Internal use only.# Does not apply. Internal use only.
Get index for spotInRoi nuclear/full-cell data subsetting.
.selectNCT.index(dfNucCyt, what).selectNCT.index(dfNucCyt, what)
dfNucCyt |
Parsed spotInRoi nuclear/full-cell data. |
what |
What to subset. must be |
Indices for subsetting.
# Does not apply. Internal use only.# Does not apply. Internal use only.
Load behavior activity data from metadata
actogram_loadFromMetadata(path, data_dir = "./", ...)actogram_loadFromMetadata(path, data_dir = "./", ...)
path |
Path to metadata, must be commonly used delimited or excel. |
data_dir |
Path to the behavior data dir. |
... |
These dots are for future extensions and must be empty. |
behavr::behavr behavior data table.
# TODO# TODO
Plotting actogram
actogram_plot( behavr, file = NULL, file.options = list(device = tools::file_ext(file), height = 9.14, width = 10.6) )actogram_plot( behavr, file = NULL, file.options = list(device = tools::file_ext(file), height = 9.14, width = 10.6) )
behavr |
|
file |
Optional path to save the plot. Backend is |
file.options |
List to specify options for saving the plot. |
ggplot plot object.
# TODO# TODO
Load behavior metadata
behavior_loadMetadata(path)behavior_loadMetadata(path)
path |
Path to metadata file. See body for column spec. |
Metadata tibble.
# Not exported.# Not exported.
This is de facto the versatile X-Y plot generator of this package. Supports multiple plot templates.
ctcf_plot(data, x, y, fill = NA, template = "boxPoint")ctcf_plot(data, x, y, fill = NA, template = "boxPoint")
data |
tibble of CTCF data |
x |
x-axis variable for plotting |
y |
y-axis variable for plotting |
fill |
fill variable for plotting |
template |
which template to use, see details. |
All possible templates are not exported functions plot. in this package.
Supported ones are:
"linePoint" - uses plot.linePoint() - point plot with summary line
"boxPoint" - uses plot.boxPoint() - point plot with box
ggplot object
# Will warn about the `am` continuous color variable ctcf_plot(mtcars, cyl, mpg, am, template = "linePoint") # Will create a boxPoint plot. Note that for boxPoint X must be discrete. ctcf_plot( mtcars |> dplyr::mutate(gear = as.character(gear), am = as.character(am)), am, mpg, gear)# Will warn about the `am` continuous color variable ctcf_plot(mtcars, cyl, mpg, am, template = "linePoint") # Will create a boxPoint plot. Note that for boxPoint X must be discrete. ctcf_plot( mtcars |> dplyr::mutate(gear = as.character(gear), am = as.character(am)), am, mpg, gear)
Read CTCF results table
ctcf_read_csv(path, ...)ctcf_read_csv(path, ...)
path |
Path to the CTCF analysis csv |
... |
Forwarded to |
tibble of CTCF table
#TODO#TODO
Compute NND metrics for a pair of spot sets.
ij_nnd.compute(foreach, to, z.proximal)ij_nnd.compute(foreach, to, z.proximal)
foreach |
For each spot in |
to |
compute its distance to the nearest neighbor in |
z.proximal |
Only spots in close enough z-proximity is computed. |
y3628::metaRcrd object storing the NND results. For spots that have
no Z-proximal spots in the to spot set, NAs are returned.
# TODO# TODO
Initialize an ImageJ ROI point set saver function
ij_RoiPointsSaver(use_python)ij_RoiPointsSaver(use_python)
use_python |
Path to the Python binary to use. |
A ROI saver function.
# TODO# TODO
jtk.init
Initialize the JTK environment for all periods
jtk.init(periods, interval = 1)jtk.init(periods, interval = 1)
periods |
Periods to test on (in units of spacing |
interval |
Spacing of time points (in physical unit like hours). For example, |
None; Run only for side effects on JTK_env.
# Refer to the JTK Cycle guide.# Refer to the JTK Cycle guide.
jtkdist
JTK Cycle V3.1 Adaptation jtkdist
jtkdist(timepoints, reps = 1, normal = FALSE, alt = FALSE)jtkdist(timepoints, reps = 1, normal = FALSE, alt = FALSE)
timepoints |
Number of time points in the data. |
reps |
Number of replicates for each time point. |
normal |
Not used. Refer to JTK Cycle paper. |
alt |
Not used. Refer to JTK Cycle paper. |
Not used. Refer to JTK Cycle paper.
# Refer to the JTK Cycle guide.# Refer to the JTK Cycle guide.
This is getter function to fetch computation results of jtkx.
jtkget(get.AMP.CI = FALSE)jtkget(get.AMP.CI = FALSE)
get.AMP.CI |
Bool, whether to get amplitude confidence interval, which will be length=2 numeric vector. |
In this adaptation, jtkx results are stored internally in a package
environment JTK_env. This function is a getter of the enrivonment.
Named numeric vector of current jtkx results stored in JTK_env.
If get.AMP.CI==TRUE, only return the amplitude confidence interval.
# Refer to the JTK Cycle guide.# Refer to the JTK Cycle guide.
jtkstat
jtkstat: calculate the p-values for all (period,phase) combos. v3.1 modified to analyze data with missing values.
jtkstat(z)jtkstat(z)
z |
Numeric vector of data at each time point. |
None; Run only for side effects on JTK_env.
# Internal use by `jtkx` only.# Internal use by `jtkx` only.
jtkx
jtkx: integration of jtkstat and jtkdist for repeated use.
jtkx(z, ampci = FALSE, conf = 0.8)jtkx(z, ampci = FALSE, conf = 0.8)
z |
Numeric vector of data at each time point. |
ampci |
Boolean, whether to compute amplitude CI and p-value. |
conf |
Confidence level of amplitude. Only useful if |
None; Run only for side effects on JTK_env.
# Refer to the JTK Cycle guide.# Refer to the JTK Cycle guide.
nls() fitting of multiple groupsnls() fitting of multiple groups
nlsGroup(.data, var.group, formula, ...)nlsGroup(.data, var.group, formula, ...)
.data |
data.frame with variables to fit with additional group variables. |
var.group |
group variables. Follow |
formula |
Formula to run |
... |
Additional parameters forwarded to |
Data frame of fitting parameters, with group variables.
# Puromycin, self-starting SSmicmen kinetics nlsGroup(Puromycin, state, rate~SSmicmen(conc,Vm,K)) # Custom formula. Must provide start values. michaelis_menten <- rate ~ (Vm)*conc/(K+conc) nlsGroup(Puromycin, state, michaelis_menten, start=list(Vm=100,K=0.01))# Puromycin, self-starting SSmicmen kinetics nlsGroup(Puromycin, state, rate~SSmicmen(conc,Vm,K)) # Custom formula. Must provide start values. michaelis_menten <- rate ~ (Vm)*conc/(K+conc) nlsGroup(Puromycin, state, michaelis_menten, start=list(Vm=100,K=0.01))
Order permutation for a NND result record
nnd.order(nnd.results, ...)nnd.order(nnd.results, ...)
nnd.results |
|
... |
Passed to |
Order permutation using the nnd field.
# Does not apply. Internal use only.# Does not apply. Internal use only.
Load Clocklab periodogram batch export table
periodogram_loadClocklab(data, meta, ...)periodogram_loadClocklab(data, meta, ...)
data |
Path to the Clocklab periodogram csv export file. |
meta |
Path to the metadata file. |
... |
These dots are for future extensions and must be empty. |
Periodogram table with metadata columns
# TODO# TODO
Simple wrapper of ggsave for saving plots.
plot_ggsave( plots = list(), widths, heights, units = "in", dir = "plots_eps", ... )plot_ggsave( plots = list(), widths, heights, units = "in", dir = "plots_eps", ... )
plots |
Named list of plots to save. |
widths |
Width of the plots. Either length one or same as plots. |
heights |
Height of the plots. Either length one or same as plots. |
units |
Unit of width and height |
dir |
Directory under which to save the plot |
... |
These dots are for future extensions and must be empty. |
# TODO# TODO
Boxplot with data points
## S3 method for class 'boxPoint' plot(data, x, y, fill, theme = "classic")## S3 method for class 'boxPoint' plot(data, x, y, fill, theme = "classic")
data |
Data |
x |
x, must be already quoted |
y |
y, must be already quoted |
fill |
fill, must be already quoted |
theme |
what theme to apply, see |
ggplot object
# Internal use# Internal use
If color not specified or equal to x, whole data will be one color.
## S3 method for class 'linePoint' plot( data, x, y, color = NA, theme = "classic", mean_func = mean, sd_func = function(x) stats::sd(x)/sqrt(length(x)) )## S3 method for class 'linePoint' plot( data, x, y, color = NA, theme = "classic", mean_func = mean, sd_func = function(x) stats::sd(x)/sqrt(length(x)) )
data |
Data |
x |
x, must be already quoted |
y |
y, must be already quoted |
color |
color, must be already quoted |
theme |
what theme to apply, see |
mean_func |
function to compute 'mean' (sample representative value) |
sd_func |
function to compute 'sd' (sample spread) |
ggplot object
# Internal use# Internal use
Themes used by different plots in this package for standardized behavior.
## S3 method for class 'themes' plot(type = "classic")## S3 method for class 'themes' plot(type = "classic")
type |
standardized theme name, see details. |
Implemented themes:
classic: Based on ggplot2::theme_classic().
GG theme object.
# Internal use# Internal use
Count number of dots per cell
rfish_count(samples, dots, by = c("sample", "image"), ...)rfish_count(samples, dots, by = c("sample", "image"), ...)
samples |
tibble of samples table, |
dots |
tibble of dots table, |
by |
group by which variables before counting |
... |
< |
Count table (number of dots per cell).
# TODO# TODO
Read dots table from snakemake pipeline output
rfish_read_dots(path, ...)rfish_read_dots(path, ...)
path |
Path to the dots csv |
... |
Forwarded to |
tibble of dots table
#TODO#TODO
Read samples table from snakemake pipeline output
rfish_read_samples(path, ...)rfish_read_samples(path, ...)
path |
Path to the samples excel. |
... |
Forwarded to |
tibble of samples table
#TODO#TODO
Add metadata column to spotInRoi data
spotInRoi_addMeta(df, idMap, meta, ...)spotInRoi_addMeta(df, idMap, meta, ...)
df |
spotInRoi table, see details. |
idMap |
identifier map table, see details. |
meta |
metadata table. |
... |
< |
spotInRoi data here takes a generalized meaning - a data frame with two id columns $tp, $meas, plus any number of additional columns.
The identifier map table must contain two id columns $tp, $meas, plus additional columns that are identifiers in the metadata table.
spotInRoi data with the specified metadata columns.
# TODO# TODO
Expand NND results as data frame entries
spotInRoi_as.data.frame.df.nnd(df.nnd, nnd.column = "result")spotInRoi_as.data.frame.df.nnd(df.nnd, nnd.column = "result")
df.nnd |
Data frame with a NND result column |
nnd.column |
Character name of the column that stores NND results. |
Expanded data frame with each NND value as one row
# TODO# TODO
Join spotInRoi data with metadata columns
spotInRoi_joinMeta(df, df.meta, by, ...)spotInRoi_joinMeta(df, df.meta, by, ...)
df |
spotInRoi data frame. |
df.meta |
metadata data frame. |
by |
columns to perform join |
... |
< |
spotInRoi data frame joined with metadata.
# Not exported# Not exported
Sort spotInRoi data based on NND results
spotInRoi_nnd.sort(df.nnd, nnd.column = "result", ...)spotInRoi_nnd.sort(df.nnd, nnd.column = "result", ...)
df.nnd |
spotInRoi data with NND results. |
nnd.column |
Character name of the column that stores NND results. |
... |
Passed to |
Sorted spotInRoi results.
# TODO# TODO
Read data for spotInRoi analysis of the Puncta Tracker ImageJ plugin.
spotInRoi_read_csv(file, parse.spotOut = FALSE, ...)spotInRoi_read_csv(file, parse.spotOut = FALSE, ...)
file |
File passed to |
parse.spotOut |
Whether to parse spotOut array data. |
... |
Other parameters passed to |
tibble of the spotInRoi analysis result.
# TODO# TODO
Predefined subsetting of spotInRoi nuclear/full-cell data.
spotInRoi_selectNCT(dfNucCyt, what)spotInRoi_selectNCT(dfNucCyt, what)
dfNucCyt |
Parsed spotInRoi nuclear/full-cell data. |
what |
What to subset. must be |
Subsetted spotInRoi nuclear/full-cell data.
Predefined subsetting rules are as follows:
nuclear - for each cell select the ROI with the smallest equi.D
full - for each cell select the ROI with the largest equi.D
cytoplasm - currently not implemented and will error.
# TODO# TODO
behavr::behavr behavior tablesSimple subset of behavr::behavr behavior tables
subset_behavr(behavr, expr)subset_behavr(behavr, expr)
behavr |
Behavior table to subset |
expr |
An expression that evaluates to logical. See details. |
Right now the subsetting creates an intermediate logical vector, which can be very large.
Subsetted behavior table.
# Not exported# Not exported