Skip to content

Commit

Permalink
rename metrics (#4)
Browse files Browse the repository at this point in the history
* clean up lasso experiment remnants

* sync package loading with req.txt file

* clean up redudant code to check and install packages

* update dockerfile to fix config errors when building

* set up tests for mzML and Bruker file loading

* clean up main directory

* activate GHA caching

* fix `zoo` dependency problem

* remove browser() for debugging pca plots.

* update actions/cache to v4.0.2

* update GHA to use versions instead of hashes

* add tests to GHA

* add test that checks if processing was sucessful

* set smoothHalfWindowSize to a more reasonable value

* remove devtools and use pak instead

* update metrics naming (mod Z' -> FZ, mod V' -> FV, SSMD -> FS
  • Loading branch information
thomas-enzlein authored Oct 29, 2024
1 parent be44526 commit e9cefc4
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ testdata_bruker.zip
testdata_mzML.zip
Curve
mzMl
bayer_export.R
78 changes: 38 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
<img src="figures/M2ara_Logo.png" alt="M²ara overview" width="100" height="100">

# M²ara - MALDI MS Bioassays Evaluation and Classification App
# M2ara <img src="figures/logo_resized.png" align="right" height="120"/>

M²ara is a software tool to facilitate the exploration of metabolomic responses in complex matrix-assisted laser desorption/ionization mass spectrometry (MALDI MS) bioassays. The app is intended for the evaluation of metabolomic drug actions by using the mass-to-charge ratios of hundreds of metabolites and it is particularly useful in defining novel pharmacodynamic biomarkers for high-throughput applications.

M²ara is based on the R package [MALDIcellassay](https://github.com/CeMOS-Mannheim/MALDIcellassay) (published in [Unger et. al. 2021](https://www.nature.com/articles/s41596-021-00624-z), Nature Protocols) and extends its capabilities with a GUI and adds helpful features like clustering of curves, PCA analysis as well as the Curve Response Score (CRS) which enables fast screening for molecules regulated by drug treatment.

For more information please check out the [preprint](https://chemrxiv.org/engage/chemrxiv/article-details/663a1d0f418a5379b0aa286b).
For more information please check out the [preprint](https://chemrxiv.org/engage/chemrxiv/article-details/663a1d0f418a5379b0aa286b).

<img src="figures/Workflow_figure.png" alt="M²ara workflow overview" width="100%">
<img src="figures/Workflow_figure.png" alt="M²ara workflow overview" width="100%"/>

## How to use

This application simplifies the analysis of Molecular High Content Screening (MHCS) MALDI-TOF MS assay data and the evaluation of complex drug actions. After your data has been loaded, you can adjust settings as needed and start the processing. From here, you can analyze your data by selecting entries in the data table, visually inspect and rank mass features using the Curve Response Score (CRS) fingerprints, and save the curve fit and peak profile of your chosen *m/z* value.
This application simplifies the analysis of Molecular High Content Screening (MHCS) MALDI-TOF MS assay data and the evaluation of complex drug actions. After your data has been loaded, you can adjust settings as needed and start the processing. From here, you can analyze your data by selecting entries in the data table, visually inspect and rank mass features using the Curve Response Score (CRS) fingerprints, and save the curve fit and peak profile of your chosen *m/z* value.

This app is specifically designed for use with Bruker flex series raw data but also features support for mzML.

For more detailed information please take a look at the [Manual](manual.md) that is also available inside the app.

<img src="figures/gui_example.png" alt="M²ara GUI overview" width="100%">
<img src="figures/gui_example.png" alt="M²ara GUI overview" width="100%"/>

## How to install
## How to install

### R

Clone the GitHub repository to your local machine (please make sure to have R installed, tested with **R v4.3.2**) and start the app by sourcing the `app.R` file.

```bash
``` bash
git clone https://github.com/CeMOS-Mannheim/M2ara.git
```

```R
``` r
# install all packages needed
source("install_packages.R")

Expand All @@ -39,41 +37,42 @@ source("app.R")
```

### Docker
Install the [docker container](https://hub.docker.com/repository/docker/thomasenzlein/m2ara), run it and access `localhost:3838` to interact with the app.
Don't forget to change the path `c:/path/to/massSpecData` to your data so that it can be mounted when running the container.

```bash
Install the [docker container](https://hub.docker.com/repository/docker/thomasenzlein/m2ara), run it and access `localhost:3838` to interact with the app. Don't forget to change the path `c:/path/to/massSpecData` to your data so that it can be mounted when running the container.

``` bash
docker pull thomasenzlein/m2ara:main
```

```bash
``` bash
docker run -p 3838:3838 -v c:/path/to/massSpecData:/mnt thomasenzlein/m2ara:main
```

### Stand-alone installer for Windows
Use the stand-alone installer (Windows only, no R installation needed).
The installer can be downloaded [here](https://github.com/CeMOS-Mannheim/M2ara/releases/download/1.4.1/M2ara_1.4.1.exe).

Use the stand-alone installer (Windows only, no R installation needed). The installer can be downloaded [here](https://github.com/CeMOS-Mannheim/M2ara/releases/download/1.4.1/M2ara_1.4.1.exe).

## Example data
To test the app please use the example data on [FigShare](https://dx.doi.org/10.6084/m9.figshare.25736541).

To test the app please use the example data on [FigShare](https://dx.doi.org/10.6084/m9.figshare.25736541).

#### Unger2020_OATP2B1_inhibition_mzML.zip

The file contains mzML data (converted from Bruker Flex using MSConvert) originally published in Unger, et. al., 2020.

To replicate the results shown use the following parameters:

- under Settings set File Format to mzML
- set Concentration unit to nM
- set Normalization/re-calibration *m/z* to 354.1418 (D4-E3S, [M-H]<sup>-</sup>)
- set recalibration tolerance to 0.1 Da
- set normalization to *m/z*
- deactivate smoothing and activate baseline removal
- set Aggregation method to mean
- set SNR to 3
- set alignment to 0 mDa (no alignment)
- set binning tolerance to 100 ppm
- select the folder `mzML` (parent folder of the mzML files) from the .zip file, please make sure that no other files are in this folder.
- under Settings set File Format to mzML
- set Concentration unit to nM
- set Normalization/re-calibration *m/z* to 354.1418 (D4-E3S, [M-H]<sup>-</sup>)
- set recalibration tolerance to 0.1 Da
- set normalization to *m/z*
- deactivate smoothing and activate baseline removal
- set Aggregation method to mean
- set SNR to 3
- set alignment to 0 mDa (no alignment)
- set binning tolerance to 100 ppm
- select the folder `mzML` (parent folder of the mzML files) from the .zip file, please make sure that no other files are in this folder.

Alternatively, copy the [this file](https://github.com/CeMOS-Mannheim/M2ara/blob/main/tests/testthat/settings_mzML_data.csv) as `settings.csv` into the main folder of the app.

Expand All @@ -85,19 +84,18 @@ The file contains data in the Bruker Flex format originally published in Weigt,

To replicate the results shown use the following parameters:

- under Settings set File Format to Bruker Flex
- set Concentration unit to µM
- set Normalization/re-calibration *m/z* to 760.5851 (PC(34:1) [M+H]<sup>+</sup>)
- set recalibration tolerance to 0.1 Da
- set normalization to TIC
- activate smoothing and baseline removal
- set Aggregation method to mean
- set SNR to 3
- set alignment to 0 mDa (no alignment)
- set binning tolerance to 100 ppm
- select the the folder `curve` from the .zip file, make sure no other files/folders are present.
- under Settings set File Format to Bruker Flex
- set Concentration unit to µM
- set Normalization/re-calibration *m/z* to 760.5851 (PC(34:1) [M+H]<sup>+</sup>)
- set recalibration tolerance to 0.1 Da
- set normalization to TIC
- activate smoothing and baseline removal
- set Aggregation method to mean
- set SNR to 3
- set alignment to 0 mDa (no alignment)
- set binning tolerance to 100 ppm
- select the the folder `curve` from the .zip file, make sure no other files/folders are present.

Alternatively, copy the [this file](https://github.com/CeMOS-Mannheim/M2ara/blob/main/tests/testthat/settings_bruker_data.csv) as `settings.csv` into the main folder of the app.

The target is *m/z* 826.5722 (PC(36:1) [M+K]<sup>+</sup>) and *m/z* 616.1767 (Heme B [M+H]<sup>+</sup>) the pIC50 values should be 9.5 and 9.7.

6 changes: 3 additions & 3 deletions components/mainTab.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ mainTab <- function() {
selectInput(inputId = "metric",
label = "Metric",
choices = c("CRS",
"Z'",
"V'",
"SSMD",
"FZ",
"FV",
"FS",
"log2FC",
"pEC50"),
selected = defaults$errorbars,
Expand Down
2 changes: 1 addition & 1 deletion components/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ server <- function(input, output, session) {
normMz = input$normMz,
normTol = input$normTol,
normMeth = input$normMeth,
smoothHalfWindowSize = 3,
alignTol = input$alignTol * 1e-3,
halfWindowSize = input$halfWindowSize,
peakMethod = input$peakMethod)
Expand Down Expand Up @@ -118,7 +119,6 @@ server <- function(input, output, session) {
dir = appData$selected_dir
)
)

message(MALDIcellassay:::timeNow(), " processing done\n")

# write everything needed into appData
Expand Down
Binary file added figures/logo_resized.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions functions/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,14 @@ checkMetaData <- function(object) {

return(TRUE)
}

#' Extract directory path
#'
#' @param object Object of class MALDIassay
#'
#' @return
#' List, containing the data used to do the fits as well as the nlpr curve fit .
getDirectory <- function(object) {
MALDIcellassay:::stopIfNotIsMALDIassay(object)
return(object@settings$dir)
}
10 changes: 5 additions & 5 deletions functions/plotFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ plateMapPlot <- function(appData,
return(p)
}

scorePlot <- function(stats, metric = c("CRS", "V'", "Z'", "log2FC", "pEC50", "SSMD")) {
scorePlot <- function(stats, metric = c("CRS", "FV", "FZ", "log2FC", "pEC50", "FS")) {
metric <- match.arg(metric)

df <- stats %>%
mutate(direction = if_else(log2FC < 0, "down", "up")) %>%
select(c("mz", "direction")) %>%
mutate(value = pull(stats, metric))

if(metric %in% c("V'", "Z'")) {
if(metric %in% c("FV", "FZ")) {
# cut V' and Z' at zero as lower values then zero just indicate bad models
# and its prettier for visualization
df <- df %>%
Expand All @@ -284,7 +284,7 @@ scorePlot <- function(stats, metric = c("CRS", "V'", "Z'", "log2FC", "pEC50", "S
limits <- c(-1, 1)
}

if(metric %in% c("CRS", "V'", "Z'", "SSMD")) {
if(metric %in% c("CRS", "FV", "FZ", "FS")) {
df <- df %>%
mutate(value = if_else(direction == "down", -value, value))
}
Expand All @@ -300,14 +300,14 @@ scorePlot <- function(stats, metric = c("CRS", "V'", "Z'", "log2FC", "pEC50", "S
y = ylab,
col = NULL)

if(metric %in% c("V'", "Z'")) {
if(metric %in% c("FV", "FZ")) {
p <- p +
scale_y_continuous(limits = limits,
breaks = c(-1, -0.5, 0, 0.5, 1),
labels = c(1, 0.5, 0, 0.5 , 1))
}

if(metric %in% c("log2FC", "SSMD")) {
if(metric %in% c("log2FC", "FS")) {
absVal <- abs(df$value)
absVal <- absVal[!is.infinite(absVal)]
absMax <- max(absVal, na.rm = TRUE)
Expand Down
8 changes: 8 additions & 0 deletions functions/storeResults.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
storeResults <- function(appData, res, input, stats) {
appData$res <- res
appData$preprocessing <- appData$preprocessing

# rename Z', V', SSMD to FZ, FV and FS
stats <- stats %>%
rename("FZ" = `Z'`,
"FV" = `V'`,
"FS" = SSMD)


appData$stats_original <- stats # copy of original stats for updates
appData$stats <- stats

Expand Down
Loading

0 comments on commit e9cefc4

Please sign in to comment.