| Title: | Apply Normalization Methods to Multiplexed Images |
|---|---|
| Description: | Implements methods to normalize multiplexed imaging data, including statistical metrics and visualizations to quantify technical variation in this data type. Reference for methods listed here: Harris, C., Wrobel, J., & Vandekar, S. (2022). mxnorm: An R Package to Normalize Multiplexed Imaging Data. Journal of Open Source Software, 7(71), 4180, <doi:10.21105/joss.04180>. |
| Authors: | Coleman Harris [aut, cre] (ORCID: <https://orcid.org/0000-0002-6325-0694>) |
| Maintainer: | Coleman Harris <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.0 |
| Built: | 2026-05-21 09:40:11 UTC |
| Source: | https://github.com/colemanrharris/mxnorm |
Takes in data from data.frame of cell-level multiplexed data to create a mx_dataset S3 object.
mx_dataset(data, slide_id, image_id, marker_cols, metadata_cols = NULL)mx_dataset(data, slide_id, image_id, marker_cols, metadata_cols = NULL)
data |
multiplexed data to normalize. Data assumed to be a data.frame with cell-level data. |
slide_id |
String slide identifier of input |
image_id |
String image identifier of input |
marker_cols |
vector of column name(s) in |
metadata_cols |
other identifiers of the input |
data.frame object in the mx_dataset format with attribute for input type
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals"))mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals"))
Normalizes some given image input according to the method specified
mx_normalize( mx_data, transform = "None", method = "None", method_override = NULL, method_override_name = NULL, ... )mx_normalize( mx_data, transform = "None", method = "None", method_override = NULL, method_override_name = NULL, ... )
mx_data |
|
transform |
transformation to perform on the input data. Options include: c("None", "log10", "mean_divide","log10_mean_divide") |
method |
normalization method to perform on the input data. Options include: c("None", "ComBat","Registration") |
method_override |
optional user-defined function to perform own normalization method (default=NULL). If using a user-defined function, it must include a |
method_override_name |
optional name for method_override (default=NULL). |
... |
optional additional arguments for normalization functions |
Multiplexed data normalized according to the method specified, in the mx_dataset format. Normalized data will be included a new table with normalized values and attributes describing the transformation.
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None")mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None")
mxnorm.A simulated multiplexed dataset containing: 4 slides, with 3 images each, and 3 markers, and 1 metadata column.
mx_samplemx_sample
A data frame with 3000 rows and 6 variables:
slide identifier
image identifier
simulated marker 1 values
simulated marker 2 values
simulated marker 3 values
simulated metadata 1 values
...
Visualize marker density before/after normalization by marker and slide
plot_mx_density(mx_data)plot_mx_density(mx_data)
mx_data |
|
ggplot2 object with density plot
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") ## using `threshold_override` here in case users haven't installed `scikit-image` mx_data = run_otsu_discordance(mx_data, table="normalized", threshold_override = function(thold_data){quantile(thold_data, 0.5)}) plot_mx_density(mx_data)mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") ## using `threshold_override` here in case users haven't installed `scikit-image` mx_data = run_otsu_discordance(mx_data, table="normalized", threshold_override = function(thold_data){quantile(thold_data, 0.5)}) plot_mx_density(mx_data)
Visualize Otsu discordance scores by marker and slide
plot_mx_discordance(mx_data)plot_mx_discordance(mx_data)
mx_data |
|
ggplot2 object with Otsu discordance scores plot
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") ## using `threshold_override` here in case users haven't installed `scikit-image` mx_data = run_otsu_discordance(mx_data, table="normalized", threshold_override = function(thold_data){quantile(thold_data, 0.5)}) plot_mx_discordance(mx_data)mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") ## using `threshold_override` here in case users haven't installed `scikit-image` mx_data = run_otsu_discordance(mx_data, table="normalized", threshold_override = function(thold_data){quantile(thold_data, 0.5)}) plot_mx_discordance(mx_data)
Visualize variance proportions by marker and table
plot_mx_proportions(mx_data)plot_mx_proportions(mx_data)
mx_data |
|
ggplot2 object with proportions plot
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_var_proportions(mx_data, table="both") plot_mx_proportions(mx_data)mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_var_proportions(mx_data, table="both") plot_mx_proportions(mx_data)
Visualize UMAP dimension reduction algorithm
plot_mx_umap(mx_data, metadata_col = NULL)plot_mx_umap(mx_data, metadata_col = NULL)
mx_data |
|
metadata_col |
column denoted in the |
ggplot2 object with density plot
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_reduce_umap(mx_data, table="normalized", c("marker1_vals","marker2_vals","marker3_vals")) plot_mx_umap(mx_data)mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_reduce_umap(mx_data, table="normalized", c("marker1_vals","marker2_vals","marker3_vals")) plot_mx_umap(mx_data)
print S3 method to print summary.mx_dataset objectsExtension of print S3 method to print summary.mx_dataset objects
## S3 method for class 'summary.mx_dataset' print(x, ...)## S3 method for class 'summary.mx_dataset' print(x, ...)
x |
|
... |
option for additional params given S3 logic |
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) print(summary(mx_data))mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) print(summary(mx_data))
mx_dataset object.The Otsu discordance analysis quantifies slide-to-slide agreement by summarizing the distance between slide-level Otsu thresholds and the global Otsu threshold for a given marker in a single metric.
run_otsu_discordance( mx_data, table, threshold_override = NULL, plot_out = FALSE, ... )run_otsu_discordance( mx_data, table, threshold_override = NULL, plot_out = FALSE, ... )
mx_data |
|
table |
dataset in |
threshold_override |
optional user-defined function or alternate thresholding algorithm adaptable from Python skimage module |
plot_out |
boolean to generate Otsu discordance plots (default=FALSE) |
... |
optional additional arguments for Otsu discordance functions |
mx_dataset object with analysis results of Otsu discordance in otsu_data table
Otsu, N. (1979). A threshold selection method from gray-level histograms. IEEE transactions on systems, man, and cybernetics, 9(1), 62-66.
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") ## using `threshold_override` here in case users haven't installed `scikit-image` mx_data = run_otsu_discordance(mx_data, table="normalized", threshold_override = function(thold_data){quantile(thold_data, 0.5)})mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") ## using `threshold_override` here in case users haven't installed `scikit-image` mx_data = run_otsu_discordance(mx_data, table="normalized", threshold_override = function(thold_data){quantile(thold_data, 0.5)})
mx_dataset object.Run UMAP dimension reduction algorithm on an mx_dataset object.
run_reduce_umap( mx_data, table, marker_list, downsample_pct = 1, metadata_cols = NULL )run_reduce_umap( mx_data, table, marker_list, downsample_pct = 1, metadata_cols = NULL )
mx_data |
|
table |
dataset in |
marker_list |
list of markers in the |
downsample_pct |
double, optional percentage (0, 1] of sample rows to include when running UMAP algorithm. (default=1) |
metadata_cols |
other identifiers of the input |
mx_dataset object with analysis results of UMAP dimension results in umap_data table
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_reduce_umap(mx_data, table="normalized", c("marker1_vals","marker2_vals","marker3_vals"))mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_reduce_umap(mx_data, table="normalized", c("marker1_vals","marker2_vals","marker3_vals"))
mx_dataset object to determine proportions of variance at the slide levelRun random effects modeling on mx_dataset object to determine proportions of variance at the slide level
run_var_proportions( mx_data, table, metadata_cols = NULL, formula_override = NULL, save_models = FALSE, ... )run_var_proportions( mx_data, table, metadata_cols = NULL, formula_override = NULL, save_models = FALSE, ... )
mx_data |
|
table |
dataset in |
metadata_cols |
other identifiers of the input |
formula_override |
String with user-defined formula to use for variance proportions modeling analysis (default=NULL). This will be the RHS of a formula with |
save_models |
Boolean flag to save |
... |
optional additional arguments for |
mx_dataset object with modeling results in var_data table
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_var_proportions(mx_data, table="both")mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) mx_data = mx_normalize(mx_data, transform="log10",method="None") mx_data = run_var_proportions(mx_data, table="both")
summary S3 method to summarize mx_dataset objectsExtension of summary S3 method to summarize mx_dataset objects
## S3 method for class 'mx_dataset' summary(object, ...)## S3 method for class 'mx_dataset' summary(object, ...)
object |
|
... |
option for additional params given S3 logic |
summary.mx_dataset object
mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) summary(mx_data)mx_data = mx_dataset(mxnorm::mx_sample, "slide_id", "image_id", c("marker1_vals","marker2_vals","marker3_vals"), c("metadata1_vals")) summary(mx_data)