| Title: | Omics Data Processing Toolbox |
|---|---|
| Description: | Provides tools for processing and analyzing omics data from genomics, transcriptomics, proteomics, and metabolomics platforms. Includes data import, filtering, imputation, normalization, targeted calibration, spectrum export, visualization, statistical comparisons, and reproducible QC reports. The QC-RLSC (quality control-based robust LOESS signal correction) algorithm is used for normalization. Dunn et al. (2011) <doi:10.1038/nprot.2011.335>. |
| Authors: | Yaoxiang Li [aut], Meth Jayatilake [aut], Anushka Dongaonkar [aut], Rupayan Mallick [aut], Amrita Cheema [cre, aut] |
| Maintainer: | Amrita Cheema <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 2.0.0 |
| Built: | 2026-11-04 06:47:33 UTC |
| Source: | https://github.com/cheemalab/omicstools |
This function calculates the mean, standard deviation, and coefficient of variation for QC data, optionally ignoring NA values. It also calculates the relative standard deviation (RSD) for both Pooled QC and NIST samples. The input data should be a tibble where the first column is the sample ID and all other columns are features.
calculate_qc_rsd( data, qc_string = "Pooled QC|Pooled_QC", nist_string = "NIST", id_col = "sample_id", ignore_na = TRUE )calculate_qc_rsd( data, qc_string = "Pooled QC|Pooled_QC", nist_string = "NIST", id_col = "sample_id", ignore_na = TRUE )
data |
A tibble with the first column as sample IDs and other columns as features. |
qc_string |
A string pattern to filter Pooled QC samples. Default is "Pooled QC|Pooled_QC". |
nist_string |
A string pattern to filter NIST samples. Default is "NIST". |
id_col |
The name of the sample ID column. Default is "sample_id". |
ignore_na |
Logical, whether to ignore NA values in calculations. Default is TRUE. |
A list containing tibbles with calculated statistics for Pooled QC and NIST samples. If no matching samples are found, returns NULL for that category.
Yaoxiang Li
# Generate example data example_data <- tibble::tibble( sample_id = c("Pooled QC 1", "Pooled QC 2", "NIST 1", "NIST 2", "Sample 1"), feature1 = c(10, 15, 20, NA, 5), feature2 = c(20, NA, 25, 30, 10), feature3 = c(NA, 25, 30, 35, 15) ) # Calculate QC statistics and RSD rsd_stats <- calculate_qc_rsd(example_data) # Access results pooled_qc_rsd <- rsd_stats$Pooled_QC_RSD nist_rsd <- rsd_stats$NIST_RSD# Generate example data example_data <- tibble::tibble( sample_id = c("Pooled QC 1", "Pooled QC 2", "NIST 1", "NIST 2", "Sample 1"), feature1 = c(10, 15, 20, NA, 5), feature2 = c(20, NA, 25, 30, 10), feature3 = c(NA, 25, 30, 35, 15) ) # Calculate QC statistics and RSD rsd_stats <- calculate_qc_rsd(example_data) # Access results pooled_qc_rsd <- rsd_stats$Pooled_QC_RSD nist_rsd <- rsd_stats$NIST_RSD
This function checks if two tibbles have the same column names, sorts the columns of one tibble to match the order of the other, and then checks if all values in both tibbles are the same.
check_and_sort_columns(area_data, area_txt)check_and_sort_columns(area_data, area_txt)
area_data |
A tibble containing the data to be checked and sorted. |
area_txt |
A tibble containing the reference data for column order and value comparison. |
Prints messages indicating whether the tibbles have the same column names and whether all values are the same.
Yaoxiang Li
## Not run: area_data <- read.delim("path/to/All_txt.txt", check.names = FALSE) area_txt <- read.delim("path/to/area.txt", check.names = FALSE) check_and_sort_columns(area_data, area_txt) ## End(Not run)## Not run: area_data <- read.delim("path/to/All_txt.txt", check.names = FALSE) area_txt <- read.delim("path/to/area.txt", check.names = FALSE) check_and_sort_columns(area_data, area_txt) ## End(Not run)
This function checks if sample IDs and column names match between area data and internal standard area data.
check_match(area_data, istd_area_data)check_match(area_data, istd_area_data)
area_data |
A data frame containing the area data. |
istd_area_data |
A data frame containing the internal standard area data. |
A logical value indicating if the sample IDs and column names match.
Yaoxiang Li
area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) istd_area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) check_match(area_data, istd_area_data)area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) istd_area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) check_match(area_data, istd_area_data)
Combine Multiple Logical Tibbles with Intersection or Union
combine_logical_tibbles(..., method = c("intersection", "union"))combine_logical_tibbles(..., method = c("intersection", "union"))
... |
Multiple tibbles to be combined. Each tibble should have the same dimensions, same column names in the same order, and the first column values should be identical across all tibbles. |
method |
A string indicating the method to combine the tibbles. Either "intersection" or "union". Default is "intersection". |
A combined tibble where each cell is TRUE based on the method: - "intersection": TRUE if all corresponding cells in the input tibbles are TRUE, otherwise FALSE. - "union": TRUE if at least one corresponding cell in the input tibbles is TRUE, otherwise FALSE.
Yaoxiang Li
tibble1 <- tibble::tibble(id = 1:3, A = c(TRUE, FALSE, NA), B = c(TRUE, TRUE, FALSE)) tibble2 <- tibble::tibble(id = 1:3, A = c(TRUE, TRUE, TRUE), B = c(FALSE, TRUE, TRUE)) tibble3 <- tibble::tibble(id = 1:3, A = c(TRUE, FALSE, TRUE), B = c(TRUE, TRUE, NA)) combine_logical_tibbles(tibble1, tibble2, tibble3, method = "intersection") combine_logical_tibbles(tibble1, tibble2, tibble3, method = "union")tibble1 <- tibble::tibble(id = 1:3, A = c(TRUE, FALSE, NA), B = c(TRUE, TRUE, FALSE)) tibble2 <- tibble::tibble(id = 1:3, A = c(TRUE, TRUE, TRUE), B = c(FALSE, TRUE, TRUE)) tibble3 <- tibble::tibble(id = 1:3, A = c(TRUE, FALSE, TRUE), B = c(TRUE, TRUE, NA)) combine_logical_tibbles(tibble1, tibble2, tibble3, method = "intersection") combine_logical_tibbles(tibble1, tibble2, tibble3, method = "union")
Calculates Welch or Wilcoxon tests on log2 intensities and adjusts p-values using Benjamini-Hochberg. When zeros occur, half the smallest positive value in the two groups is added to that feature before transformation. Log2 fold change is the log2 ratio of group means with the same offset. Untestable features retain an NA p-value and an explanatory status.
compare_omics_groups( data, group_col, reference, comparison, method = c("welch", "wilcoxon"), id_col = "sample_id", metadata_cols = NULL )compare_omics_groups( data, group_col, reference, comparison, method = c("welch", "wilcoxon"), id_col = "sample_id", metadata_cols = NULL )
data |
A samples-by-features data frame including sample IDs. |
group_col |
Group column. |
reference, comparison
|
Reference and comparison group labels. |
method |
Welch t-test or Wilcoxon rank-sum test. |
id_col |
Sample ID column. |
metadata_cols |
Columns excluded from intensity processing. NULL also identifies nonnumeric columns as metadata. |
A tibble with feature IDs, group means, log2FC, p_value, fdr, and status.
Yaoxiang Li
This function converts a tibble containing MRM data to a wide format based on the specified response column.
convert_mrm_data( data, response_col, sample_name_col = "data_filename", sample_id_col = "sample_id", component_name_col = "component_name" )convert_mrm_data( data, response_col, sample_name_col = "data_filename", sample_id_col = "sample_id", component_name_col = "component_name" )
data |
A tibble containing the MRM transition data. |
response_col |
Name of the column containing the response data to be spread. |
sample_name_col |
Name of the column containing sample name information. |
sample_id_col |
Name of the column containing sample ID information. |
component_name_col |
Name of the column containing component name information. |
A tibble in wide format with samples as rows and compounds as columns.
Yaoxiang Li
## Not run: all_txt <- tibble::tribble( ~`data_filename`, ~`sample_id`, ~`component_name`, ~Area, ~`IS Area`, "Sample1", "ID1", "Compound1", 100, 50, "Sample1", "ID2", "Compound2", 200, 75, "Sample2", "ID1", "Compound1", 150, 60, "Sample2", "ID2", "Compound2", 250, 80 ) area_data <- convert_mrm_data(all_txt, "Area", "data_filename", "sample_id", "component_name") is_area_data <- convert_mrm_data(all_txt, "IS Area", "data_filename", "sample_id", "component_name") print(area_data) print(is_area_data) ## End(Not run)## Not run: all_txt <- tibble::tribble( ~`data_filename`, ~`sample_id`, ~`component_name`, ~Area, ~`IS Area`, "Sample1", "ID1", "Compound1", 100, 50, "Sample1", "ID2", "Compound2", 200, 75, "Sample2", "ID1", "Compound1", 150, 60, "Sample2", "ID2", "Compound2", 250, 80 ) area_data <- convert_mrm_data(all_txt, "Area", "data_filename", "sample_id", "component_name") is_area_data <- convert_mrm_data(all_txt, "IS Area", "data_filename", "sample_id", "component_name") print(area_data) print(is_area_data) ## End(Not run)
This function adds a column 'MRM_Duplicate_Flag' to the tibble, indicating if a row is a duplicate based on the criteria: same polarity, less than a 1-minute retention time difference, and the same MRM transition (Q1/Q3).
detect_duplicates( data, polarity_col = "polarity", retention_time_col = "retention_time", mass_info_col = "Mass Info", component_name_col = "component_name" )detect_duplicates( data, polarity_col = "polarity", retention_time_col = "retention_time", mass_info_col = "Mass Info", component_name_col = "component_name" )
data |
A tibble containing the MRM transition data. |
polarity_col |
Name of the column containing polarity information. |
retention_time_col |
Name of the column containing retention time information. |
mass_info_col |
Name of the column containing mass information. |
component_name_col |
Name of the column containing component name information. |
The original tibble with an added 'MRM_Duplicate_Flag' column.
Yaoxiang Li
## Not run: sample_data <- tibble::tribble( ~polarity, ~`retention_time`, ~`Mass Info`, ~`component_name`, "Positive", 1.95, "61.0 / 44.0", "Urea_pos", "Positive", 8.34, "206.0 / 189.0", "Lipoamide_pos", "Positive", 2.18, "339.1 / 110.0", "AICAR_pos", "Positive", 1.76, "175.1 / 70.0", "Arginine_pos", "Positive", 1.75, "176.2 / 159.1", "Citrulline_pos", "Positive", 8.90, "198.0 / 181.0", "Dopa_pos", "Positive", 2.06, "132.1 / 86.0", "Isoleucine_pos", "Positive", 1.92, "132.1 / 43.1", "Leucine_pos", "Positive", 1.76, "150.1 / 133.0", "Methionine_pos", "Positive", 7.79, "166.1 / 103.0", "Phenylalanine_pos" ) detect_duplicates(sample_data, "polarity", "retention_time", "Mass Info", "component_name") ## End(Not run)## Not run: sample_data <- tibble::tribble( ~polarity, ~`retention_time`, ~`Mass Info`, ~`component_name`, "Positive", 1.95, "61.0 / 44.0", "Urea_pos", "Positive", 8.34, "206.0 / 189.0", "Lipoamide_pos", "Positive", 2.18, "339.1 / 110.0", "AICAR_pos", "Positive", 1.76, "175.1 / 70.0", "Arginine_pos", "Positive", 1.75, "176.2 / 159.1", "Citrulline_pos", "Positive", 8.90, "198.0 / 181.0", "Dopa_pos", "Positive", 2.06, "132.1 / 86.0", "Isoleucine_pos", "Positive", 1.92, "132.1 / 43.1", "Leucine_pos", "Positive", 1.76, "150.1 / 133.0", "Methionine_pos", "Positive", 7.79, "166.1 / 103.0", "Phenylalanine_pos" ) detect_duplicates(sample_data, "polarity", "retention_time", "Mass Info", "component_name") ## End(Not run)
Detect multivariate sample outliers
detect_sample_outliers(data, threshold = NULL)detect_sample_outliers(data, threshold = NULL)
data |
Numeric samples-by-features matrix or data frame. |
threshold |
Threshold for robust multivariate distance. |
A tibble with sample identifiers, scores, and outlier flags.
Yaoxiang Li
Writes separate intensity, sample, feature, QC, comparison, blank audit, processing-step, and settings files together with a self-contained HTML report. A temporary directory is published only after every output succeeds.
export_omics_results(result, directory)export_omics_results(result, directory)
result |
A result from process_omics_data(). |
directory |
A new output directory. Existing directories are not overwritten. |
Invisibly, the output directory path.
Yaoxiang Li
Positive intensities are averaged separately in blanks and study samples. A feature is retained when its study mean is positive and at least ratio times its blank mean in every batch. The audit table records each decision.
filter_blank_features( data, sample_type_col, blank_value = "Blank", study_value = "Sample", ratio = 3, batch_col = NULL, id_col = "sample_id", metadata_cols = NULL )filter_blank_features( data, sample_type_col, blank_value = "Blank", study_value = "Sample", ratio = 3, batch_col = NULL, id_col = "sample_id", metadata_cols = NULL )
data |
A samples-by-features data frame including sample IDs. |
sample_type_col |
Column identifying blanks and study samples. |
blank_value, study_value
|
Labels for blank and study samples. |
ratio |
Minimum study-to-blank intensity ratio, at least one. |
batch_col |
Optional batch column. Every batch needs blanks and study samples. |
id_col |
Sample ID column. |
metadata_cols |
Columns excluded from intensity processing. NULL also identifies nonnumeric columns as metadata. |
A list containing the filtered data and a per-feature, per-batch summary.
Yaoxiang Li
Supports data frames and matrices.
filter_missing_value(data, percent = 0.2, metadata_cols = 1L)filter_missing_value(data, percent = 0.2, metadata_cols = 1L)
data |
A data frame or matrix. |
percent |
Maximum allowed missing-value proportion per feature. |
metadata_cols |
Columns in a tabular input that should not be filtered. |
The filtered object, preserving the input representation.
Yaoxiang Li
Filter features by quality-control relative standard deviation
filter_qc_rsd( data, percent = 0.2, qc_index = NULL, qc_string = "QC|Pooled QC|Pooled_QC", id_col = 1L, metadata_cols = 1L )filter_qc_rsd( data, percent = 0.2, qc_index = NULL, qc_string = "QC|Pooled QC|Pooled_QC", id_col = 1L, metadata_cols = 1L )
data |
A data frame or matrix. |
percent |
Maximum allowed QC relative standard deviation. |
qc_index |
Logical or numeric indicator identifying QC rows. When omitted for tabular inputs, 'qc_string' is matched in 'id_col'. |
qc_string |
Pattern used to identify QC rows. |
id_col |
Sample identifier column for tabular data. |
metadata_cols |
Columns that should not be filtered. |
The filtered object, preserving the input representation.
Yaoxiang Li
Fit a targeted-assay calibration model
fit_targeted_calibration( standards, concentration_col = "std_conc", response_col = "response", model = c("linear", "exponential"), response_range = NULL, weights = NULL )fit_targeted_calibration( standards, concentration_col = "std_conc", response_col = "response", model = c("linear", "exponential"), response_range = NULL, weights = NULL )
standards |
Data frame containing known concentrations and responses. |
concentration_col |
Name of the concentration column. |
response_col |
Name of the instrument-response column. |
model |
Calibration model: ordinary linear regression or an exponential curve fitted by regressing log concentration on response. |
response_range |
Optional two-element response range used to subset standards before fitting. |
weights |
Optional non-negative observation weights. |
An object of class 'omics_calibration'.
Yaoxiang Li
Flags features in samples based on their abundance in blank samples. If a feature is NA in the first blank sample, all samples for this feature are marked as TRUE. Otherwise, for each sample and feature, if the peak area is at least 10 times the area of the first blank sample, it is marked as TRUE, else FALSE. NA values in the samples remain unchanged.
flag_underexpressed_features( data, sample_id_col = "sample_id", feature_cols, threshold = 10 )flag_underexpressed_features( data, sample_id_col = "sample_id", feature_cols, threshold = 10 )
data |
A tibble containing the MRM transition data. |
sample_id_col |
Name of the column containing sample ID information. |
feature_cols |
A vector of column names representing the features. |
threshold |
A numeric value representing the threshold multiplier (default is 10). |
A tibble with the same dimensions and column names as the input data, containing TRUE, FALSE, or NA based on the criteria.
Yaoxiang Li
## Not run: area_data <- tibble::tibble( sample_id = c( "011_Blank", "012_sample_002", "013_NIST_Plasma", "014_Blank", "015_sample_006", "016_sample_003" ), `2-Deoxyglucose-6-Phosphate_neg` = c(NA, 345423.96, NA, NA, 125889.80, 323818.25), `2-Oxoisoleucine_neg` = c(NA, 53004.06, 124669.80, NA, 23650.90, 118364.36), `3-(4-Hydroxyphenyl)propionate_neg` = c(NA, 53004.06, 124669.80, NA, 23650.90, 118364.36) ) flagged_data <- flag_underexpressed_features( area_data, sample_id_col = "sample_id", feature_cols = names(area_data)[-1] ) print(flagged_data) ## End(Not run)## Not run: area_data <- tibble::tibble( sample_id = c( "011_Blank", "012_sample_002", "013_NIST_Plasma", "014_Blank", "015_sample_006", "016_sample_003" ), `2-Deoxyglucose-6-Phosphate_neg` = c(NA, 345423.96, NA, NA, 125889.80, 323818.25), `2-Oxoisoleucine_neg` = c(NA, 53004.06, 124669.80, NA, 23650.90, 118364.36), `3-(4-Hydroxyphenyl)propionate_neg` = c(NA, 53004.06, 124669.80, NA, 23650.90, 118364.36) ) flagged_data <- flag_underexpressed_features( area_data, sample_id_col = "sample_id", feature_cols = names(area_data)[-1] ) print(flagged_data) ## End(Not run)
This function generates a comprehensive process report for Sciex 7500/5500 raw data, including data normalization, missing value imputation, and optional normalization and flagging steps. The results are saved in a temporary directory and then zipped into a file for easy sharing.
generate_process_report( input_file, output_file = NULL, filter_blank = TRUE, blank_string = "Blank|BLANK|blank", filter_nist = TRUE, nist_string = "NIST|Nist|nist", imputation_threshold = 0.25, imputation_method = "half_min", qc_string = "QC", include_is_normalization = TRUE, include_qc_rlsc = TRUE, include_pqn = TRUE, include_qc_rsd = TRUE, include_snr_flag = TRUE, snr_threshold = 10, include_area_flag = TRUE, include_height_flag = TRUE, id_col = "sample_id", ignore_na = TRUE )generate_process_report( input_file, output_file = NULL, filter_blank = TRUE, blank_string = "Blank|BLANK|blank", filter_nist = TRUE, nist_string = "NIST|Nist|nist", imputation_threshold = 0.25, imputation_method = "half_min", qc_string = "QC", include_is_normalization = TRUE, include_qc_rlsc = TRUE, include_pqn = TRUE, include_qc_rsd = TRUE, include_snr_flag = TRUE, snr_threshold = 10, include_area_flag = TRUE, include_height_flag = TRUE, id_col = "sample_id", ignore_na = TRUE )
input_file |
The path to the input file containing raw data. |
output_file |
The path to the output zip file. |
filter_blank |
Logical, whether to filter out blank samples (default: TRUE). |
blank_string |
Character, regular expression pattern to match blank sample IDs (default: 'Blank|BLANK|blank'). |
filter_nist |
Logical, whether to filter out NIST samples (default: TRUE). |
nist_string |
Character, regular expression pattern to match NIST sample IDs (default: 'NIST|Nist|nist'). |
imputation_threshold |
Numeric, threshold for missing value imputation (default: 0.25). |
imputation_method |
Character, method for missing value imputation (default: 'half_min'). |
qc_string |
Character, regular expression pattern to match QC sample IDs (default: 'QC'). |
include_is_normalization |
Logical, whether to include internal standard normalization (default: TRUE). |
include_qc_rlsc |
Logical, whether to include QC-RLSC normalization (default: TRUE). |
include_pqn |
Logical, whether to include PQN normalization (default: TRUE). |
include_qc_rsd |
Logical, whether to include QC RSD calculation (default: TRUE). |
include_snr_flag |
Logical, whether to include Signal-to-Noise ratio flagging (default: TRUE). |
snr_threshold |
Numeric, threshold for Signal-to-Noise ratio flagging (default: 10). |
include_area_flag |
Logical, whether to include area threshold flagging (default: TRUE). |
include_height_flag |
Logical, whether to include height threshold flagging (default: TRUE). |
id_col |
Character, name of the column containing sample IDs (default: 'sample_id'). |
ignore_na |
Logical, whether to ignore NA values in QC RSD calculation (default: TRUE). |
The path to the generated zip file containing the process report.
Yaoxiang Li
Splits sample identifiers into structured fields and preserves acquisition order.
generate_sample_metadata( samples, separator = "[_-]", fields = c("group", "subject", "replicate"), strip_extension = TRUE )generate_sample_metadata( samples, separator = "[_-]", fields = c("group", "subject", "replicate"), strip_extension = TRUE )
samples |
Character vector of sample or file names. |
separator |
Regular expression used to split identifiers. |
fields |
Names assigned to the split components. |
strip_extension |
Whether to remove a final file extension. |
A tibble containing 'sample_id', 'acquisition_order', and requested metadata fields.
Yaoxiang Li
This function filters features based on a missing value threshold and imputes missing values using various methods. Metadata columns are specified by the user and are exempt from filtering and imputation.
handle_missing_values( data, threshold = 0.2, imputation_method = "half_min", metadata_cols = NULL )handle_missing_values( data, threshold = 0.2, imputation_method = "half_min", metadata_cols = NULL )
data |
A tibble containing the data with potential missing values. |
threshold |
A numeric value between 0 and 1 representing the maximum allowable proportion of missing values in a feature. Default is 0.20. |
imputation_method |
A character string indicating the method to use for imputation. Valid methods are "mean", "median", "mode", and "half_min". Default is "mean". |
metadata_cols |
A vector of column names or indices to be treated as metadata, exempt from filtering and imputation. Default is NULL. |
A tibble with filtered features and imputed missing values.
Yaoxiang Li
data <- tibble::tibble( Feature1 = c(1, 2, NA, 4, 5), Feature2 = c(NA, 2, 3, 4, NA), Feature3 = c(1, NA, 3, NA, 5), Metadata = c("A", "B", "C", "D", "E") ) imputed_data <- handle_missing_values( data, threshold = 0.20, imputation_method = "half_min", metadata_cols = "Metadata" ) print(imputed_data)data <- tibble::tibble( Feature1 = c(1, 2, NA, 4, 5), Feature2 = c(NA, 2, 3, 4, NA), Feature3 = c(1, NA, 3, NA, 5), Metadata = c("A", "B", "C", "D", "E") ) imputed_data <- handle_missing_values( data, threshold = 0.20, imputation_method = "half_min", metadata_cols = "Metadata" ) print(imputed_data)
Impute missing values with half of a feature minimum
impute_half_min(data, metadata_cols = 1L)impute_half_min(data, metadata_cols = 1L)
data |
A data frame or matrix. |
metadata_cols |
Columns in a tabular input that should not be imputed. |
The imputed object, preserving the input representation.
Yaoxiang Li
This function performs internal standard normalization.
internal_standard_normalize(area_data, istd_area_data)internal_standard_normalize(area_data, istd_area_data)
area_data |
A data frame containing the area data. |
istd_area_data |
A data frame containing the internal standard area data. |
A data frame with normalized data.
Yaoxiang Li
area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) istd_area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) normalized_data <- internal_standard_normalize(area_data, istd_area_data)area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) istd_area_data <- data.frame(sample_id = c("S1", "S2", "S3"), A = 1:3, B = 4:6) normalized_data <- internal_standard_normalize(area_data, istd_area_data)
Load omics data
load_data(file_path, format = NULL, ...)load_data(file_path, format = NULL, ...)
file_path |
Path to the input file. |
format |
Optional format override. By default the file extension is used. |
... |
Additional arguments passed to the corresponding reader. |
The value returned by [load_omics_data()].
Yaoxiang Li
Reads common delimited, Excel, and serialized R formats without attaching additional packages. Tabular inputs are returned as tibbles.
load_omics_data(file_path, format = NULL, ...)load_omics_data(file_path, format = NULL, ...)
file_path |
Path to the input file. |
format |
Optional format override. By default the file extension is used. |
... |
Additional arguments passed to the corresponding reader. |
A tibble for tabular data, or the stored R object for 'rds', 'rda', and 'rdata' files. An R data file containing multiple objects returns a named list.
Yaoxiang Li
Load and Parse SCIEX OS Exported LC-MRM-MS2 Data
load_parse_sciex_txt( file_path, input_data = NULL, return_all_columns = TRUE, check_negative_values = TRUE, fix_istds = TRUE )load_parse_sciex_txt( file_path, input_data = NULL, return_all_columns = TRUE, check_negative_values = TRUE, fix_istds = TRUE )
file_path |
File path of the input text file of a complete output of the SCIEX OS results from a sequence. File should be tab-delimited and in the 'long' format. |
input_data |
Input tibble of raw SCIEX (pre-parsing) text file. If 'NULL' (default value), data will be loaded from 'file_path'. |
return_all_columns |
Logical value as to whether to return all columns ('TRUE') or just the necessary columns for downstream machine learning analysis or quality control review ('FALSE'). Default value is 'TRUE'. When set to false, the columns included in the returned tibble include: '"component_name"', '"component_idx"', '"precursor_mz"', '"product_mz"', '"is_istd"', '"istd"', '"retention_time_expected"', '"data_filename"', '"data_file_idx"', '"sample_id"', '"sample_type"', '"component_type"', '"polarity"', '"component_group"', '"outlier_reasons"', '"retention_time_expected_istd"', '"area"', '"istd_area"', '"area_ratio"', '"height"', '"istd_height"', '"height_ratio"', '"peak_quality"', '"istd_peak_quality"', '"retention_time"', '"retention_time_istd"', '"rt_error"', '"rt_delta_min"', '"rt_start"', '"istd_rt_start"', '"rt_end"', '"istd_rt_end"', '"peak_width"', '"istd_peak_width"', '"fwhm"', '"istd_fwhm"', '"signal_noise"', '"istd_signal_noise"', '"modified"', '"relative_rt"', '"used"', '"tailing_factor"', '"asymmetry_factor"', 'points_across_baseline"', '"points_across_fwhm"'). |
check_negative_values |
Logical value as to whether to check for negative values in the 'area' and 'height' variables (for both components and internal standards). If 'TRUE' (default) and there is at least one negative value in the data, the minimum 'area' or 'height' value will be subtracted from all 'area' and/or 'height' values by 'component_name', and 100 will then be added to avoid having values below 100. 'area_ratio', 'height_ratio', and 'area_height_ratio' values (and their internal standard equivalent variables) will also be re-calculated. |
fix_istds |
Logical value (default 'TRUE') to identify internal standards
by regular expression of |
tibble with the fields appropriately renamed.
Yaoxiang Li
## Not run: data(sciex_mrm_ms_data) data_tibble <- load_parse_sciex_txt( file_path = "path/to/file.txt", return_all_columns = FALSE, check_negative_values = TRUE ) ## End(Not run)## Not run: data(sciex_mrm_ms_data) data_tibble <- load_parse_sciex_txt( file_path = "path/to/file.txt", return_all_columns = FALSE, check_negative_values = TRUE ) ## End(Not run)
Search for MS1 annotations.
ms1_annotation( AnnotaData, masstole = 0.05, toleUnit = 1, annotaDB = "metlin", ionMode = "pos", adducts = NULL )ms1_annotation( AnnotaData, masstole = 0.05, toleUnit = 1, annotaDB = "metlin", ionMode = "pos", adducts = NULL )
AnnotaData |
Numeric vector of observed m/z values. |
masstole |
Non-negative mass tolerance. |
toleUnit |
Tolerance unit, '1' or '"Da"', or '2' or '"ppm"'. |
annotaDB |
Database name, '"metlin"' or '"hmdb"'. |
ionMode |
Ion mode, '"pos"', '"neg"', or '"neu"' for neutral masses. |
adducts |
Optional CEU Mass Mediator adduct names. By default all compatible adducts are searched. |
A tibble of CEU Mass Mediator matches.
Yaoxiang Li
Locate a bundled plot example
omics_example_file(relative_path)omics_example_file(relative_path)
relative_path |
Path under the package's example directory. |
The path to the example file.
Yaoxiang Li
Lists the workflows that are reachable from the 'omicsTools' Shiny application. The registry is used by automated tests so workflows retain their GUI entry point.
omics_gui_capabilities()omics_gui_capabilities()
A tibble with package, workflow, Shiny tab, and supporting exported functions.
Yaoxiang Li
Plot detected LC-MS features by retention time and m/z
plot_lcms_features( data, rt_col = "rt", mz_col = "mz", mode_col = "mode", title = "Detected LC-MS features" )plot_lcms_features( data, rt_col = "rt", mz_col = "mz", mode_col = "mode", title = "Detected LC-MS features" )
data |
Feature table. |
rt_col, mz_col
|
Column names for retention time and mass-to-charge. |
mode_col |
Optional polarity/mode column. |
title |
Plot title. |
A 'ggplot' object.
Yaoxiang Li
This function loads a specified data file containing lipid measurements, calculates the summary of missing values and relative standard deviation (RSD) for each lipid class, and generates plots for both summaries. It also plots and saves figures showing the distribution of internal standards across samples.
plot_lipid_data_summary( file_path, output_xlsx = "lipid_classes_with_names.xlsx", missing_plot_path = "missing_values_plot.png", rsd_plot_path = "rsd_values_plot.png", is_plots_dir = "is_plots", blank_pattern = "Blank|Control|Neg", pooled_pattern = "Pooled QC|Pooled|Pool|PQ", nist_pattern = "NIST Plasma|NIST|nist" )plot_lipid_data_summary( file_path, output_xlsx = "lipid_classes_with_names.xlsx", missing_plot_path = "missing_values_plot.png", rsd_plot_path = "rsd_values_plot.png", is_plots_dir = "is_plots", blank_pattern = "Blank|Control|Neg", pooled_pattern = "Pooled QC|Pooled|Pool|PQ", nist_pattern = "NIST Plasma|NIST|nist" )
file_path |
The path to the lipid measurement data file (e.g., "area.txt"). |
output_xlsx |
Path to save the lipid classes with names as an Excel file. Default is "lipid_classes_with_names.xlsx". |
missing_plot_path |
Path to save the missing data percentage plot. Default is "missing_values_plot.png". |
rsd_plot_path |
Path to save the RSD percentage plot. Default is "rsd_values_plot.png". |
is_plots_dir |
Directory to save internal standard distribution plots. Default is "is_plots". |
blank_pattern |
Regex pattern to identify blank samples in the "Sample ID" column. Default is "Blank|blank". |
pooled_pattern |
Regex pattern to identify pooled QC samples in the "Sample ID" column. Default is "Pooled QC|Pooled|pool|PQC". |
nist_pattern |
Regex pattern to identify NIST QC samples in the "Sample ID" column. Default is "NIST Plasma|NIST|nist". |
Plots and saves summary figures of missing percentages, RSD percentages, and internal standard distributions.
Yaoxiang Li
This function loads a specified data file containing metabolomics measurements, identifies internal standards based on a naming convention, and generates plots for the distribution of internal standards across samples. It also saves the internal standard information in an Excel file.
plot_met_data_summary( file_path, output_xlsx = "internal_standards.xlsx", is_plots_dir = "is_plots", blank_pattern = "Blank|Control|Neg", pooled_pattern = "Pooled QC|Pooled|Pool|PQ", nist_pattern = "NIST Plasma|NIST|nist", other_special_pattern = "Special Case|Extra Sample|Other QC" )plot_met_data_summary( file_path, output_xlsx = "internal_standards.xlsx", is_plots_dir = "is_plots", blank_pattern = "Blank|Control|Neg", pooled_pattern = "Pooled QC|Pooled|Pool|PQ", nist_pattern = "NIST Plasma|NIST|nist", other_special_pattern = "Special Case|Extra Sample|Other QC" )
file_path |
The path to the metabolomics measurement data file (e.g., "area_TM.txt"). |
output_xlsx |
The path where the Excel file with internal standards will be saved (default is "internal_standards.xlsx"). |
is_plots_dir |
Directory where plots for each internal standard will be saved (default is "is_plots"). |
blank_pattern |
Pattern for identifying blank samples in 'Sample ID' column (default is "Blank|BLANK|blank|Control|Negative Control|Neg Control|BLK|Blk"). |
pooled_pattern |
Pattern for identifying pooled QC samples in 'Sample ID' column (default is "Pooled QC|Pooled_QC|Pooled|POOL|Pool|pool|QC Mix|Mix QC|Pool QC|PQ|PQC"). |
nist_pattern |
Pattern for identifying NIST QC samples in 'Sample ID' column (default is "NIST Plasma|NIST_Plasma|NIST-QC|Reference Plasma|Plasma Ref|NIST_QC|NIST QC|NIST|nist"). |
other_special_pattern |
Pattern for identifying other special cases in 'Sample ID' column (default is "Special Case|Extra Sample|NonStandard QC|Other QC"). |
Saves internal standard plots and an Excel file with the identified internal standards.
Yaoxiang Li
Plot a feature intensity heatmap
plot_omics_heatmap( data, id_col = "sample_id", feature_cols = NULL, scale_features = TRUE, max_features = 50L )plot_omics_heatmap( data, id_col = "sample_id", feature_cols = NULL, scale_features = TRUE, max_features = 50L )
data |
A samples-by-features data frame. |
id_col |
Sample ID column. |
feature_cols |
Numeric feature columns; NULL selects all numeric columns. |
scale_features |
Whether to center and standardize each feature. |
max_features |
Maximum number of features, chosen by decreasing variance. |
A ggplot heatmap with creator credit.
Yaoxiang Li
Compute and plot principal components for omics data
plot_omics_pca(data, group = NULL, labels = NULL, center = TRUE, scale. = TRUE)plot_omics_pca(data, group = NULL, labels = NULL, center = TRUE, scale. = TRUE)
data |
Numeric matrix/data frame with samples in rows. |
group |
Optional grouping vector. |
labels |
Optional sample labels. |
center, scale.
|
Passed to [stats::prcomp()]. |
A 'ggplot' object with the fitted 'prcomp' object attached as the 'pca' attribute.
Yaoxiang Li
Plot a tandem mass spectrum
plot_peak_list(peak_list)plot_peak_list(peak_list)
peak_list |
Two-column matrix or data frame containing m/z and intensity. |
A 'ggplot' object.
Yaoxiang Li
Plot a targeted calibration curve
plot_targeted_calibration(calibration)plot_targeted_calibration(calibration)
calibration |
An object returned by [fit_targeted_calibration()]. |
A 'ggplot' object.
Yaoxiang Li
Perform Probabilistic Quotient Normalization (PQN) for sample intensities. The PQN method determines a dilution factor for each sample by comparing the distribution of quotients between samples and a reference spectrum, followed by sample normalization using this dilution factor. The reference spectrum in this method is the median spectrum of all samples.
pqn_normalize(data, reference_rows = seq_len(nrow(data)))pqn_normalize(data, reference_rows = seq_len(nrow(data)))
data |
A data frame containing the sample data. The first column should contain the sample identifiers, and the rest of the columns contain the peaks to be normalized. |
reference_rows |
Rows used to calculate the reference spectrum. |
A data frame with the first column as the sample identifiers and the rest of the columns containing the normalized peak intensities.
Yaoxiang Li
Dieterle, F., Ross, A., Schlotterbeck, G., & Senn, H. (2006). Probabilistic quotient normalization as robust method to account for dilution of complex biological mixtures. Application in 1H NMR metabonomics. Analytical chemistry, 78(13), 4281-4290.
data <- data.frame( Sample = paste0("S", 1:4), feature_a = c(10, 11, 12, 13), feature_b = c(20, 18, 16, 14) ) # Display the first few rows of the original data print(head(data)) # Apply the pqn_normalize function normalized_data <- pqn_normalize(data) # Display the first few rows of the normalized data print(head(normalized_data)) # Write the normalized data to a new CSV file readr::write_csv(normalized_data, paste0(tempdir(), "/normalized_data.csv"))data <- data.frame( Sample = paste0("S", 1:4), feature_a = c(10, 11, 12, 13), feature_b = c(20, 18, 16, 14) ) # Display the first few rows of the original data print(head(data)) # Apply the pqn_normalize function normalized_data <- pqn_normalize(data) # Display the first few rows of the normalized data print(head(normalized_data)) # Write the normalized data to a new CSV file readr::write_csv(normalized_data, paste0(tempdir(), "/normalized_data.csv"))
Predict concentrations with a targeted calibration model
predict_targeted_calibration( calibration, new_data, response_col = calibration$response_col, output_col = "predicted_concentration" )predict_targeted_calibration( calibration, new_data, response_col = calibration$response_col, output_col = "predicted_concentration" )
calibration |
An object returned by [fit_targeted_calibration()]. |
new_data |
Data frame containing an instrument-response column. |
response_col |
Optional response-column override. |
output_col |
Name of the appended concentration column. |
'new_data' with predicted concentrations appended.
Yaoxiang Li
This function takes a tibble containing MRM transition data, processes each sample_id separately to detect duplicates, and adds a column 'MRM_Duplicate_Flag' indicating if a row is a duplicate based on the criteria: same polarity, less than a 1-minute retention time difference, and the same MRM transition (Q1/Q3).
process_mrm_duplicates( mrm_data, sample_name_col = "data_filename", sample_id_col = "sample_id", polarity_col = "polarity", retention_time_col = "retention_time", mass_info_col = "Mass Info", component_name_col = "component_name" )process_mrm_duplicates( mrm_data, sample_name_col = "data_filename", sample_id_col = "sample_id", polarity_col = "polarity", retention_time_col = "retention_time", mass_info_col = "Mass Info", component_name_col = "component_name" )
mrm_data |
A tibble containing the MRM transition data. |
sample_name_col |
Name of the column containing sample name information. |
sample_id_col |
Name of the column containing sample ID information. |
polarity_col |
Name of the column containing polarity information. |
retention_time_col |
Name of the column containing retention time information. |
mass_info_col |
Name of the column containing mass information. |
component_name_col |
Name of the column containing component name information. |
The original tibble with an added 'MRM_Duplicate_Flag' column.
Yaoxiang Li
## Not run: mrm_data <- tibble::tribble( ~`data_filename`, ~`sample_id`, ~polarity, ~`retention_time`, ~`Mass Info`, ~`component_name`, "Sample1", "ID1", "Positive", 1.95, "61.0 / 44.0", "Urea_pos", "Sample1", "ID1", "Positive", 8.34, "206.0 / 189.0", "Lipoamide_pos", "Sample2", "ID2", "Positive", 2.18, "339.1 / 110.0", "AICAR_pos", "Sample2", "ID2", "Positive", 1.76, "175.1 / 70.0", "Arginine_pos") processed_data <- process_mrm_duplicates( mrm_data, "data_filename", "sample_id", "polarity", "retention_time", "Mass Info", "component_name" ) print(processed_data) ## End(Not run)## Not run: mrm_data <- tibble::tribble( ~`data_filename`, ~`sample_id`, ~polarity, ~`retention_time`, ~`Mass Info`, ~`component_name`, "Sample1", "ID1", "Positive", 1.95, "61.0 / 44.0", "Urea_pos", "Sample1", "ID1", "Positive", 8.34, "206.0 / 189.0", "Lipoamide_pos", "Sample2", "ID2", "Positive", 2.18, "339.1 / 110.0", "AICAR_pos", "Sample2", "ID2", "Positive", 1.76, "175.1 / 70.0", "Arginine_pos") processed_data <- process_mrm_duplicates( mrm_data, "data_filename", "sample_id", "polarity", "retention_time", "Mass Info", "component_name" ) print(processed_data) ## End(Not run)
Runs validated preprocessing, optional blank filtering and group comparison, and records the settings and sample/feature counts at each step. QC-RLSC uses injection order within each batch and requires three QC samples per batch. Table order is used when no injection-order column is supplied.
process_omics_data( data, id_col = "sample_id", metadata_cols = NULL, sample_info = NULL, feature_info = NULL, sample_type_col = NULL, batch_col = NULL, order_col = NULL, blank_filter = FALSE, blank_value = "Blank", study_value = "Sample", ratio = 3, missing = 0.2, imputation = "half_min", normalization = "none", qc_value = "QC", qc_rsd = NULL, group_col = NULL, reference = NULL, comparison = NULL, method = "welch" )process_omics_data( data, id_col = "sample_id", metadata_cols = NULL, sample_info = NULL, feature_info = NULL, sample_type_col = NULL, batch_col = NULL, order_col = NULL, blank_filter = FALSE, blank_value = "Blank", study_value = "Sample", ratio = 3, missing = 0.2, imputation = "half_min", normalization = "none", qc_value = "QC", qc_rsd = NULL, group_col = NULL, reference = NULL, comparison = NULL, method = "welch" )
data |
A samples-by-features data frame including sample IDs. |
id_col |
Sample ID column. |
metadata_cols |
Columns excluded from intensity processing. NULL also identifies nonnumeric columns as metadata. |
sample_info |
Optional sample metadata with the same sample IDs. |
feature_info |
Optional feature metadata with feature_id and optional mz and rt columns. Retention times are in seconds. |
sample_type_col |
Column identifying blanks and study samples. |
batch_col |
Optional batch column. Every batch needs blanks and study samples. |
order_col |
Optional numeric injection-order column, unique within batch. |
blank_filter |
Whether to filter against blank samples. |
blank_value, study_value
|
Labels for blank and study samples. |
ratio |
Minimum study-to-blank intensity ratio, at least one. |
missing |
Maximum missing fraction per feature. |
imputation |
One of none, half_min, mean, median, or mode. |
normalization |
One of none, qc_rlsc, or pqn. |
qc_value |
Label identifying QC samples. |
qc_rsd |
Optional maximum QC relative standard deviation. |
group_col |
Group column. |
reference, comparison
|
Reference and comparison group labels. |
method |
Welch t-test or Wilcoxon rank-sum test. |
A list with original/processed tables, metadata, QC summaries, comparison results, blank audit, processing steps, and settings.
Yaoxiang Li
This function performs normalization on the input data matrix using the robust loess signal correction (RLSC) method. Normalization is based on Quality Control (QC) samples in the data.
qc_normalize(data, qc_label = "QC", sample_id_col = "sample_id")qc_normalize(data, qc_label = "QC", sample_id_col = "sample_id")
data |
A data frame containing the sample data. The first column should contain the sample identifiers by default named 'sample_id', and the rest of the columns contain the peaks to be normalized. QC samples should be indicated in the sample identifiers with 'QC'. |
qc_label |
A string indicating the label used for QC samples. Default is 'QC'. |
sample_id_col |
A string indicating the column name used for sample identifiers. Default is 'sample_id'. |
A data frame with the first column as the sample identifiers and the rest of the columns containing the normalized peak intensities.
Yaoxiang Li
data <- data.frame( Sample = c("QC_1", "S1", "QC_2", "S2", "QC_3", "QC_4"), feature_a = c(10, 11, 12, 13, 14, 15), feature_b = c(20, 19, 18, 17, 16, 15) ) # Display the first few rows of the original data print(head(data)) # Apply the qc_rlsc_normalize function normalized_data <- qc_normalize(data, qc_label = "QC", sample_id_col = "Sample") # Display the first few rows of the normalized data print(head(normalized_data)) # Write the normalized data to a new CSV file readr::write_csv(normalized_data, paste0(tempdir(), "/normalized_data.csv"))data <- data.frame( Sample = c("QC_1", "S1", "QC_2", "S2", "QC_3", "QC_4"), feature_a = c(10, 11, 12, 13, 14, 15), feature_b = c(20, 19, 18, 17, 16, 15) ) # Display the first few rows of the original data print(head(data)) # Apply the qc_rlsc_normalize function normalized_data <- qc_normalize(data, qc_label = "QC", sample_id_col = "Sample") # Display the first few rows of the normalized data print(head(normalized_data)) # Write the normalized data to a new CSV file readr::write_csv(normalized_data, paste0(tempdir(), "/normalized_data.csv"))
Run the omicsTools application
run_app( onStart = NULL, options = list(), enableBookmarking = NULL, uiPattern = "/" )run_app( onStart = NULL, options = list(), enableBookmarking = NULL, uiPattern = "/" )
onStart |
A function that will be called before the app is actually run.
This is only needed for |
options |
Named options that should be passed to the |
enableBookmarking |
Can be one of |
uiPattern |
A regular expression that will be applied to each |
A Shiny application.
Yaoxiang Li
Write a spectrum in MSP format
save_msp( file_path, netcdf_file, formula = "Unknown", comments = "Generated by omicsTools", precursor_ion, precursor_type = "Unknown", instrument_type = "Unknown", instrument = "Unknown", peak_list )save_msp( file_path, netcdf_file, formula = "Unknown", comments = "Generated by omicsTools", precursor_ion, precursor_type = "Unknown", instrument_type = "Unknown", instrument = "Unknown", peak_list )
file_path |
Output '.MSP' path. |
netcdf_file |
Source raw-file name. |
formula |
Molecular formula. |
comments |
Free-text comments. |
precursor_ion |
Precursor m/z. |
precursor_type |
Precursor adduct. |
instrument_type, instrument
|
Instrument metadata. |
peak_list |
Two-column matrix or data frame. |
Invisibly, the lines written to 'file_path'.
Yaoxiang Li
Transpose a feature table using its first column as identifiers
transpose_df(df)transpose_df(df)
df |
Data frame whose first column contains identifiers. |
A tibble with original measurement columns as rows and original identifiers as columns.
Yaoxiang Li
Intensity tables have one row per sample and one column per feature. Sample metadata are aligned by ID. Feature metadata use a feature_id column. Missing intensities are allowed; negative or infinite intensities are rejected.
validate_omics_data( data, id_col = "sample_id", metadata_cols = NULL, sample_info = NULL, feature_info = NULL )validate_omics_data( data, id_col = "sample_id", metadata_cols = NULL, sample_info = NULL, feature_info = NULL )
data |
A samples-by-features data frame including sample IDs. |
id_col |
Sample ID column. |
metadata_cols |
Columns excluded from intensity processing. NULL also identifies nonnumeric columns as metadata. |
sample_info |
Optional sample metadata with the same sample IDs. |
feature_info |
Optional feature metadata with feature_id and optional mz and rt columns. Retention times are in seconds. |
A list containing aligned data, feature and metadata column names, and aligned feature metadata.
Yaoxiang Li
Includes processing settings, counts, missingness, QC RSD, PCA before and after processing, blank-filter decisions, and group comparisons.
write_omics_report(result, file)write_omics_report(result, file)
result |
A result from process_omics_data(). |
file |
Output HTML file. |
Invisibly, the output file path.
Yaoxiang Li