mzPointer <- mzPlotter::getMzPointer(path = params$path)
mzXMLHeader <- mzPlotter::readMzSpec(mzPointer)

Summary Tables{.tabset .tabset-fade .tabset-pills}

Instrument Information

knitr::kable(as.data.frame(mzR::instrumentInfo(mzPointer)[1:5]))

Run information

msLevels <- unique(mzXMLHeader$msLevel)


lows <- round(sapply(split(mzXMLHeader$lowMZ, mzXMLHeader$msLevel), min), 1)
highs <- round(sapply(split(mzXMLHeader$highMZ, mzXMLHeader$msLevel), max), 1)
spectra <- lengths(split(mzXMLHeader$msLevel, mzXMLHeader$msLevel))

a <- t(rbind(`MS level` = msLevels,
             `low mass` = lows,
             `high mass` = highs,
             `number of spectra` = spectra))

knitr::kable(a)
mzRpolarity <- unique(mzXMLHeader$polarity)

if(all(c(0, 1) %in% mzRpolarity)) {
  polarity <- c("Positive and Negative")
} else { 

  if(0 %in% mzRpolarity) {
    polarity <- c("Negative")
  }

  if(1 %in% mzRpolarity) {
    polarity <- c("Positive")
  }

  if(-1 %in% mzRpolarity) {
    polarity <- c("Unknown")
  }

}

cat("Detected Polarity: ", polarity)

Summary Plots {.tabset .tabset-fade .tabset-pills}

MS^1^ Summary

Positive Mode:

if (1 %in% mzRpolarity) {
  mzPlotter::figure1(mzPointer = mzPointer,
                     pol = mzRpolarity)
}

Negative Mode:

if (0 %in% mzRpolarity) {
  mzPlotter::figure1(mzPointer = mzPointer,
                     pol = mzRpolarity)
} 

MS^2^ Summary

Positive Mode:

if (2 %in% msLevels) {
  if (1 %in% mzRpolarity) {
    mzPlotter::figure2(mzPointer = mzPointer,
                       pol = 1)
  }
} else {
  print("Please double-check that your sample has MS2 spectra.")
}

Negative Mode:

if (2 %in% msLevels) {
  if (0 %in% mzRpolarity) {
    mzPlotter::figure2(mzPointer = mzPointer,
                       pol = 0)
  }
} else {
  print("Please double-check that your sample has MS2 spectra.")
}


chasemc/mzPlotter documentation built on Nov. 19, 2019, 12:39 a.m.