Dear all,
I have set the identical mass resolution and mass range when reading the files, however, the resulting mz values and number of mz values were still different among the MSI data, and as such I was unable to combine the files.
Please see the demo code below:
library(Cardinal)
mse1 <- readMSIData(file = "Test/06_20_ven_cru_pos_rep1.imzML",
resolution = 10,
units = "ppm"
mass.range = c(310, 890)
)
mse2 <- readMSIData(file = "Test/06_20_ner_cru_pos_rep1.imzML",
resolution = 10,
units = "ppm",
mass.range = c(310, 890)
)
all.equal(mz(mse1), mz(mse2))
[1] "Numeric: lengths (19971, 19580) differ”
What I did was to use the mean spectrum of one of the MSI data as a reference, and aligned all other MSI files to the reference. With this approach, I could successfully combine all MSI files.
Please see the demo code below:
library(Cardinal)
#(1) Read files
path <- list.files("Test/", pattern = ".imzML", full.names=TRUE, recursive=TRUE)
mse <- vector(mode="list", length=length(path))
for(i in 1:length(path)){
mse[[i]] <- readMSIData(file = path[i],
resolution = 10,
units = "ppm"
)
}
#(2) Set reference peaks, here I use the first MSI data
ref <- summarizeFeatures(mse[[1]], FUN="mean") %>%
peakPick(method="mad",SNR=3) %>%
peakAlign("mean", tolerance=15, units="ppm") %>%
peakFilter() %>%
process()
#(3) Align MSI data to the reference peaks
mse_aligned <- vector(mode="list", length=length(path))
for(i in 1:length(mse)){
mse_aligned[[i]] <- mse[[i]] %>%
normalize(method="tic") %>%
peakBin(ref=mz(ref), tolerance=15, units="ppm") %>%
process()
}
#(4) Combine aligned MSI data
MSIData <- do.call(Cardinal::cbind, mse_aligned)
I am wondering why readMSIData() function did not yield identical m/z values for raw centroid MSI datasets? Is this a bug?
Are there alternative approaches to efficiently combine MSI datasets acquired in centroid mode?
Thank a lot.
Yonghui Dong