postvocs is an R package designed for automated post-processing of Shimadzu GC-MS volatile organic compound (VOC) data.
The package provides a complete workflow for transforming raw GC-MS export files into analyzable compound abundance matrices. It automates:
The workflow is fully modular, allowing users to perform individual processing steps or run the complete pipeline from raw GC-MS files to final VOC screening results.
The development version can be installed from GitHub using:
# install.packages("devtools")
devtools::install_github("HanXT97/postvocs")Load the package:
library(postvocs)The postvocs workflow converts raw GC-MS exports into processed VOC analysis results:
process_gcms_txt()batch_process_gcms()extract_peak_areas()build_cas_abundance()annotate_compounds()filter_by_frequency()save_postvocs_results()save_gcms_results()Parse all Shimadzu GC-MS exported .txt files and map raw
filenames to sample names.
batch <- batch_process_gcms(
txt_dir = "data-raw/txt",
sample_file = "data-raw/SampleID.xlsx"
)Extract CAS numbers and total peak areas from parsed GC-MS results.
areas <- extract_peak_areas(batch)Construct a CAS × sample abundance matrix.
abund <- build_cas_abundance(areas)Annotate compounds using either a user-provided library or chemical databases.
Example using webchem:
annotated <- annotate_compounds(
abund,
lib_source = "webchem"
)Remove unreliable compounds based on blank contamination and occurrence frequency.
result <- filter_by_frequency(
abundance_data = annotated,
sample_group_file = "data-raw/sample_groups.xlsx",
group_col = "Combined_Treatment"
)Save processed VOC results.
save_postvocs_results(
result,
output_dir = "results",
format = "xlsx"
)| Function | Description |
|---|---|
process_gcms_txt() |
Parse a single GC-MS exported .txt file |
batch_process_gcms() |
Batch process multiple GC-MS files with sample name mapping |
extract_peak_areas() |
Extract CAS numbers and peak area information |
build_cas_abundance() |
Generate CAS × sample abundance matrix |
annotate_compounds() |
Annotate compounds using databases or custom libraries |
filter_by_frequency() |
Perform frequency-based VOC screening with blank removal |
save_postvocs_results() |
Export processed VOC results as CSV/XLSX |
save_gcms_results() |
Save raw parsing outputs including peak tables and search results |
postvocs accepts multiple input formats:
This allows users to integrate the package into different GC-MS analysis pipelines.
The package automatically protects CAS numbers during export by adding single quotes when necessary. It checks whether a leading quote already exists before adding one, avoiding duplication.
This prevents Excel from automatically converting CAS identifiers into dates or other unintended formats.
annotate_compounds() supports:
When using online annotation services:
Results can be exported as Excel workbooks containing multiple related tables, including:
filter_by_frequency() provides detailed tracking
information:
Detailed documentation is available through R help:
library(postvocs)
?process_gcms_txt
?batch_process_gcms
?extract_peak_areas
?build_cas_abundance
?annotate_compounds
?filter_by_frequency
?save_postvocs_results
?save_gcms_resultsExample datasets and workflows will be provided in future releases.
A typical analysis requires:
project/
|
├── data-raw/
│ ├── txt/
│ │ ├── sample1.txt
│ │ ├── sample2.txt
│ │
│ ├── SampleID.xlsx
│
└── results/
SampleID.xlsx contains sample identification and
grouping information with columns:
| Column | Description |
|---|---|
SampleID |
Sample identifier (e.g., 01, 02, …) |
SampleName |
User-defined sample name |
Factor1 |
First grouping factor (e.g., Species) |
Factor2 |
Second grouping factor (e.g., Treatment) |
Combined_Factor |
Combined grouping factor for analysis (e.g., Species_Treatment) |
This file is used for both sample name mapping in
batch_process_gcms() and frequency screening in
filter_by_frequency().
Contributions, bug reports, and feature requests are welcome.
Please submit issues or pull requests through GitHub:
https://github.com/HanXT97/postvocs
GPL-3 © Xiaotao Han