Moves an HDF5 dataset from one location to another within the same HDF5 file. This function automatically handles moving associated rownames and colnames datasets, creates parent groups if needed, and updates all internal references.
Character string. Current path to the dataset (e.g., “/group1/dataset1”)
dest_path
Character string. New path for the dataset (e.g., “/group2/new_name”)
overwrite
Logical. Whether to overwrite destination if it exists (default: FALSE)
4 Value
List with components. If an error occurs, all string values are returned as empty strings (““):
fn: Character string with the HDF5 filename
ds: Character string with the full dataset path to the moved dataset in its new location (group/dataset)
5 Details
This function provides a high-level interface for moving datasets within HDF5 files. The operation is efficient as it uses HDF5’s native linking mechanism without copying actual data.
Key features:
6 Examples
Code
# Move dataset to a different groupsuccess <-bdmove_hdf5_dataset("data.h5", source_path ="/old_group/my_dataset",dest_path ="/new_group/my_dataset")# Rename dataset within the same groupsuccess <-bdmove_hdf5_dataset("data.h5",source_path ="/data/old_name", dest_path ="/data/new_name",overwrite =TRUE)# Move dataset to root levelsuccess <-bdmove_hdf5_dataset("data.h5",source_path ="/deep/nested/dataset",dest_path ="/dataset")# Move with automatic group creationsuccess <-bdmove_hdf5_dataset("data.h5",source_path ="/old_location/dataset",dest_path ="/new/deep/structure/dataset")
Source Code
---title: "bdmove_hdf5_dataset"subtitle: "bdmove_hdf5_dataset"---<span class="category-badge hdf5_io_management">HDF5_IO_MANAGEMENT</span>## DescriptionMoves an HDF5 dataset from one location to another within the same HDF5 file.This function automatically handles moving associated rownames and colnames datasets, creates parent groups if needed, and updates all internal references.## Usage```rbdmove_hdf5_dataset(filename, source_path, dest_path, overwrite =FALSE)```## Arguments::: {.param-table}| Parameter | Description ||-----------|-------------||`filename`| Character string. Path to the HDF5 file ||`source_path`| Character string. Current path to the dataset (e.g., "/group1/dataset1") ||`dest_path`| Character string. New path for the dataset (e.g., "/group2/new_name") ||`overwrite`| Logical. Whether to overwrite destination if it exists (default: FALSE) |:::## Value::: {.return-value}List with components. If an error occurs, all string values are returned as empty strings (""):- **`fn`**: Character string with the HDF5 filename- **`ds`**: Character string with the full dataset path to the moved dataset in its new location (group/dataset):::## DetailsThis function provides a high-level interface for moving datasets within HDF5 files.The operation is efficient as it uses HDF5's native linking mechanism without copying actual data.Key features:\itemize{ \item Moves main dataset and associated rownames/colnames datasets \item Creates parent directory structure automatically \item Preserves all dataset attributes and properties \item Updates internal dataset references \item Efficient metadata-only operation \item Comprehensive error handling}## Examples```{r}#| eval: false#| code-fold: show# Move dataset to a different groupsuccess <-bdmove_hdf5_dataset("data.h5", source_path ="/old_group/my_dataset",dest_path ="/new_group/my_dataset")# Rename dataset within the same groupsuccess <-bdmove_hdf5_dataset("data.h5",source_path ="/data/old_name", dest_path ="/data/new_name",overwrite =TRUE)# Move dataset to root levelsuccess <-bdmove_hdf5_dataset("data.h5",source_path ="/deep/nested/dataset",dest_path ="/dataset")# Move with automatic group creationsuccess <-bdmove_hdf5_dataset("data.h5",source_path ="/old_location/dataset",dest_path ="/new/deep/structure/dataset")```