Package 'ijAnalysis'

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]
Maintainer: Ye Yuan <[email protected]>
License: GPL (>= 3)
Version: 0.0.4
Built: 2025-02-13 04:40:40 UTC
Source: https://github.com/yeyuan98/ijAnalysis

Help Index


Parse spot array JSON data to metaRcrd.

Description

Parse spot array JSON data to metaRcrd.

Usage

.parse_meta(ser.coord, ser.dist)

Arguments

ser.coord

Serialized coord.

ser.dist

Serialized dist.

Value

A y3628::metaRcrd object.

Examples

# Does not apply. Internal use only.

Get index for spotInRoi nuclear/full-cell data subsetting.

Description

Get index for spotInRoi nuclear/full-cell data subsetting.

Usage

.selectNCT.index(dfNucCyt, what)

Arguments

dfNucCyt

Parsed spotInRoi nuclear/full-cell data.

what

What to subset. must be nuclear, cytoplasm, or full.

Value

Indices for subsetting.

Examples

# Does not apply. Internal use only.

Load behavior activity data from metadata

Description

Load behavior activity data from metadata

Usage

actogram_loadFromMetadata(path, data_dir = "./", ...)

Arguments

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.

Value

behavr::behavr behavior data table.

Examples

# TODO

Plotting actogram

Description

Plotting actogram

Usage

actogram_plot(
  behavr,
  file = NULL,
  file.options = list(device = tools::file_ext(file), height = 9.14, width = 10.6)
)

Arguments

behavr

behavr::behavr behavior data table.

file

Optional path to save the plot. Backend is ggplot2::ggsave().

file.options

List to specify options for saving the plot.

Value

ggplot plot object.

Examples

# TODO

Load behavior metadata

Description

Load behavior metadata

Usage

behavior_loadMetadata(path)

Arguments

path

Path to metadata file. See body for column spec.

Value

Metadata tibble.

Examples

# Not exported.

Standardized plotting of CTCF data

Description

Standardized plotting of CTCF data

Usage

ctcf_plot(data, x, y, fill = NA)

Arguments

data

tibble of CTCF data

x

x-axis variable for plotting

y

y-axis variable for plotting

fill

fill variable for plotting

Value

ggplot object

Examples

# TODO

Read CTCF results table

Description

Read CTCF results table

Usage

ctcf_read_csv(path, ...)

Arguments

path

Path to the CTCF analysis csv

...

Forwarded to readr::read_csv

Value

tibble of CTCF table

Examples

#TODO

Compute NND metrics for a pair of spot sets.

Description

Compute NND metrics for a pair of spot sets.

Usage

ij_nnd.compute(foreach, to, z.proximal)

Arguments

foreach

For each spot in foreach,

to

compute its distance to the nearest neighbor in to spot set.

z.proximal

Only spots in close enough z-proximity is computed.

Value

y3628::metaRcrd object storing the NND results. For spots that have no Z-proximal spots in the to spot set, NAs are returned.

Examples

# TODO

Initialize an ImageJ ROI point set saver function

Description

Initialize an ImageJ ROI point set saver function

Usage

ij_RoiPointsSaver(use_python)

Arguments

use_python

Path to the Python binary to use.

Value

A ROI saver function.

Examples

# TODO

JTK Cycle V3.1 Adaptation jtk.init

Description

Initialize the JTK environment for all periods

Usage

jtk.init(periods, interval = 1)

Arguments

periods

Periods to test on (in units of spacing interval).

interval

Spacing of time points (in physical unit like hours).

For example, jtk.init(9:15, 2) means that data time point spacing is 2-hour and possible periods would be 18-hour to 30-hour (2-hour spacing).

Value

None; Run only for side effects on JTK_env.

Examples

# Refer to the JTK Cycle guide.

JTK Cycle V3.1 Adaptation jtkdist

Description

JTK Cycle V3.1 Adaptation jtkdist

Usage

jtkdist(timepoints, reps = 1, normal = FALSE, alt = FALSE)

Arguments

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.

Value

Not used. Refer to JTK Cycle paper.

Examples

# Refer to the JTK Cycle guide.

JTK Cycle V3.1 Adaptation

Description

This is getter function to fetch computation results of jtkx.

Usage

jtkget(get.AMP.CI = FALSE)

Arguments

get.AMP.CI

Bool, whether to get amplitude confidence interval, which will be length=2 numeric vector.

Details

In this adaptation, jtkx results are stored internally in a package environment JTK_env. This function is a getter of the enrivonment.

Value

Named numeric vector of current jtkx results stored in JTK_env. If get.AMP.CI==TRUE, only return the amplitude confidence interval.

Examples

# Refer to the JTK Cycle guide.

JTK Cycle V3.1 Adaptation jtkstat

Description

jtkstat: calculate the p-values for all (period,phase) combos. v3.1 modified to analyze data with missing values.

Usage

jtkstat(z)

Arguments

z

Numeric vector of data at each time point.

Value

None; Run only for side effects on JTK_env.

Examples

# Internal use by `jtkx` only.

JTK Cycle V3.1 Adaptation jtkx

Description

jtkx: integration of jtkstat and jtkdist for repeated use.

Usage

jtkx(z, ampci = FALSE, conf = 0.8)

Arguments

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 ampci == TRUE.

Value

None; Run only for side effects on JTK_env.

Examples

# Refer to the JTK Cycle guide.

nls() fitting of multiple groups

