Raman data can be tedious to import and analyse, when exported from Renishaw Wire. I found myself writing similar pieces of code over an over, to solve the same problems and have collected it all in this R package for easy use. This document will demonstrate how to work with curve fit results. Another vignette is available describing functions for spectral maps.
Curve fit results from wire can be exported to a set of .txt
files. The files should be saved indicating the peak and corresponding feature, e.g. 2D FWHM.txt
for the Full-width at Half-max of the 2D peak (use int
for intensity and pos
for position).
The package includes some sample data that will be used for demonstration purposes. cf_folder
should point to the folder containing your curve fit results.
library(tidyverse) library(gRaphene) cf_folder <- system.file("extdata/graphene_curve_fit_export", package = "gRaphene") data_cf <- gr_cf_read(cf_folder)
Common graphene ratios (D/G
, 2D/G
and D/Dp
) will automatically be calculated if the right peaks are present.
The data can be summarised easily by using gr_cf_summary(data_cf)
. The example used here contains a mix of SiO2 and graphene flakes, so in some cases i use filter()
or mutate()
to deal with values that are outside the expected ranges.
data_cf_filtered <- data_cf %>% filter(`G int` > 50) %>% select(-starts_with('SiO2')) knitr::kable( gr_cf_summary(data_cf_filtered), digits = c(0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 2, 2) )
Getting an overview of the data from curve-fits can be challenging. The gr_cf_plot
accepts a data-frame with columns x
, y
and a value
and plots a map. Arguments can be passed to change appearance of the plot and size of the scalebar. See available color schemes by running the command RColorBrewer::display.brewer.all()
.
data_cf_small <- data_cf %>% select(x, y, `G int`) %>% rename(value = `G int`) gr_cf_plot(df = data_cf_small, name = 'G int') gr_cf_plot(df = data_cf_small, name = 'G int', scalebar = 2, palette = "Greys")
A whole range of maps can be plotted by supplying a data-frame to gr_cf_plot_all()
as in the following example. This function also accepts the scalebar
and palette
arguments.
data_cf %>% mutate(condition = `G int` > 50) %>% mutate(`2D FWHM` = ifelse(condition, `2D FWHM`, NA)) %>% mutate(`D FWHM` = ifelse(condition, `D FWHM`, NA)) %>% mutate(`G FWHM` = ifelse(condition, `G FWHM`, NA)) %>% mutate(`D/G-ratio` = ifelse(condition, `D/G-ratio`, NA)) %>% mutate(`2D/G-ratio` = ifelse(condition, `2D/G-ratio`, NA)) %>% gr_cf_plot_all()
In some cases it is desireable to present the results of a curve-fit on a spectrum as an example. This is possible using gr_cf_fit_add()
and gr_cf_fit_plot()
. It is necessary to have two files:
curvefit <- system.file("extdata/curvefit_data.txt", package = "gRaphene") spectrum <- system.file("extdata/spectrum_example.txt", package = "gRaphene") gr_cf_fit_plot(spectrum, curvefit)
The object returned by gr_cf_fit_plot()
is an ordinary ggplot2 object, and can be modified by adding new layers.
gr_cf_ann <- gr_cf_fit_add(spectrum, curvefit) %>% select(-intensity, -envelope) %>% gather(key = "peak", value = "intensity", -wavenumber) %>% group_by(peak) %>% filter(intensity == max(intensity)) gr_cf_fit_plot(spectrum, curvefit) + ggthemes::theme_few() + theme(axis.title.y = element_blank(), axis.text.y = element_blank(), axis.ticks.y = element_blank(), legend.position = "none") + scale_fill_brewer(palette = "Set3", guide = guide_legend(nrow = 1)) + geom_text(data = gr_cf_ann, aes(x = wavenumber, y = intensity, label = peak), nudge_y = 40, nudge_x = 10)
Finally, if you wish to generate your completely own plot, just use gr_cf_fit_add()
to generate the fitted data, and plot it manually.
fit_data <- gr_cf_fit_add(spectrum, curvefit) knitr::kable(head(fit_data, 5), digits = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.