| Title: | Read, Parse and Visualize 'XVG'/'XPM' Files from Molecular Dynamics |
|---|---|
| Description: | Provides tools for reading, parsing and visualizing simulation data stored in 'xvg'/'xpm' file formats (commonly generated by 'GROMACS' molecular dynamics software). Streamlines post-processing and analysis of molecular dynamics ('MD') simulation outputs, enabling efficient exploration of molecular stability and conformational changes. Supports import of trajectory metrics ('RMSD', energy, temperature) and creation of publication-ready visualizations through integration with 'ggplot2'. |
| Authors: | BeiHao Li [aut, cre] |
| Maintainer: | BeiHao Li <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.2 |
| Built: | 2026-05-25 09:52:51 UTC |
| Source: | https://github.com/rightsz/xvm |
write the data component of an xvg_data object (or multiple objects) to a delimited text file,
controlled via the sep parameter rather than file extension detection.
export_xvg(xvg_data, file, sep = "\t", row.names = FALSE, merge = FALSE, ...)export_xvg(xvg_data, file, sep = "\t", row.names = FALSE, merge = FALSE, ...)
xvg_data |
An object of class |
file |
Path to the output file (any extension is acceptable). |
sep |
Field separator (e.g., "\t" for TSV, "," for CSV). Default is "\t". |
row.names |
Logical, whether to write row names. Default is FALSE. |
merge |
Logical, whether to merge multiple xvg_data objects before exporting. Default is FALSE. |
... |
Additional arguments passed to |
Invisibly returns the path to the written file.
## Not run: xvg <- read_xvg(system.file("extdata/rmsd.xvg", package = "xvm")) # Export as TSV export_xvg(xvg, "rmsd.tsv", sep = "\t") # Export as CSV export_xvg(xvg, "rmsd.csv", sep = ",") ## End(Not run)## Not run: xvg <- read_xvg(system.file("extdata/rmsd.xvg", package = "xvm")) # Export as TSV export_xvg(xvg, "rmsd.tsv", sep = "\t") # Export as CSV export_xvg(xvg, "rmsd.csv", sep = ",") ## End(Not run)
plot xpm data using ggplot2
plot_xpm(xpm_data, interpolate = FALSE)plot_xpm(xpm_data, interpolate = FALSE)
xpm_data |
a xpm object returned by read_xpm |
interpolate |
logical indicating whether to use raster interpolation (TRUE) or discrete tiles (FALSE). Default is FALSE. |
a ggplot2 object
library(xvm) xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) plot_xpm(xpm_data) # plot the xpm data using plot_xpm() functionlibrary(xvm) xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) plot_xpm(xpm_data) # plot the xpm data using plot_xpm() function
creates 3d visualization of xpm data with scatter plot.
plot_xpm_3d(xpm_data, reversescale = FALSE, point_size = 2)plot_xpm_3d(xpm_data, reversescale = FALSE, point_size = 2)
xpm_data |
a xpm object (from |
reversescale |
whether to reverse the color scale; default is FALSE |
point_size |
the size of the points in the scatter plot; default is 2 |
a plotly object
library(xvm) xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) plot_xpm_3d(xpm_data) # plot 3D scatter plot from xpm filelibrary(xvm) xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) plot_xpm_3d(xpm_data) # plot 3D scatter plot from xpm file
creates dual-panel visualizations of xpm data with scatter or area plots.
plot_xpm_facet(xpm_data, plot_type = "scatter")plot_xpm_facet(xpm_data, plot_type = "scatter")
xpm_data |
a xpm object (from |
plot_type |
visualization type: "scatter" (default) or "area". |
a ggplot2 object with:
Dual facets showing x/y axis relationships
Automatic data transformation for visualization
NULL if invalid plot_type specified
library(xvm) xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) plot_xpm_facet(xpm_data) # plot pseudo-3D from xpm filelibrary(xvm) xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) plot_xpm_facet(xpm_data) # plot pseudo-3D from xpm file
plot xvg data using ggplot2
plot_xvg( xvg_data, merge = FALSE, title = NULL, subtitle = NULL, use_color_scale = NULL, ... )plot_xvg( xvg_data, merge = FALSE, title = NULL, subtitle = NULL, use_color_scale = NULL, ... )
xvg_data |
xvg data object returned by read_xvg |
merge |
logical; if TRUE and multiple datasets provided, merge them (default: FALSE) |
title |
chart title (default uses xvg file's title) |
subtitle |
chart subtitle (default uses xvg file's subtitle) |
use_color_scale |
custom color scale function (e.g., ggsci::scale_color_bmj) to override default colors |
... |
additional parameters passed to ggplot2::geom_line |
a ggplot2 object
library(xvm) rmsd_file_path <- system.file("extdata/rmsd.xvg", package = "xvm") rmsd_data <- read_xvg(rmsd_file_path) plot_xvg(rmsd_data) # plot the xvg data using plot_xvg() functionlibrary(xvm) rmsd_file_path <- system.file("extdata/rmsd.xvg", package = "xvm") rmsd_data <- read_xvg(rmsd_file_path) plot_xvg(rmsd_data) # plot the xvg data using plot_xvg() function
This function reads xpm (X PixMap) files, validates their existence, and returns parsed data structures in a list format.
read_xpm(xpm_files)read_xpm(xpm_files)
xpm_files |
a character vector containing paths to one or more xpm files. |
The function performs the following operations:
Validates input type (must be character vector)
Checks for file existence and filters missing files with warnings
Reads valid files and parses them using parse_xpm()
Returns aggregated results in a named list
list with the following components:
data - Data frame containing matrix values with coordinates
title - Chart title extracted from xpm
legend - Legend text extracted from xpm
x_label - X-axis label extracted from xpm
y_label - Y-axis label extracted from xpm
color_map - Named list mapping color codes to hex values
color_values - Named list mapping color codes to numeric values
library(xvm) # Retrieve the path to the example file included in the package xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) # read the xpm file using read_xpm() function names(xpm_data)library(xvm) # Retrieve the path to the example file included in the package xpm_file_path <- system.file("extdata/gibbs.xpm", package = "xvm") xpm_data <- read_xpm(xpm_file_path) # read the xpm file using read_xpm() function names(xpm_data)
read one or more GROMACS-generated xvg files
read_xvg(xvg_files, skip_comments = TRUE)read_xvg(xvg_files, skip_comments = TRUE)
xvg_files |
character vector of xvg file paths |
skip_comments |
logical indicating whether to skip comment lines (default: TRUE) |
Named list containing xvg data, using filenames (without extension) as keys
library(xvm) # Retrieve the path to the example file included in the package: rmsd_file_path <- system.file("extdata/rmsd.xvg", package = "xvm") rmsd_data <- read_xvg(rmsd_file_path) # read the xvg file using read_xvg() function names(rmsd_data)library(xvm) # Retrieve the path to the example file included in the package: rmsd_file_path <- system.file("extdata/rmsd.xvg", package = "xvm") rmsd_data <- read_xvg(rmsd_file_path) # read the xvg file using read_xvg() function names(rmsd_data)
compute basic summary statistics (mean, sd, min, median, max) for each variable in one or more xvg_data objects.
summary_xvg(xvg_data, merge_results = FALSE)summary_xvg(xvg_data, merge_results = FALSE)
xvg_data |
a list of class 'xvg_data' or a list containing multiple 'xvg_data' objects, as returned by |
merge_results |
logical, whether to combine results from multiple objects (default: FALSE). When TRUE, results will include a 'group' column identifying the source. |
a data.frame with columns:
(Optional) Source identifier when processing multiple objects with merge_results=TRUE.
Name of the variable (column) in the xvg data.
Arithmetic mean of that variable.
Standard deviation.
Minimum value.
Median value.
Maximum value.
path <- system.file("extdata/rmsd.xvg", package = "xvm") xvg <- read_xvg(path) summary_xvg(xvg)path <- system.file("extdata/rmsd.xvg", package = "xvm") xvg <- read_xvg(path) summary_xvg(xvg)