This helper function creates custom sample names for plot data object functions
custom_sampnames(
omicsData,
firstn = NULL,
from = NULL,
to = NULL,
delim = NULL,
components = NULL,
pattern = NULL,
...
)
an object of the class 'pepData', 'proData',
'metabData', 'lipidData', 'nmrData', or 'seqData', created by as.pepData
,
as.proData
, as.metabData
, as.lipidData
, as.nmrData
,
or as.seqData
, respectively.
an integer specifying the first n characters to keep as the sample name. This argument is optional.
an integer specifying the start of the range of characters to keep as the sample name. This argument is optional. If this argument is specified, 'to' must also be specified.
an integer specifying the end of the range of characters to keep as the sample name. This argument is optional. If this argument is specified, 'from' must also be specified.
character delimiter by which to separate sample name components. This argument is optional. If this argument is specified, 'components' must also be specified.
integer vector specifying which components separated by the delimiter should be kept as the custom sample name. This argument is optional. If this argument is specified, 'delim' must also be specified.
character string specifying the regex pattern to use to extract substrings from the sample names
extra arguments passed to regexpr if pattern is specified
Object of same class as omicsData, with added column in f_data named 'VizSampNames'.
This function can be used to create custom (and shorter) sample names to be used when plotting so that axis labels are not so long that they interfere with the graph itself. To use the custom sample names when plotting, specify the optional argument 'use_VizSampNames = TRUE'.
library(pmartRdata)
mypep <- edata_transform(omicsData = pep_object, data_scale = "log2")
plot(mypep)
# specify new names using firstn argument
results <- custom_sampnames(omicsData = mypep, firstn = 9)
plot(results, use_VizSampNames = TRUE)
# specify new names using from and to arguments
results <- custom_sampnames(omicsData = mypep, from = 1, to = 9)
plot(results, use_VizSampNames = TRUE)
# specify new names using delim and components arguments
results <- custom_sampnames(omicsData = mypep, delim = "_", components = c(1, 2))
plot(results, use_VizSampNames = TRUE)
## specify new names using pattern arguments (regex)
# match everything after "Sample_"
pattern1 <- "[0-9]+_[0-9A-Za-z]+_[A-Z]"
results <- custom_sampnames(omicsData = mypep, pattern = pattern1)
plot(results, use_VizSampNames = TRUE)
# match "Sample_" and the number after it
pattern2 <- "^Sample_[0-9]+"
results <- custom_sampnames(omicsData = mypep, pattern = pattern2)
plot(results, use_VizSampNames = TRUE)