Description Usage Arguments Details Value See Also Examples
Produces a spatial plot of the given MSI data, designed to be used with combine_peaklists and associated load_* functions. Usually would be used on a subset of the Peak-list produced by combine_peaklist, those near a particular mass for example, see example below for an example of this example.
1 2 | spatial_plot(df.peak, df.spec, plot.var = "intensity", id.var = "Acq",
x.var = "X", y.var = "Y", return.plot = FALSE, print.plot = TRUE)
|
df.peak |
A Peak-list data.frame as produced by
|
df.spec |
A Spectra-list data.frame as produced by
|
plot.var |
A string matching the variable name in |
id.var |
A string matching the variable name that uniquely
identifies spectra in both |
x.var |
A string matching the variable name in |
y.var |
A string matching the variable name in |
return.plot |
A logical value that if TRUE will cause
|
print.plot |
A logical value indicating whether the plot should be printed to the current graphics device. |
Note spatial_plot
assumes that there are no occurrences of multiple
peaks from the same spectrum in the input peak-list df.peak
. Any such
occurrences should be dealt with before calling spatial_plot, as otherwise it
will throw an error.
On successful completion returns either a ggplot object or the
data.frame used to produce said ggplot object, depending on the value of
return.plot
.
If return.plot
is FALSE, the returned data.frame will contain rows
that represent unique X-Y coordinate pairs in a rectanglular region extending
from the minimum X-coordinate in df.spec
minus one to the maximum plus
one (inclusive), and similarly from the minimum Y-coordinate in
df.spec
minus one to the maximum plus one (inclusive), and for each
such unique X-Y coordinate pair four columns represent the relevant plotting
information:
x.var: Columned named with the string x.var
, containing the
relevant X-coordinate values.
y.var: Columned named with the string y.var
, containing the
relevant Y-coordinate values.
plot.var: Column named with the string plot.var
, containing
the relevant values, including NA for missing values.
empty: A logical column indicating X-Y coordinate pairs from which
spectra were acquired, but no peaks are present in df.peak
. This
is used to distinguish such X-Y coordnate pairs from those in which no
spectrum was acquired at all.
If return.plot
is TRUE, the returned ggplot object is a geom_tile plot
with axes labelled with x.var
and y.var
respectively, a legend
for plot.var
, X-Y coordinate pairs (or pixels) for which no spectrum
was acquired blank, and X-Y coordinate pairs (or pixels) for which a spectrum
was acquired but no peaks are present in df.peak
in darkened grey. The
plot uses coord_fixed() to match X and Y scales.
Intended to be used with combine_peaklists
, associated
load_*
functions, and the ggplot2
package
(https://cran.r-project.org/web/packages/ggplot2/index.html),
hadley's book on ggplot2 is a good resource, see his github
(https://github.com/hadley/ggplot2-book) or you can access samples
and/ or buy his book from the website (http://ggplot2.org/book).
1 2 3 4 5 6 7 8 9 10 11 12 | i.path = system.file("extdata", "test1", package = "dipps")
n.empty = combine_peaklists(i.path)
o.name = basename(i.path)
df.spec = load_speclist(o.name)
df.peak = load_peaklist(o.name)
# Select a m/z window of interest, in this case m/z = 1570.677 +/- 0.1 Da
df.cal = subset(df.peak, abs(m.z - 1570.677) < 0.1)
# Plot log-intensity of said m/z window.
df.cal$log.intensity = log1p(df.cal$intensity)
p = spatial_plot(df.cal, df.spec, plot.var = "log.intensity")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.