Add sample annotation to Skyline data frame

add_sample_annotation(data, annot_file)

Arguments

data

LipidomicsExperiment object.

annot_file

CSV file or a data.frame with at least 2 columns, sample names & group(s).

Value

LipidomicsExperiment with sample group information.

Examples

datadir <- system.file("extdata", package = "lipidr") # all csv files filelist <- list.files(datadir, "data.csv", full.names = TRUE) d <- read_skyline(filelist)
#> Successfully read 3 methods. #> Your data contain 58 samples, 10 lipid classes, 277 lipid molecules.
# Add clinical info to existing LipidomicsExperiment object clinical_file <- system.file("extdata", "clin.csv", package = "lipidr") d <- add_sample_annotation(d, clinical_file) colData(d)
#> DataFrame with 58 rows and 3 columns #> group Diet BileAcid #> <character> <character> <character> #> S1A NormalDiet_water Normal water #> S2A NormalDiet_water Normal water #> S3A NormalDiet_water Normal water #> S4A NormalDiet_water Normal water #> S5A NormalDiet_water Normal water #> ... ... ... ... #> TQC_8 QC QC QC #> TQC_9 QC QC QC #> TQC_10 QC QC QC #> TQC_11 QC QC QC #> TQC_12 QC QC QC
d$group
#> [1] "NormalDiet_water" "NormalDiet_water" "NormalDiet_water" "NormalDiet_water" #> [5] "NormalDiet_water" "NormalDiet_water" "NormalDiet_water" "NormalDiet_water" #> [9] "NormalDiet_water" "NormalDiet_water" "NormalDiet_water" "NormalDiet_DCA" #> [13] "NormalDiet_DCA" "NormalDiet_DCA" "NormalDiet_DCA" "NormalDiet_DCA" #> [17] "NormalDiet_DCA" "NormalDiet_DCA" "NormalDiet_DCA" "NormalDiet_DCA" #> [21] "NormalDiet_DCA" "NormalDiet_DCA" "HighFat_water" "HighFat_water" #> [25] "HighFat_water" "HighFat_water" "HighFat_water" "HighFat_water" #> [29] "HighFat_water" "HighFat_water" "HighFat_water" "HighFat_water" #> [33] "HighFat_water" "HighFat_DCA" "HighFat_DCA" "HighFat_DCA" #> [37] "HighFat_DCA" "HighFat_DCA" "HighFat_DCA" "HighFat_DCA" #> [41] "HighFat_DCA" "HighFat_DCA" "HighFat_DCA" "HighFat_DCA" #> [45] "blank" "blank" "QC" "QC" #> [49] "QC" "QC" "QC" "QC" #> [53] "QC" "QC" "QC" "QC" #> [57] "QC" "QC"
# Subset samples using clinical information # Note we are subsetting columns d[, d$group == "QC"]
#> class: LipidomicsExperiment #> dim: 279 12 #> metadata(2): summarized dimnames #> assays(3): Retention Time Area Background #> rownames(279): 1 2 ... 278 279 #> rowData names(26): filename Molecule ... total_cs Class #> colnames(12): TQC_1 TQC_2 ... TQC_11 TQC_12 #> colData names(3): group Diet BileAcid
# Subset lipids using lipid annotation # Note we are subsetting rows d[rowData(d)$istd, ]
#> class: LipidomicsExperiment #> dim: 10 58 #> metadata(2): summarized dimnames #> assays(3): Retention Time Area Background #> rownames(10): 62 63 ... 220 279 #> rowData names(26): filename Molecule ... total_cs Class #> colnames(58): S1A S2A ... TQC_11 TQC_12 #> colData names(3): group Diet BileAcid