Skip to content

Commit

Permalink
fix: plot,LamaParama method
Browse files Browse the repository at this point in the history
- Fix `plot,LamaParama`: x and y coordinates were switched.
- Small changes in the vignette.
- Ensure .R files are loaded in the correct order.
  • Loading branch information
jorainer committed Apr 4, 2024
1 parent ab847b0 commit 9bb7bd5
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 57 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ Collate:
'MPI.R'
'MsExperiment-functions.R'
'MsExperiment.R'
'XcmsExperiment.R'
'PlainTextParam.R'
'RDataParam.R'
'XcmsExperiment-functions.R'
'XcmsExperiment-plotting.R'
'XcmsExperiment.R'
'c.R'
'cwTools.R'
'databases.R'
Expand Down
2 changes: 2 additions & 0 deletions R/PlainTextParam.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' @include XcmsExperiment.R

This comment has been minimized.

Copy link
@jorainer

jorainer Apr 4, 2024

Author Collaborator

@philouail , this ensures that the XcmsExperiment.R file is loaded before PlainTextParam.R - to avid the warning message when loading the package.


#' @title Store contents of `MsExperiment` and `XcmsExperiment` objects as
#' plain text files
#'
Expand Down
3 changes: 2 additions & 1 deletion R/methods-Params.R
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,8 @@ setMethod("plot", signature(x = "LamaParama"),
zero_weight = x@zeroWeight,
bs = x@bs)
datap <- x@rtMap[[index]]
plot(datap, type = "p", xlab = xlab, ylab = ylab, col = colPoints, ...)
plot(datap[, 2L], datap[, 1L], type = "p", xlab = xlab, ylab = ylab,

This comment has been minimized.

Copy link
@jorainer

jorainer Apr 4, 2024

Author Collaborator

@philouail indeed, the x and y coordinates where switched. datap has columns "ref" and "obs", but we were plotting chrom Peaks ("obs") on x and lamas ("ref") on y. This just switches them.

col = colPoints, ...)
points(model, type = "l", col = colFit)
})

Expand Down
92 changes: 46 additions & 46 deletions man/XcmsExperiment.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 26 additions & 9 deletions vignettes/xcms.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ f[f != "QC"] <- NA
ref <- filterFeatures(ref, PercentMissingFilter(threshold = 0, f = f))
ref_mz_rt <- featureDefinitions(ref)[, c("mzmed","rtmed")]
head(ref_mz_rt)
nrow(ref_mz_rt)
```

This is what the `lamas` input should look like for alignment. In terms of
Expand Down Expand Up @@ -1396,29 +1397,45 @@ abline(v = mtch[[1]]$obs)
```

The overlay of BPC above provides insight into the correlation between accurate
alignment and the presence of peaks matching with `lamas.` Furthermore, a more
detailed examination of the matching and the model used for fitting each file
is possible. Numerical information can be obtained using the
alignment and the presence of peaks matching with `lamas`. For this particular
sample no chromatographic peaks were matched to the `lamas` between 2500 and
3000 seconds and hence the alignment in that region was not good. For the second
file, chrom peaks could also be matched in that region resulting in a better
alignment.

```{r}
par(mfrow = c(1, 1))
plot(bpc[1, 2], col = "#00000080", main = "Distribution CP matched to Lamas")
points(rtime(bpc_tst_adj[1, 2]), intensity(bpc_tst_adj[1, 2]), type = "l",
col = "#0000ff80")
grid()
abline(v = mtch[[2]]$obs)
```

Furthermore, a more detailed examination of the matching and the model used for
fitting each file is possible. Numerical information can be obtained using the
`summarizeLamaMatch()` function. From this, the percentage of chromatographic
peaks utilized for alignment can be computed relative to the total number of
peaks in the file. Additionally, it is feasible to directly `plot()` the
`param` object for the file of interest, showcasing the distribution of these
peaks in the file. Additionally, it is feasible to directly `plot()` the `param`
object for the file of interest, showcasing the distribution of these
chromatographic peaks along with the fitted model line.

```{r}
#access summary of matches and model information
#' access summary of matches and model information
summary <- summarizeLamaMatch(param)
summary
# coverage for each file
#' coverage for each file
summary$Matched_peaks / summary$Total_peaks * 100
#access the information on the model of for the first file
#' access the information on the model of for the first file
summary$Model_summary[[1]]
# Plot obs vs. ref with fitting line
#' Plot obs vs. ref with fitting line
plot(param, index = 1L, main = "ChromPeaks versus Lamas for the first file",
colPoint = "red")
abline(0, 1, lty = 3, col = "grey")
grid()
```


Expand Down

0 comments on commit 9bb7bd5

Please sign in to comment.