R-Forge Logo

R package chemosensors

The development of chemosensors package was originated in NEUROChem project with requirements of large-scale gas sensor array data to run simulations on artificial olfaction. This package introduces a software tool that allows for the design of synthetic experiments with so-called virtual gas sensor arrays.

The generator of sensor signals can be used in applications related to educational tools, neuromorphic simulations in machine olfaction, and test and benchmarking of signal processing methods.

The synthetic array of sensors allows for the generation of chemosensor data with a variety of characteristics: unlimited number of sensors, support of multicomponent gas mixtures and full parametric control of the noise in the system.

The released package makes use of the object-oriented programming paradigm (S4 classes), supports parallel computing and contains the datasets exploited in projects of the authors.


  1. Ziyatdinov, A., Fernández Diaz, E., Chaudry, A., Marco, S., Persaud, K., & Perera, A. (2013). A software tool for large-scale synthetic experiments based on polymeric sensor arrays. Sensors and Actuators B: Chemical, 177, 596–604. doi:10.1016/j.snb.2012.09.093 [link]
  2. Ziyatdinov, A., & Perera-Lluna, A. (2014). Data Simulation in Machine Olfaction with the R Package Chemosensors. (H. A. Kestler, Ed.) PLoS ONE, 9(2), e88839. doi:10.1371/journal.pone.0088839 [link]



The current version of software allows for simulations with mixtures of up to 3 gas classes. This limitation comes from the fact the the only reference UNIMAN data set contains records for three analytes (ammonia, propanoic acid and n-butanol).

An extension of the data simulation software to higher-order gas mixtures is possible if approriate reference data sets become available. Please contact us if you are interested to share some data to be simulated with our software.

The rectangular gas pulse is the only sampling available till now. Again, this sampling was used in the measurement of the reference UNIMAN data set, where the injection of an analyte in the sensor chamber lasted from 0 s to 180 s.

When the sensor dynamics is disabled (R code: SensorArray(enableDyn = FALSE)), an arbitrary concentration matrix (i.e. sampling protocol) is possible. In this case there is nothing to deal with the sensor dynamics. We suggest the user to follow the rectangle pulse protocol for the simulations based on the reference UNIMAN data set.

Installation from CRAN (recommended)

The command in R to install the package:


The stable version of chemosensors package from the CRAN repository will be installed

Installation from R-forge

Chemosensors package can be installed as a regular R package from the R-Forge repository. The command to type in R:

install.packages("chemosensors", dep=TRUE, repos="http://r-forge.r-project.org")

That will install the latest development version with all dependencies.

Installation from source

If the installation suggested above fails, it is still possible to install the package from source.

In the case you don't have the local file of the package sourse, you can get it from R-Forge svn repository and then install. Commands in Linux are the following.

svn checkout svn://scm.r-forge.r-project.org/svnroot/chemosensors/pkg
sudo R CMD INSTALL pkg/

Please let us know if you have any problems related to installation or running the software.


Help pages in html format are available on http://chemosensors.r-forge.r-project.org/html/. Thanks to devtools and staticdocs.


You might prefer to start with demos of the package. To see the list of available demos type in R:


Basic commands to generate synthetic data from a virtual sensor array could be:

# concentration matrix of 3 gas classes: A, C and AC
conc <- matrix(0, 300, 3)
conc[1:100, 1] <- 0.05 # A
conc[101:200, 3] <- 1 # C
conc[201:300, 1] <- 0.05 # AC
conc[201:300, 3] <- 1 # AC

conc <- conc[sample(1:nrow(conc)), ]

# sensor array of 5 sensors with parametrized noise levels
sa <- SensorArray(num=1:5, csd=0.1, ssd=0.1, dsd=0.1)

# get information about the array

# generate the data
sdata <- predict(sa, conc)

Animation demo

This animation presents a simulation of synthetic data with different noise parameters. The synthetic data (top of the graphics) is visually compared with the reference UNIMAN data (bottom of the graphics) by plotting PCA scores.

Objective of the simulation is to reproduce the reference dataset by playing with combinations of the parameters (barplot on the graphics). The virtual sensor array is composed of the same number of sensors (17) as the UNIMAN array. The concentration profile of 200 samples contains eight gas classes (legend of the graphics).

Three noise parameters represent concentration noise (csd), sensor noise (ssd) and drift (dsd).


Alexandre Perera
Email: alexandre.perera [at] upc.edu

Andrey Ziyatdinov
Email: andrey.ziyatdinov [at] upc.edu

Universitat Politècnica de Catalunya, dept. ESAII
c/ Pau Gargallo 5, 08028 Barcelona, Spain
Tel.: +34 93 407 07 73


This work was funded from the European Community's Seventh Framework Programme (FP7/2007-2013) under grant agreement no. 216916: Biologically inspired computation for chemical sensing (NEUROChem), the Ramon y Cajal program from the Spanish Ministerio de Educacion y Ciencia and TEC2010-20886-C02-02. CIBER-BBN is an initiative of the Spanish ISCIII.


This page was last updated: 2014-03-04.