| Title: | Self-Organising Maps for EEMs from DOM |
|---|---|
| Description: | Self-organising maps (SOM, Kohonen 2013) <doi:10.1016/j.neunet.2012.09.018> for excitation emission matrix (EEM) data of dissolved organic matter (DOM) prepared with 'staRdom'. Samples are arranged on a map, grouped by clustering the prototype EEMs and fluorescence regions are derived from correlated component planes following Ejarque-Gonzalez and Butturini (2014) <doi:10.1371/journal.pone.0099618>. Results can be split into sample groups for subsequent PARAFAC analyses. |
| Authors: | Matthias Pucher [aut, cre] (ORCID: <https://orcid.org/0000-0002-9093-2199>) |
| Maintainer: | Matthias Pucher <[email protected]> |
| License: | AGPL-3 |
| Version: | 0.3.0 |
| Built: | 2026-11-29 14:51:48 UTC |
| Source: | https://github.com/matthiaspucher/starsom |
Each EEM in an eemlist is unfolded into a vector. The result is a matrix with one row per sample and one column per pair of excitation and emission wavelengths. This matrix is the input for the self-organising map in eemsom. The unfolding can be reversed by mat2eem.
eem2mat(eem_list, normalise = "sd", na = "remove")eem2mat(eem_list, normalise = "sd", na = "remove")
eem_list |
object of class eemlist. All EEMs need to have the same excitation and emission wavelengths and unique sample names. |
normalise |
normalisation of each sample: |
na |
handling of missing values (e.g. removed scatter): |
Columns are named "ex|em", e.g. "250|450". The EEM matrix is unfolded column-wise, so emission wavelengths change faster than excitation wavelengths.
Normalisation removes differences in concentration and focuses on the shape of the EEMs. The normalisation factors are calculated from the remaining wavelength pairs (after removing missing values) and are saved as an attribute. They need to be positive, so EEMs with a maximum or a sum of zero or below cannot be normalised with "max" or "sum".
Wavelength pairs that are missing in all samples (e.g. scatter that was removed but not interpolated) carry no information and are removed even with na = "keep". Otherwise, the self-organising map would contain arbitrary values for them, because kohonen fills missing values in the initial codebook vectors with random values. With na = "keep", kohonen calculates the distances between samples and codebook vectors from the available wavelength pairs and scales them up to the number of all wavelength pairs.
A matrix with samples in rows and wavelength pairs in columns. Attributes: ex and em (wavelengths of the original EEMs), keep (logical vector stating which of the unfolded wavelength pairs are columns of the matrix), samples, normalise and norm_factors.
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other self-organising maps:
eempf_som(),
eemsom(),
mat2eem()
data(eem_list) m <- eem2mat(eem_list) dim(m) attr(m, "norm_factors")data(eem_list) m <- eem2mat(eem_list) dim(m) attr(m, "norm_factors")
Instead of the EEMs, the sample loadings (A-mode) of a PARAFAC model are arranged on a self-organising map. The loadings are scaled to Fmax, the maximum fluorescence of each component in each sample. Cuss et al. (2014) found a clearer separation of DOM sources with the relative contributions of PARAFAC components than with the EEMs themselves.
eempf_som(pfmodel, dim = "auto", normalise = TRUE, seed = NULL, ...) ## S3 method for class 'eempf_som' print(x, ...)eempf_som(pfmodel, dim = "auto", normalise = TRUE, seed = NULL, ...) ## S3 method for class 'eempf_som' print(x, ...)
pfmodel |
object of class parafac, see |
dim |
size of the map, either |
normalise |
logical, if TRUE (default), the Fmax values of each sample are divided by their sum, so the map shows the relative composition of the samples (Cuss et al. 2014, Wheeler et al. 2017). If FALSE, the Fmax values are used directly (Zhang et al. 2015). |
seed |
seed for the random number generator. With |
... |
additional parameters passed on to |
x |
object of class eempf_som |
The result can be used with the functions for self-organising maps of EEMs, e.g. eemsom_samples, eemsom_cluster, eemsom_split and the plot functions. The prototype EEM of a unit (eemsom_codes, ggeem) is the sum of the PARAFAC components weighted by the prototype loadings. eemsom_plot_cplane shows component planes of the PARAFAC components with the argument comps. eemsom_predict maps new samples after calculating their loadings with the fixed emission and excitation loadings of the PARAFAC model.
Relative contributions (normalise = TRUE) are only meaningful for non-negative loadings, i.e. for models calculated with const = c("nonneg", "nonneg", "nonneg") in eem_parafac.
eemsom_regions and eemsom_stability are not available for these maps.
object of class eempf_som and eemsom, see eemsom. Additionally, it contains the element pfmodel, the PARAFAC model with emission (B) and excitation (C) loadings scaled to Fmax (see eempf_rescaleBC), which is used to reconstruct prototype EEMs and to map new samples. The element normalise is the logical value of the argument and norm_factors are the sums of the Fmax values (or 1).
Cuss, C. W., Shi, Y. X., McConnell, S. M., Gueguen, C. (2014). Changes in the fluorescence composition of multiple DOM sources over pH gradients assessed by combining parallel factor analysis and self-organizing maps. Journal of Geophysical Research: Biogeosciences 119(9), 1850-1860. doi:10.1002/2013JG002598
Wheeler, K. I., Levia, D. F., Hudson, J. E. (2017). Tracking senescence-induced patterns in leaf litter leachate using parallel factor analysis (PARAFAC) modeling and self-organizing maps. Journal of Geophysical Research: Biogeosciences 122(9), 2233-2250. doi:10.1002/2016JG003677
Zhang, Y., Liang, X., Wang, Z., Xu, L. (2015). A novel approach combining self-organizing map and parallel factor analysis for monitoring water quality of watersheds under non-point source pollution. Scientific Reports 5, 16079. doi:10.1038/srep16079
Other self-organising maps:
eem2mat(),
eemsom(),
mat2eem()
data(pf_models) pfsom <- eempf_som(pf4[[1]], rlen = 100, seed = 42) pfsom eemsom_plot_cplane(pfsom, comps = 1:6) pfsom <- eemsom_cluster(pfsom, k = 4) eemsom_plot_map(pfsom, type = "cluster") ggeem(pfsom, units = 1:4)data(pf_models) pfsom <- eempf_som(pf4[[1]], rlen = 100, seed = 42) pfsom eemsom_plot_cplane(pfsom, comps = 1:6) pfsom <- eemsom_cluster(pfsom, k = 4) eemsom_plot_map(pfsom, type = "cluster") ggeem(pfsom, units = 1:4)
The EEMs are unfolded into vectors (see eem2mat), normalised and arranged on a self-organising map (SOM, Kohonen 2013). Each unit of the map gets a prototype EEM (codebook vector). Similar samples are mapped to the same or neighbouring units. The calculation is done with som, please see details there.
eemsom( eem_list, dim = "auto", topo = "hexagonal", normalise = "sd", na = "remove", rlen = 500, alpha = c(0.05, 0.01), mode = "online", init = "pca", seed = NULL, cores = 1, verbose = FALSE, ... ) ## S3 method for class 'eemsom' print(x, ...)eemsom( eem_list, dim = "auto", topo = "hexagonal", normalise = "sd", na = "remove", rlen = 500, alpha = c(0.05, 0.01), mode = "online", init = "pca", seed = NULL, cores = 1, verbose = FALSE, ... ) ## S3 method for class 'eemsom' print(x, ...)
eem_list |
object of class eemlist. All EEMs need to have the same excitation and emission wavelengths and unique sample names. |
dim |
size of the map, either |
topo |
topology of the map, |
normalise |
normalisation of each sample, see |
na |
handling of missing values, see |
rlen |
number of times the complete data set is presented to the map during training |
alpha |
learning rate, vector of start and end value |
mode |
training algorithm: |
init |
initialisation of the codebook vectors: |
seed |
seed for the random number generator. With |
cores |
number of cores used with |
verbose |
print infos |
... |
additional parameters that are passed on to |
x |
object of class eemsom |
With dim = "auto", the number of units is (Vesanto and Alhoniemi 2000) but not more than the number of samples n. The ratio of the side lengths follows the two largest eigenvalues of the data (Bieroza et al. 2009, Ejarque-Gonzalez and Butturini 2014): like in the SOM Toolbox (Vesanto et al. 2000), it is the square root of the ratio of the eigenvalues, i.e. the ratio of the standard deviations along the first two principal components. Ratios above the square root of the number of units are replaced by 1 to avoid very elongated maps.
The default learning rate (0.05 to 0.01) and the default neighbourhood radius (decreasing from two thirds of all unit distances to zero) of som correspond to the settings of Ejarque-Gonzalez and Butturini (2014).
The squared Euclidean distance (dist.fcts = "sumofsquares") is always used. Otherwise, kohonen would switch to the Tanimoto distance for data between 0 and 1 with row sums of 1, which occurs with normalise = "sum". With na = "keep", distances are calculated from the available wavelength pairs of a sample and scaled up to the number of all wavelength pairs.
The initialisation with init = "pca" is deterministic. The order of samples in the online training is random, so please set seed or use set.seed before the call for reproducible results.
The training time grows with the numbers of samples, units and wavelength pairs. As a rough guide for one core, online training with rlen = 500 takes about a minute for 200 EEMs with 3000 wavelength pairs and several minutes for 1000 EEMs. mode = "pbatch" with cores > 1, a smaller rlen or a lower resolution of the EEMs (see eem_range and eem_exclude; Ejarque-Gonzalez and Butturini (2014) used 366 wavelength pairs) reduce the time. This matters for eemsom_stability, which repeats the training many times.
object of class eemsom, a list containing
som: object of class kohonen, see som
ex, em: excitation and emission wavelengths
keep: logical vector of the unfolded wavelength pairs used in the SOM
samples: sample names
normalise, norm_factors: normalisation method and factors
na: handling of missing values
clusters: cluster of each unit, NULL until the units are clustered
settings: arguments used for som, needed by eemsom_stability
Kohonen, T. (2013). Essentials of the self-organizing map. Neural Networks 37, 52-65. doi:10.1016/j.neunet.2012.09.018
Vesanto, J., Alhoniemi, E. (2000). Clustering of the self-organizing map. IEEE Transactions on Neural Networks 11(3), 586-600. doi:10.1109/72.846731
Vesanto, J., Himberg, J., Alhoniemi, E., Parhankangas, J. (2000). SOM Toolbox for Matlab 5. Report A57, Helsinki University of Technology.
Bieroza, M., Baker, A., Bridgeman, J. (2009). Exploratory analysis of excitation-emission matrix fluorescence spectra with self-organizing maps as a basis for determination of organic matter removal efficiency at water treatment works. Journal of Geophysical Research: Biogeosciences 114(G4), 2009JG000940. doi:10.1029/2009JG000940
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Wehrens, R., Kruisselbrink, J. (2018). Flexible Self-Organizing Maps in kohonen 3.0. Journal of Statistical Software 87(7), 1-18. doi:10.18637/jss.v087.i07
som, eemsom_samples, eemsom_codes, eemsom_quality
Other self-organising maps:
eem2mat(),
eempf_som(),
mat2eem()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som eemsom_samples(som)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som eemsom_samples(som)
The prototypes (codebook vectors) of the units are grouped by hierarchical clustering or k-means. Samples belong to the cluster of their unit. This two-level approach (Vesanto and Alhoniemi 2000) is faster and more robust than clustering the samples directly.
eemsom_cluster(som, k, method = "complete", seed = NULL)eemsom_cluster(som, k, method = "complete", seed = NULL)
som |
object of class eemsom, see |
k |
number of clusters, see |
method |
|
seed |
seed for the random number generator, only used for |
object of class eemsom with the cluster of each unit in the element clusters
Vesanto, J., Alhoniemi, E. (2000). Clustering of the self-organizing map. IEEE Transactions on Neural Networks 11(3), 586-600. doi:10.1109/72.846731
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other clustering:
eemsom_kselect(),
eemsom_plot_silhouette(),
eemsom_split()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) eemsom_samples(som) eemsom_plot_map(som, type = "cluster")data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) eemsom_samples(som) eemsom_plot_map(som, type = "cluster")
The codebook vectors of the units are converted to EEMs.
eemsom_codes(som, denormalise = FALSE)eemsom_codes(som, denormalise = FALSE)
som |
object of class eemsom, see |
denormalise |
logical, if TRUE, each prototype is multiplied by the mean normalisation factor of the samples mapped to the unit (the mean of all samples for empty units). The result has the scale of the original data. |
For maps of PARAFAC loadings (eempf_som), the prototype EEM of a unit is the sum of the PARAFAC components weighted by the prototype loadings.
object of class eemlist, samples are named by the unit (e.g. "V1"), see mat2eem
Other map results:
eemsom_predict(),
eemsom_quality(),
eemsom_samples(),
eemsom_split()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) codes <- eemsom_codes(som) codes ggeem(codes)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) codes <- eemsom_codes(som) codes ggeem(codes)
The fluorescence of each sample is integrated within each region. Following Chen et al. (2003), the volumes are normalised by the area of the region, so regions of different size can be compared. Ejarque-Gonzalez and Butturini (2014) quantified their fluorescence components from the self-organising map in this way.
eemsom_fri(eem_list, regions)eemsom_fri(eem_list, regions)
eem_list |
object of class eemlist with the same wavelengths as the self-organising map used for the regions. Usually, these are the original (not normalised) EEMs. |
regions |
object of class eemsom_regions, see |
The volume of region i is over all wavelength pairs of the region. The area-normalised volume is , with A being the total area of all regions and the area of region i. Missing values in a sample are ignored and the area of the region is reduced accordingly.
data frame with column sample and one column per region (region_1, region_2, ...) containing the area-normalised volumes
Chen, W., Westerhoff, P., Leenheer, J. A., Booksh, K. (2003). Fluorescence Excitation-Emission Matrix Regional Integration to Quantify Spectra for Dissolved Organic Matter. Environmental Science & Technology 37(24), 5701-5710. doi:10.1021/es034354c
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other fluorescence regions:
eemsom_regions(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) regions <- eemsom_regions(som, k = 4, dim = c(8, 8), seed = 42) eemsom_fri(eem_list, regions)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) regions <- eemsom_regions(som, k = 4, dim = c(8, 8), seed = 42) eemsom_fri(eem_list, regions)
The units of a self-organising map are clustered with different numbers of clusters k. Several criteria are calculated for each k.
eemsom_kselect(som, k = 2:9, method = "complete", seed = NULL)eemsom_kselect(som, k = 2:9, method = "complete", seed = NULL)
som |
object of class eemsom, see |
k |
numeric vector of numbers of clusters to be tested |
method |
clustering method, see |
seed |
seed for the random number generator, only used for |
silhouette: mean silhouette width of the units (Rousseeuw 1987), higher is better
negative: number of units with negative silhouette width, i.e. units that are closer to another cluster, lower is better (Ejarque-Gonzalez and Butturini 2014)
davies_bouldin: Davies-Bouldin index, lower is better (Inf if two clusters have identical centres)
wss: within-cluster sum of squares, look for an elbow
data frame with one row per k
Rousseeuw, P. J. (1987). Silhouettes: A graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics 20, 53-65. doi:10.1016/0377-0427(87)90125-7
Davies, D. L., Bouldin, D. W. (1979). A Cluster Separation Measure. IEEE Transactions on Pattern Analysis and Machine Intelligence 1(2), 224-227. doi:10.1109/TPAMI.1979.4766909
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other clustering:
eemsom_cluster(),
eemsom_plot_silhouette(),
eemsom_split()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_kselect(som, k = 2:6)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_kselect(som, k = 2:6)
A component plane shows the value of one variable in the prototypes of all units. Similar component planes indicate correlated variables. For maps of EEMs, the variables are wavelength pairs, for maps of PARAFAC loadings (eempf_som), the variables are the PARAFAC components.
eemsom_plot_cplane(som, ex = NULL, em = NULL, comps = NULL, scale = "common")eemsom_plot_cplane(som, ex = NULL, em = NULL, comps = NULL, scale = "common")
som |
|
ex |
numeric vector of excitation wavelengths (maps of EEMs only) |
em |
numeric vector of emission wavelengths, same length as |
comps |
numeric vector or names of PARAFAC components (maps of PARAFAC loadings only). NULL (default) plots all components. |
scale |
|
The closest wavelengths available in the data are used. With scale = "common", values are on the scale of the normalised data.
Ejarque-Gonzalez and Butturini (2014) compared the component planes of all wavelength pairs by their correlation to discriminate fluorescence components, see eemsom_regions.
a ggplot object
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other plots:
eemsom_plot_map(),
eemsom_plot_silhouette(),
eemsom_plot_stability(),
eemsom_plot_training(),
ggeem.eemsom(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) # fluorescence peaks B, T, A and C (Coble 1996) eemsom_plot_cplane(som, ex = c(275, 275, 260, 350), em = c(310, 340, 450, 450)) eemsom_plot_cplane(som, ex = c(275, 275, 260, 350), em = c(310, 340, 450, 450), scale = "each") data(pf_models) pfsom <- eempf_som(pf4[[1]], rlen = 100, seed = 42) eemsom_plot_cplane(pfsom, scale = "each")data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) # fluorescence peaks B, T, A and C (Coble 1996) eemsom_plot_cplane(som, ex = c(275, 275, 260, 350), em = c(310, 340, 450, 450)) eemsom_plot_cplane(som, ex = c(275, 275, 260, 350), em = c(310, 340, 450, 450), scale = "each") data(pf_models) pfsom <- eempf_som(pf4[[1]], rlen = 100, seed = 42) eemsom_plot_cplane(pfsom, scale = "each")
Different properties of the units are shown on the map.
eemsom_plot_map( som, type = "counts", colour = NULL, labels = FALSE, unit_labels = FALSE )eemsom_plot_map( som, type = "counts", colour = NULL, labels = FALSE, unit_labels = FALSE )
som |
object of class eemsom, see |
type |
property to be shown:
|
colour |
optional vector with one value per sample (e.g. sampling site from metadata) used to colour the samples with |
labels |
logical, whether sample names are shown with |
unit_labels |
logical, whether the numbers of the units are shown. They are used by |
Neighbours are defined like in unit.distances: six units on hexagonal maps, eight units including the diagonals on rectangular maps.
With type = "samples", samples of the same unit are arranged in a circle around the centre of the unit.
Ejarque-Gonzalez and Butturini (2014) used the U-matrix to find regions of similar units and projected the samples, coloured by sampling site and hydrological conditions, onto the map to explore the patterns among samples.
a ggplot object
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other plots:
eemsom_plot_cplane(),
eemsom_plot_silhouette(),
eemsom_plot_stability(),
eemsom_plot_training(),
ggeem.eemsom(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_plot_map(som, unit_labels = TRUE) eemsom_plot_map(som, type = "umatrix") eemsom_plot_map(som, type = "samples", colour = substr(eem_names(eem_list), 1, 2), labels = TRUE)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_plot_map(som, unit_labels = TRUE) eemsom_plot_map(som, type = "umatrix") eemsom_plot_map(som, type = "samples", colour = substr(eem_names(eem_list), 1, 2), labels = TRUE)
The silhouette width of each unit shows how well it fits into its cluster. Values close to 1 indicate a good fit, negative values indicate that the unit is closer to another cluster. Ejarque-Gonzalez and Butturini (2014) chose the number of fluorescence components by the mean silhouette width and the number of negative silhouettes.
eemsom_plot_silhouette(x)eemsom_plot_silhouette(x)
x |
object of class eemsom with clusters (see |
a ggplot object
Rousseeuw, P. J. (1987). Silhouettes: A graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics 20, 53-65. doi:10.1016/0377-0427(87)90125-7
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other clustering:
eemsom_cluster(),
eemsom_kselect(),
eemsom_split()
Other plots:
eemsom_plot_cplane(),
eemsom_plot_map(),
eemsom_plot_stability(),
eemsom_plot_training(),
ggeem.eemsom(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) eemsom_plot_silhouette(som)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) eemsom_plot_silhouette(som)
A histogram of the neighbourhood stability of all pairs of samples is compared to the distribution expected on a randomly organised map (de Bodt et al. 2002), as in Figure 4B of Ejarque-Gonzalez and Butturini (2014).
eemsom_plot_stability(x)eemsom_plot_stability(x)
x |
object of class eemsom_stability, see |
a ggplot object
de Bodt, E., Cottrell, M., Verleysen, M. (2002). Statistical tools to assess the reliability of self-organizing maps. Neural Networks 15(8-9), 967-978. doi:10.1016/S0893-6080(02)00071-0
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other stability:
eemsom_stability()
Other plots:
eemsom_plot_cplane(),
eemsom_plot_map(),
eemsom_plot_silhouette(),
eemsom_plot_training(),
ggeem.eemsom(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, dim = c(3, 3), rlen = 20, seed = 42) stab <- eemsom_stability(eem_list, som, nrep = 3, seed = 42) eemsom_plot_stability(stab)data(eem_list) som <- eemsom(eem_list, dim = c(3, 3), rlen = 20, seed = 42) stab <- eemsom_stability(eem_list, som, nrep = 3, seed = 42) eemsom_plot_stability(stab)
The mean distance between samples and their closest unit during the training is plotted. The curve should flatten at the end of the training, otherwise rlen might be increased.
eemsom_plot_training(som)eemsom_plot_training(som)
som |
object of class eemsom, see |
a ggplot object
Other plots:
eemsom_plot_cplane(),
eemsom_plot_map(),
eemsom_plot_silhouette(),
eemsom_plot_stability(),
ggeem.eemsom(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_plot_training(som)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_plot_training(som)
New EEMs are assigned to their best matching unit. For maps of EEMs (eemsom), they are normalised like the training data. For maps of PARAFAC loadings (eempf_som), their loadings are calculated first with the fixed emission and excitation loadings of the PARAFAC model (A_missing).
eemsom_predict(som, eem_list, cores = 1, ...)eemsom_predict(som, eem_list, cores = 1, ...)
som |
|
eem_list |
object of class eemlist with the same excitation and emission wavelengths as the training data or the PARAFAC model |
cores |
number of cores used by |
... |
additional arguments passed on to |
Maps of EEMs: only the wavelength pairs used in the map are considered. Missing values in the new samples are ignored when calculating the distances, which are scaled up to the number of all wavelength pairs as in kohonen (see eemsom_samples).
Maps of PARAFAC loadings: the new EEMs need the same preparation as the EEMs of the PARAFAC model (e.g. scatter removal). Their Fmax loadings are scaled like in eempf_som (relative or absolute) and the distances refer to these loadings.
data frame with columns sample, unit, x, y, distance, hits, umatrix and cluster like eemsom_samples. hits is the number of training samples mapped to the unit. A distance much higher than the distances of the training samples indicates a sample that is not represented by the map.
Other map results:
eemsom_codes(),
eemsom_quality(),
eemsom_samples(),
eemsom_split()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) # usually, new samples are mapped. Here, the training samples are used. eemsom_predict(som, eem_list) # map of PARAFAC loadings: the loadings of the new samples are calculated first data(pf_models) data(eem_list_outliers) pfsom <- eempf_som(pf4[[1]], rlen = 100, seed = 42) new_samples <- eem_list_outliers |> eem_rem_scat(remove_scatter = c(TRUE, TRUE, TRUE, TRUE), remove_scatter_width = c(15, 15, 18, 19)) |> eem_interp(type = 1, extend = FALSE, cores = 1) eemsom_predict(pfsom, new_samples)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) # usually, new samples are mapped. Here, the training samples are used. eemsom_predict(som, eem_list) # map of PARAFAC loadings: the loadings of the new samples are calculated first data(pf_models) data(eem_list_outliers) pfsom <- eempf_som(pf4[[1]], rlen = 100, seed = 42) new_samples <- eem_list_outliers |> eem_rem_scat(remove_scatter = c(TRUE, TRUE, TRUE, TRUE), remove_scatter_width = c(15, 15, 18, 19)) |> eem_interp(type = 1, extend = FALSE, cores = 1) eemsom_predict(pfsom, new_samples)
Quality measures of a self-organising map
eemsom_quality(som)eemsom_quality(som)
som |
object of class eemsom, see |
quantisation_error: mean Euclidean distance between samples and their prototypes, see eemsom_samples for the handling of missing values
topographic_error: share of samples whose best and second best matching units are not neighbours (six neighbours on hexagonal maps, eight including the diagonals on rectangular maps, see unit.distances)
explained_variance: share of the total sum of squares of the (normalised) data explained by the prototypes
data frame with one row
Kohonen, T. (2013). Essentials of the self-organizing map. Neural Networks 37, 52-65. doi:10.1016/j.neunet.2012.09.018
Other map results:
eemsom_codes(),
eemsom_predict(),
eemsom_samples(),
eemsom_split()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_quality(som)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_quality(som)
Wavelength pairs with similar behaviour across the units of a self-organising map are grouped into regions. Each region is assumed to represent a fluorescence component (Ejarque-Gonzalez and Butturini 2014). The component planes are arranged on a second self-organising map ("R-mode") and its units are clustered hierarchically.
eemsom_regions( som, k = 2:9, method = "planes", dim = "auto", cluster_method = "complete", seed = NULL, ... ) ## S3 method for class 'eemsom_regions' print(x, ...)eemsom_regions( som, k = 2:9, method = "planes", dim = "auto", cluster_method = "complete", seed = NULL, ... ) ## S3 method for class 'eemsom_regions' print(x, ...)
som |
object of class eemsom, see |
k |
number of regions (a single number) or candidates (a vector, default 2 to 9) from which the number with the highest mean silhouette width is chosen. NULL is the same as |
method |
|
dim |
size of the R-mode map, either |
cluster_method |
clustering method of the R-mode units, see |
seed |
seed for the random number generator. With |
... |
additional parameters that are passed on to |
x |
object of class eemsom_regions |
Following Barreto-Sanz and Perez-Uribe (2007), Ejarque-Gonzalez and Butturini (2014) calculated a self-organising map from the matrix of Pearson's correlations between all component planes (method = "cormat"). This matrix has as many rows and columns as wavelength pairs and the calculation gets slow with a high resolution of the EEMs (minutes with a few thousand wavelength pairs).
With method = "planes", each component plane is centred and scaled to length 1. The squared Euclidean distance of two such vectors equals , where r is their correlation. The R-mode map is calculated from these vectors directly, which is much faster and groups wavelength pairs by their correlation as well.
Both methods group wavelength pairs by the correlation of their component planes, but the R-mode maps are trained on different vectors. The resulting regions are similar but not identical and the region numbers can differ.
Wavelength pairs with constant component planes have no correlation and get no region (NA), as well as wavelength pairs that were not used in the map.
object of class eemsom_regions, a list containing
regions: data frame with columns ex, em and region
k: number of regions
kselect: data frame with criteria for the candidates (see eemsom_kselect), NULL if k was a single number
rsom: R-mode self-organising map of class kohonen
unit_regions: region of each unit of the R-mode map
method, cluster_method, seed: settings used. Without a given seed, a seed is drawn from the random number stream of the session and used for the map and the clustering.
Barreto-Sanz, M. A., Perez-Uribe, A. (2007). Improving the Correlation Hunting in a Large Quantity of SOM Component Planes. In: Artificial Neural Networks - ICANN 2007, Lecture Notes in Computer Science 4669, 379-388. doi:10.1007/978-3-540-74695-9_39
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other fluorescence regions:
eemsom_fri(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) regions <- eemsom_regions(som, dim = c(8, 8), seed = 42) regions regions$kselect ggeem(regions) # fixed number of regions eemsom_regions(som, k = 3, dim = c(8, 8), seed = 42)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) regions <- eemsom_regions(som, dim = c(8, 8), seed = 42) regions regions$kselect ggeem(regions) # fixed number of regions eemsom_regions(som, k = 3, dim = c(8, 8), seed = 42)
Assignment of samples to units of a self-organising map
eemsom_samples(som)eemsom_samples(som)
som |
object of class eemsom, see |
With missing values (na = "keep"), the distances are calculated from the available wavelength pairs of a sample and scaled up to the number of all wavelength pairs, as in kohonen.
The columns hits and umatrix help to find unusual samples (outliers): such samples often occupy a unit alone (hits = 1) that is separated from its neighbours by a high U-matrix value. Their distance to the prototype can be small though, because the prototype adapts to them. The leave-one-out distance calculated by eemsom_stability with type = "loo" is a more reliable indicator.
data frame with columns sample, unit (number of the best matching unit), x and y (position of the unit on the map), distance (Euclidean distance between sample and prototype), hits (number of samples mapped to the unit), umatrix (mean distance between the prototype of the unit and the prototypes of its neighbours, see eemsom_plot_map) and cluster (NA if no clustering was done)
Other map results:
eemsom_codes(),
eemsom_predict(),
eemsom_quality(),
eemsom_split()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_samples(som)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) eemsom_samples(som)
The samples are divided into groups that can be analysed separately, e.g. by eem_parafac.
eemsom_split(eem_list, som, by = "cluster", min_samples = 20)eemsom_split(eem_list, som, by = "cluster", min_samples = 20)
eem_list |
object of class eemlist, containing samples used to calculate the self-organising map. Usually, these are the original (not normalised) EEMs. |
som |
object of class eemsom, see |
by |
|
min_samples |
minimum number of samples per group. A warning is shown for smaller groups because a PARAFAC model might not be stable. |
Samples are matched by their names. Groups without samples are omitted.
a named list of eemlists, names are "cluster_1", "cluster_2", ... or "unit_1", ...
Other clustering:
eemsom_cluster(),
eemsom_kselect(),
eemsom_plot_silhouette()
Other map results:
eemsom_codes(),
eemsom_predict(),
eemsom_quality(),
eemsom_samples()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) eem_groups <- eemsom_split(eem_list, som, min_samples = 3) lengths(eem_groups) # separate PARAFAC models for the groups with at least 5 samples # (with real data sets, groups need more samples, starts and iterations) eem_groups <- eem_groups[lengths(eem_groups) >= 5] pf_groups <- lapply(eem_groups, eem_parafac, comps = 2, nstart = 1, maxit = 500, cores = 1)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) som <- eemsom_cluster(som, k = 3) eem_groups <- eemsom_split(eem_list, som, min_samples = 3) lengths(eem_groups) # separate PARAFAC models for the groups with at least 5 samples # (with real data sets, groups need more samples, starts and iterations) eem_groups <- eem_groups[lengths(eem_groups) >= 5] pf_groups <- lapply(eem_groups, eem_parafac, comps = 2, nstart = 1, maxit = 500, cores = 1)
Self-organising maps are calculated repeatedly from resampled data with the same settings as the original map. The stability of the quantisation and of the neighbourhood relations of the samples is assessed (de Bodt et al. 2002).
eemsom_stability( eem_list, som, type = "bootstrap", nrep = 20, radius = 1, seed = NULL, cores = 1, verbose = FALSE ) ## S3 method for class 'eemsom_stability' print(x, ...)eemsom_stability( eem_list, som, type = "bootstrap", nrep = 20, radius = 1, seed = NULL, cores = 1, verbose = FALSE ) ## S3 method for class 'eemsom_stability' print(x, ...)
eem_list |
object of class eemlist, the samples used to calculate |
som |
object of class eemsom, see |
type |
|
nrep |
number of maps ( |
radius |
two samples are neighbours if their units are not more than |
seed |
seed for the random number generator. With |
cores |
number of parallel calculations |
verbose |
print infos, with |
x |
object of class eemsom_stability |
... |
further arguments, not used |
For each map, all samples are mapped to their best matching unit, including samples that were not part of the resampled data.
Quantisation: the intra-class sum of squares (SS intra), the sum of the squared distances between samples and their prototypes, is calculated for each map. A low coefficient of variation indicates a stable quantisation.
Neighbourhood: for each pair of samples, the stability is the share of maps in which both samples are neighbours. Stable maps have values close to 0 or 1. On a randomly organised map, two samples are neighbours with probability p (element random), the stability then follows a binomial distribution.
Outliers: with type = "loo", each sample is mapped to the maps calculated without it. Its distance to the best matching unit is high, if no other sample is similar, which corresponds to a large residual of a sample that is not part of a PARAFAC model. The mean distance over nrep maps is returned in the element loo. Samples with distinctly higher values than the others are candidates for outliers, which should be checked further, e.g. by eempf_leverage and eempf_residuals_plot in a PARAFAC analysis.
Run time: nrep maps (type = "bootstrap") or nrep times the number of samples maps (type = "loo") are trained with the settings of som, so the run time is the corresponding multiple of the training time of eemsom. Please see there for ways to reduce the training time and use cores for parallel calculation.
object of class eemsom_stability, a list containing
quantisation: data frame with columns rep, ss_intra and left_out (only for type = "loo")
neighbourhood: data frame with columns sample1, sample2 and stability
random: probability of two samples being neighbours on a random map
loo: only for type = "loo", data frame with columns sample and distance (mean distance of each sample to its best matching unit on the maps calculated without it)
nmaps, type, radius: number of maps and settings
de Bodt, E., Cottrell, M., Verleysen, M. (2002). Statistical tools to assess the reliability of self-organizing maps. Neural Networks 15(8-9), 967-978. doi:10.1016/S0893-6080(02)00071-0
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other stability:
eemsom_plot_stability()
data(eem_list) som <- eemsom(eem_list, dim = c(3, 3), rlen = 20, seed = 42) stab <- eemsom_stability(eem_list, som, nrep = 3, seed = 42) stab eemsom_plot_stability(stab) # in parallel; with real data sets, use more repetitions som <- eemsom(eem_list, rlen = 100, seed = 42) stab <- eemsom_stability(eem_list, som, nrep = 4, cores = 2, seed = 42) eemsom_plot_stability(stab)data(eem_list) som <- eemsom(eem_list, dim = c(3, 3), rlen = 20, seed = 42) stab <- eemsom_stability(eem_list, som, nrep = 3, seed = 42) stab eemsom_plot_stability(stab) # in parallel; with real data sets, use more repetitions som <- eemsom(eem_list, rlen = 100, seed = 42) stab <- eemsom_stability(eem_list, som, nrep = 4, cores = 2, seed = 42) eemsom_plot_stability(stab)
The prototype EEMs (codebook vectors) of all units or selected units are plotted. If all units are plotted, the facets are arranged like the units on the map (top row of the map first).
## S3 method for class 'eemsom' ggeem(data, fill_max = FALSE, units = NULL, denormalise = FALSE, ...)## S3 method for class 'eemsom' ggeem(data, fill_max = FALSE, units = NULL, denormalise = FALSE, ...)
data |
object of class eemsom, see |
fill_max |
sets the maximum fluorescence value for the colour scale, see |
units |
optional numeric vector of units to be plotted |
denormalise |
logical, see |
... |
parameters passed on to |
The facet titles show the unit and the number of samples mapped to this unit. On a hexagonal map, every second row is shifted by half a unit, which cannot be shown by the facets.
Ejarque-Gonzalez and Butturini (2014) used the prototype EEMs to describe the characteristic fluorescence of the regions of the map.
a ggplot object
Ejarque-Gonzalez, E., Butturini, A. (2014). Self-Organising Maps and Correlation Analysis as a Tool to Explore Patterns in Excitation-Emission Matrix Data Sets and to Discriminate Dissolved Organic Matter Fluorescence Components. PLoS ONE 9(6), e99618. doi:10.1371/journal.pone.0099618
Other plots:
eemsom_plot_cplane(),
eemsom_plot_map(),
eemsom_plot_silhouette(),
eemsom_plot_stability(),
eemsom_plot_training(),
ggeem.eemsom_regions()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) ggeem(som) ggeem(som, units = c(1, 2), contour = TRUE)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) ggeem(som) ggeem(som, units = c(1, 2), contour = TRUE)
The regions found by eemsom_regions are shown in the excitation-emission space.
## S3 method for class 'eemsom_regions' ggeem(data, fill_max = FALSE, ...)## S3 method for class 'eemsom_regions' ggeem(data, fill_max = FALSE, ...)
data |
object of class eemsom_regions |
fill_max |
not used, for consistency with |
... |
further arguments, not used |
a ggplot object
Other fluorescence regions:
eemsom_fri(),
eemsom_regions()
Other plots:
eemsom_plot_cplane(),
eemsom_plot_map(),
eemsom_plot_silhouette(),
eemsom_plot_stability(),
eemsom_plot_training(),
ggeem.eemsom()
data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) regions <- eemsom_regions(som, dim = c(8, 8), seed = 42) ggeem(regions)data(eem_list) som <- eemsom(eem_list, rlen = 100, seed = 42) regions <- eemsom_regions(som, dim = c(8, 8), seed = 42) ggeem(regions)
Rows of a matrix created by eem2mat or of a matrix with the same columns (e.g. codebook vectors of a self-organising map) are converted to EEMs. Wavelength pairs that were removed before are set to NA.
mat2eem( mat, ex = attr(mat, "ex"), em = attr(mat, "em"), keep = attr(mat, "keep"), samples = rownames(mat), norm_factors = NULL )mat2eem( mat, ex = attr(mat, "ex"), em = attr(mat, "em"), keep = attr(mat, "keep"), samples = rownames(mat), norm_factors = NULL )
mat |
matrix with unfolded EEMs in rows |
ex |
excitation wavelengths of the EEMs |
em |
emission wavelengths of the EEMs |
keep |
logical vector of length |
samples |
sample names for the EEMs |
norm_factors |
optional numeric vector, rows of |
object of class eemlist. The EEMs have no file name and the attributes used by eemR (e.g. is_blank_corrected) are NA.
Other self-organising maps:
eem2mat(),
eempf_som(),
eemsom()
data(eem_list) m <- eem2mat(eem_list) eem_list2 <- mat2eem(m) # normalised EEMs eem_list3 <- mat2eem(m, norm_factors = attr(m, "norm_factors")) # original values eem_list2 ggeem(eem_list2)data(eem_list) m <- eem2mat(eem_list) eem_list2 <- mat2eem(m) # normalised EEMs eem_list3 <- mat2eem(m, norm_factors = attr(m, "norm_factors")) # original values eem_list2 ggeem(eem_list2)