Enrich an annotation table with Sample_ID from a Bruker HyStar sample list
Source:R/annotation.R
get_annot_sampleid.RdReads a Bruker HyStar sample list (xlsx), extracts Result.Path and
Sample.Comment, derives the run name from the path, and joins it to the
annotation table on Source_file, replacing any existing Sample_ID.
Arguments
- annotation
Annotation data frame (e.g. from
get_annot_fragpipe()orread_annot()).- file_sample_list
Path to the Bruker HyStar sample list
.xlsxfile.- keep_all
Keep every annotation row (left join, unmatched
Sample_IDleftNA) instead of dropping the unmatched ones. DefaultFALSE, the historical inner-join behaviour.
Value
annotation with the Sample_ID column filled from
Sample.Comment in the sample list. Rows without a match are dropped
(inner join) unless keep_all = TRUE.
Details
The join is easy to get silently wrong — the two sides must agree on the run
naming, and with the default inner join a mismatch simply removes rows. This
function therefore warns when nothing matched (showing example values from
both sides) and when only some rows matched (naming the ones dropped);
keep_all = TRUE switches to a left join so no annotation row is ever lost.
Examples
if (FALSE) { # \dontrun{
annot <- get_annot_fragpipe("2_data")
get_annot_sampleid(annot, "1_documentation/sample_list.xlsx")
} # }