Create a sampleMap from an experiment list and phenoData dataframe
Source:R/generateMap.R
generateMap.Rd
This function helps create a sampleMap in preparation of a
MultiAssayExperiment
object. This especially useful when the
sample identifiers are not very different, as in the case of TCGA barcodes.
An idConverter
function can be provided to truncate such sample
identifiers and obtain patient identifiers.
Arguments
- experiments
A named
list
of experiments compatible with theMultiAssayExperiment
API- colData
A
data.frame
of clinical data with patient identifiers as rownames- idConverter
A function to be used against the sample or specimen identifiers to match those in the rownames of the
colData
(default NULL)- sampleCol
A single string indicating the sample identifiers column in the colData dataset
- patientCol
A single string indicating the patient identifiers in colData, "row.names" extracts the colData row names
- ...
Additonal arguments to pass to the 'idConverter' function.
Examples
## Minimal example
expList <- list(assay1 = matrix(1:6, ncol = 2L,
dimnames = list(paste0("feature", 1:3), c("A-J", "B-J"))),
assay2 = matrix(1:4, ncol = 2,
dimnames = list(paste0("gene", 1:2), c("A-L", "B-L"))))
## Mock colData
myPheno <- data.frame(var1 = c("Yes", "No"), var2 = c("High", "Low"),
row.names = c("a", "b"))
## A look at the identifiers
vapply(expList, colnames, character(2L))
#> assay1 assay2
#> [1,] "A-J" "A-L"
#> [2,] "B-J" "B-L"
rownames(myPheno)
#> [1] "a" "b"
## Use 'idConverter' to correspond sample names to patient identifiers
generateMap(expList, myPheno,
idConverter = function(x) substr(tolower(x), 1L, 1L))
#> DataFrame with 4 rows and 3 columns
#> assay primary colname
#> <factor> <character> <character>
#> 1 assay1 a A-J
#> 2 assay1 b B-J
#> 3 assay2 a A-L
#> 4 assay2 b B-L