Description

nls() fitting of multiple groups

Usage

nlsGroup(.data, var.group, formula, ...)

Arguments

.data

data.frame with variables to fit with additional group variables.

var.group

group variables. Follow y3628::grouper().

formula

Formula to run nls()

...

Additional parameters forwarded to nls(). Most notably, you need to provide start values unless you are using self-starting models. See stats::nls().

Value

Data frame of fitting parameters, with group variables.

Examples

# 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

Description

Order permutation for a NND result record

Usage

nnd.order(nnd.results, ...)

Arguments

nnd.results

y3628::metaRcrd of NND result.

...

Passed to base::order

Value

Order permutation using the nnd field.

Examples

# Does not apply. Internal use only.

Load Clocklab periodogram batch export table

Description

Load Clocklab periodogram batch export table

Usage

periodogram_loadClocklab(data, meta, ...)

Arguments

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.

Value

Periodogram table with metadata columns

Examples

# TODO

Simple wrapper of ggsave for saving plots.

Description

Simple wrapper of ggsave for saving plots.

Usage

plot_ggsave(
  plots = list(),
  widths,
  heights,
  units = "in",
  dir = "plots_eps",
  ...
)

Arguments

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.

Examples

# TODO

Boxplot with data points, viridis_d color filled

Description

Boxplot with data points, viridis_d color filled

Usage

## S3 method for class 'boxPoint'
plot(data, x, y, fill)

Arguments

data

Data

x

x, must be already quoted

y

y, must be already quoted

fill

fill, must be already quoted

Value

ggplot object

Examples

# Internal use

Count number of dots per cell

Description

Count number of dots per cell

Usage

rfish_count(samples, dots, by = c("sample", "image"), ...)

Arguments

samples

tibble of samples table, rfish_read_samples()

dots

tibble of dots table, rfish_read_dots()

by

group by which variables before counting

...

<tidy-select> extra columns (from samples table) to retain

Value

Count table (number of dots per cell).

Examples

# TODO

Read dots table from snakemake pipeline output

Description

Read dots table from snakemake pipeline output

Usage

rfish_read_dots(path, ...)

Arguments

path

Path to the dots csv

...

Forwarded to readr::read_csv

Value

tibble of dots table

Examples

#TODO

Read samples table from snakemake pipeline output

Description

Read samples table from snakemake pipeline output

Usage

rfish_read_samples(path, ...)

Arguments

path

Path to the samples excel.

...

Forwarded to readxl::read_excel

Value

tibble of samples table

Examples

#TODO

Add metadata column to spotInRoi data

Description

Add metadata column to spotInRoi data

Usage

spotInRoi_addMeta(df, idMap, meta, ...)

Arguments

df

spotInRoi table, see details.

idMap

identifier map table, see details.

meta

metadata table.

...

<tidy-select> columns to select from the metadata table.

Details

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.

Value

spotInRoi data with the specified metadata columns.

Examples

# TODO

Expand NND results as data frame entries

Description

Expand NND results as data frame entries

Usage

spotInRoi_as.data.frame.df.nnd(df.nnd, nnd.column = "result")

Arguments

df.nnd

Data frame with a NND result column

nnd.column

Character name of the column that stores NND results.

Value

Expanded data frame with each NND value as one row

Examples

# TODO

Join spotInRoi data with metadata columns

Description

Join spotInRoi data with metadata columns

Usage

spotInRoi_joinMeta(df, df.meta, by, ...)

Arguments

df

spotInRoi data frame.

df.meta

metadata data frame.

by

columns to perform join

...

<tidy-select> columns to select from the metadata data frame.

Value

spotInRoi data frame joined with metadata.

Examples

# Not exported

Sort spotInRoi data based on NND results

Description

Sort spotInRoi data based on NND results

Usage

spotInRoi_nnd.sort(df.nnd, nnd.column = "result", ...)

Arguments

df.nnd

spotInRoi data with NND results.

nnd.column

Character name of the column that stores NND results.

...

Passed to base::order for order permutation.

Value

Sorted spotInRoi results.

Examples

# TODO

Read data for spotInRoi analysis of the Puncta Tracker ImageJ plugin.

Description

Read data for spotInRoi analysis of the Puncta Tracker ImageJ plugin.

Usage

spotInRoi_read_csv(file, parse.spotOut = FALSE, ...)

Arguments

file

File passed to readr::read_csv.

parse.spotOut

Whether to parse spotOut array data.

...

Other parameters passed to readr::read_csv.

Value

tibble of the spotInRoi analysis result.

Examples

# TODO

Predefined subsetting of spotInRoi nuclear/full-cell data.

Description

Predefined subsetting of spotInRoi nuclear/full-cell data.

Usage

spotInRoi_selectNCT(dfNucCyt, what)

Arguments

dfNucCyt

Parsed spotInRoi nuclear/full-cell data.

what

What to subset. must be nuclear, cytoplasm, or full.

Value

Subsetted spotInRoi nuclear/full-cell data.

Subset defaults

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.

Examples

# TODO

Simple subset of behavr::behavr behavior tables

Description

Simple subset of behavr::behavr behavior tables

Usage

subset_behavr(behavr, expr)

Arguments

behavr

Behavior table to subset

expr

An expression that evaluates to logical. See details.

Details

Right now the subsetting creates an intermediate logical vector, which can be very large.

Value

Subsetted behavior table.

Examples

# Not exported