get_bids_samples {bidsr} | R Documentation |
'BIDS' samples table class
Description
A tabular containing a list of samples and their metadata.
The class is a child class of BIDSTabular
, hence see
the methods there.
The original specification is at
https://bids-specification.readthedocs.io/en/stable/modality-agnostic-files.html#samples-file.
Usage
get_bids_samples(x, ...)
BIDSTabularSamples(content, meta = NULL)
Arguments
x |
R object such as file path, project instances, etc. |
... |
passed to other methods or ignored |
content , meta |
see |
Value
A BIDSTabularSamples
instance inheriting
BIDSTabular
.
Author(s)
Zhengjia Wang
Examples
# basic
tabular <- BIDSTabularSamples(
data.frame(
sample_id = "sample-001",
participant_id = "sub-001",
sample_type = "cell line"
)
)
tabular
# convert existing tabular
tabular <- BIDSTabular(
data.frame(
sample_id = "sample-001",
participant_id = "sub-001",
sample_type = "cell line"
)
)
tabular <- as_bids_tabular(tabular, cls = BIDSTabularSamples)
# save to tsv
tsv <- file.path(tempdir(), "samples.tsv")
paths <- save_bids_tabular(tabular, tsv)
print(paths)
# use base R to read
read.table(tsv, header = TRUE, na.strings = "n/a")
# get sidecar
cat(readLines(paths$sidecar_path), sep = "\n")
# clean up
unlink(tsv)
unlink(paths$sidecar_path)
[Package bidsr version 0.1.0 Index]