Title: | Metabolomics Data Analysis Functions |
---|---|
Description: | A collection of functions for processing and analyzing metabolite data. The namesake function mrbin() converts 1D or 2D Nuclear Magnetic Resonance data into a matrix of values suitable for further data analysis and performs basic processing steps in a reproducible way. Negative values, a common issue in such data, can be replaced by positive values (<doi:10.1021/acs.jproteome.0c00684>). All used parameters are stored in a readable text file and can be restored from that file to enable exact reproduction of the data at a later time. The function fia() ranks features according to their impact on classifier models, especially artificial neural network models. |
Authors: | Matthias Klein [aut, cre] |
Maintainer: | Matthias Klein <[email protected]> |
License: | GPL-3 |
Version: | 1.9.0 |
Built: | 2025-03-12 18:16:40 UTC |
Source: | https://github.com/kleinomicslab/mrbin |
This function adds a spectrum to the plot list.
addToPlot( folder = NULL, dimension = "1D", NMRvendor = "Bruker", useAsNames = "Folder names", add = TRUE, omitCurrent = FALSE )
addToPlot( folder = NULL, dimension = "1D", NMRvendor = "Bruker", useAsNames = "Folder names", add = TRUE, omitCurrent = FALSE )
folder |
Defines the exact NMR data folder. If NULL, mrbin parameter set is used |
dimension |
Defines the data dimension, "1D" or "2D". Only used if not NULL |
NMRvendor |
Defines the NMR manufacturer, default is "Bruker" |
useAsNames |
How should sample names be generated |
add |
Add spectra to existing list, or replace existing spectra. Default is TRUE |
omitCurrent |
Omit the "current spectrum" spot and start filling the additional lists immediately. Default is FALSE |
none
addToPlot()
addToPlot()
This function annotates an mrbin object and returns it with updated $annotations vector
annotatemrbin( mrbinObject, annotate = TRUE, metaboliteIdentities = NULL, add = FALSE, hideChemicalShift = FALSE, hideTentativeIds = FALSE, confirmationRthreshold = 0.6, confirmationPthreshold = 5e-06, checkBaselineCorrelation = TRUE )
annotatemrbin( mrbinObject, annotate = TRUE, metaboliteIdentities = NULL, add = FALSE, hideChemicalShift = FALSE, hideTentativeIds = FALSE, confirmationRthreshold = 0.6, confirmationPthreshold = 5e-06, checkBaselineCorrelation = TRUE )
mrbinObject |
An mrbin object |
annotate |
If FALSE, the mrbin object will not be changed. |
metaboliteIdentities |
A numeric 4-column matrix or the file path for a .csv file containing such a matrix, the first columns containing metabolite names and the first row being a header. Each row belongs to one unique metabolite signal (left, right, top, bottom borders). Row names are metabolite names. If provided, this will overwrite any current metaboliteIdentities matrix present in the mrbin object. If missing, data currently attached to the mrbin object (if any) will be used. |
add |
Should the new metabolite list be added to an existing list, or replace the current list? |
hideChemicalShift |
Should the chemical shift (bin borders) of an identified metabolite be removed, leaving only the metabolite id, or should both be shown? Showing both helps in identifying signals of interest, but hiding the chmical shift might make better plots. |
hideTentativeIds |
Should the identities of tentative ids be omitted for clarity? |
confirmationRthreshold |
A threshold to define the r-value cutoff to confirm an annotation |
confirmationPthreshold |
A threshold to define the p-value cutoff to confirm an annotation |
checkBaselineCorrelation |
Should correlation to baseline be compared to confirm an annotation |
An (invisible) mrbin object
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/3/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/1/10/pdata/10",package="mrbin")))) metaboliteIdentities=matrix(c(1.346,1.324,21,23, 4.12,4.1,70.8578,71.653, 3.052,3.043,30.5,33.5, 4.066,4.059,57,59.5), ncol=4,byrow=TRUE) rownames(metaboliteIdentities)=c("Lactate","Lactate","Creatinine","Creatinine") results<-annotatemrbin(results,metaboliteIdentities=metaboliteIdentities) results$metadata$annotations[125:135] plotPCA(results,loadings=TRUE)
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/3/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/1/10/pdata/10",package="mrbin")))) metaboliteIdentities=matrix(c(1.346,1.324,21,23, 4.12,4.1,70.8578,71.653, 3.052,3.043,30.5,33.5, 4.066,4.059,57,59.5), ncol=4,byrow=TRUE) rownames(metaboliteIdentities)=c("Lactate","Lactate","Creatinine","Creatinine") results<-annotatemrbin(results,metaboliteIdentities=metaboliteIdentities) results$metadata$annotations[125:135] plotPCA(results,loadings=TRUE)
This function replaces (column-wise) negative values by a small positive number. The number is calculated as an affine transformation to the range of the lowest positive number to 0,01*the lowest positive number (of this column). Ranks stay unchanged. Positive numbers are not altered. If sample-wise noise levels are available, the median noise level of samples with negative values is calculated and replaces the lowest positive number in case it is smaller. If no noise data is available, the 1 positive values in the data set is used as an estimate. It is recommended to us this function AFTER noise removal and other data clean-up methods, as it may alter (reduce) the noise level.
atnv(NMRdata, noiseLevels = NULL, verbose = TRUE, errorsAsWarnings = FALSE)
atnv(NMRdata, noiseLevels = NULL, verbose = TRUE, errorsAsWarnings = FALSE)
NMRdata |
A matrix or mrbin object containing NMR data. For matrix: columns=frequencies,rows=samples |
noiseLevels |
A vector (can be omitted if NMRdata is an mrbin object) |
verbose |
Should a summary be displayed if NMRdata is an mrbin object |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
An invisible matrix or mrbin object containing NMR data without negative values.
resetEnv() results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.005,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,7.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) sum(results$bins<=0) exampleNMRpositive<-atnv(NMRdata=results$bins, noiseLevels=results$parameters$noise_level_adjusted) sum(exampleNMRpositive<=0)
resetEnv() results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.005,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,7.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) sum(results$bins<=0) exampleNMRpositive<-atnv(NMRdata=results$bins, noiseLevels=results$parameters$noise_level_adjusted) sum(exampleNMRpositive<=0)
This function checks an mrbin object and returns warning if changes were not documented
checkmrbin(mrbinObject, verbose = TRUE, errorsAsWarnings = NULL)
checkmrbin(mrbinObject, verbose = TRUE, errorsAsWarnings = NULL)
mrbinObject |
An mrbin object |
verbose |
Should a summary be displayed? (Warnings will be displayed even when setting verbose to FALSE) |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. If not provided, this will be taken from the mrbinObject. |
An (invisible) character vector of warnings
mrbinObject<-createmrbin() mrbinObject<-checkmrbin(mrbinObject)
mrbinObject<-createmrbin() mrbinObject<-checkmrbin(mrbinObject)
This function decreases the minimum contour level of the current 2D NMR spectrum plot.
contMin(refreshPlot = TRUE)
contMin(refreshPlot = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="2D",binwidth2D=0.5, binheight=3,PQNScaling="No",referenceScaling="No",binRegion=c(4,3,60,65), noiseRemoval="No",trimZeros="No",cropHSQC="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE,saveFiles="No", NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) plotNMR() contMin()
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="2D",binwidth2D=0.5, binheight=3,PQNScaling="No",referenceScaling="No",binRegion=c(4,3,60,65), noiseRemoval="No",trimZeros="No",cropHSQC="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE,saveFiles="No", NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) plotNMR() contMin()
This function increases the minimum contour level of the current 2D NMR spectrum plot.
contPlus(refreshPlot = TRUE)
contPlus(refreshPlot = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
resetEnv() addToPlot(folder=system.file("extdata/1/12/pdata/10",package="mrbin"),dimension="2D") plotNMR() contPlus()
resetEnv() addToPlot(folder=system.file("extdata/1/12/pdata/10",package="mrbin"),dimension="2D") plotNMR() contPlus()
This function creates an mrbin object and returns it.
createmrbin()
createmrbin()
An (invisible) mrbin object
mrbinObject<-createmrbin()
mrbinObject<-createmrbin()
This function crops HSQC spectra to the region along the diagonal to remove uninformative signals. Will work only for 1H-13C HSQC spectra.
cropNMR()
cropNMR()
None
resetEnv() results<-mrbin(silent=TRUE, parameters=list(dimension="2D",binwidth2D=1,binheight=4,cropHSQC="No",PCA="No", PQNScaling="No",noiseRemoval="No",removeSolvent="No",verbose=TRUE,tryParallel=TRUE, NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) cropNMR()
resetEnv() results<-mrbin(silent=TRUE, parameters=list(dimension="2D",binwidth2D=1,binheight=4,cropHSQC="No",PCA="No", PQNScaling="No",noiseRemoval="No",removeSolvent="No",verbose=TRUE,tryParallel=TRUE, NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) cropNMR()
This function performs sample-wise scaling of binned data to correct for dilution through different sample volumes used, or for different sample weights. All bin values of one sample are multiplied by the corresponding dilution factor.
dilutionCorrection(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
dilutionCorrection(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
mrbinResults |
An mrbin object |
verbose |
Should a summary be printed? |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
An invisible mrbin object containing scaled NMR data.
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin"))), metadata=list(dilutionFactors=c(.75,1,.5))) results<-dilutionCorrection(results)
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin"))), metadata=list(dilutionFactors=c(.75,1,.5))) results<-dilutionCorrection(results)
This function moves down the plot region of the current NMR plot (only 2D).
down(refreshPlot = TRUE)
down(refreshPlot = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="2D",binwidth2D=0.5, binheight=3,PQNScaling="No",referenceScaling="No",binRegion=c(4,3,60,65), noiseRemoval="No",trimZeros="No",cropHSQC="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE,saveFiles="No", NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) plotNMR() zoomIn() down()
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="2D",binwidth2D=0.5, binheight=3,PQNScaling="No",referenceScaling="No",binRegion=c(4,3,60,65), noiseRemoval="No",trimZeros="No",cropHSQC="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE,saveFiles="No", NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) plotNMR() zoomIn() down()
This function edits the metabolite list within an mrbin object and returns it
editmetabolitesmrbin( mrbinObject, borders = NULL, metabolitenames = NULL, add = FALSE, ids = NULL )
editmetabolitesmrbin( mrbinObject, borders = NULL, metabolitenames = NULL, add = FALSE, ids = NULL )
mrbinObject |
An mrbin object |
borders |
A matrix of signal borders. 1D: two columns: left, right. 2D: four columns: left, right, top, bottom |
metabolitenames |
A character vector of metabolite identities |
add |
Should the new metabolite list be added to an existing list, or replace the current list? |
ids |
A matrix of potential metabolite identities. This has to be a 4-column matrix with columns indicating left, right, top, bottom. Rownames are metabolite names. If this matrix is not provided, borders and metabolitenames have to be provided. |
An (invisible) mrbin object
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-editmetabolitesmrbin(results,borders=matrix(c( 1.346,1.324, 4.12,4.1, 3.052,3.043, 4.066,4.059 ),ncol=2,byrow=TRUE),metabolitenames=c( "Lactate", "Lactate", "Creatinine", "Creatinine" )) results$parameters$metaboliteIdentities
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-editmetabolitesmrbin(results,borders=matrix(c( 1.346,1.324, 4.12,4.1, 3.052,3.043, 4.066,4.059 ),ncol=2,byrow=TRUE),metabolitenames=c( "Lactate", "Lactate", "Creatinine", "Creatinine" )) results$parameters$metaboliteIdentities
This function edits an mrbin object and returns it. This is the only documented way to edit mrbin objects, all other ways of editing such object might cause warning message
editmrbin( mrbinObject, functionName = "mrbin::editmrbin", versionNumber = as.character(utils::packageVersion("mrbin")), bins = NULL, parameters = NULL, metadata = NULL, transformations = NULL, comment = "", verbose = TRUE )
editmrbin( mrbinObject, functionName = "mrbin::editmrbin", versionNumber = as.character(utils::packageVersion("mrbin")), bins = NULL, parameters = NULL, metadata = NULL, transformations = NULL, comment = "", verbose = TRUE )
mrbinObject |
An mrbin object |
functionName |
Name of the package and function calling this command |
versionNumber |
Version number of the package calling this command |
bins |
A matrix containing values to be written to the mrbin object |
parameters |
A list containing values to be written to the mrbin object parameters, names must be names of the mrbin object, e.g. dimension |
metadata |
A list containing values to be written to the mrbin object parameters, names must be names of the mrbin object |
transformations |
An optional character vector describing any used data transformations or scaling such as reference scaling, PQN, log, atnv, etc. |
comment |
An optional character vector describing the change |
verbose |
Should a summary be displayed? |
An (invisible) mrbin object
mrbinObject<-createmrbin() mrbinObject<-editmrbin(mrbinObject)
mrbinObject<-createmrbin() mrbinObject<-editmrbin(mrbinObject)
This function finds features that can change the outcomes of a model's prediction. Example: fia=1.00 means single compound found in all but 0 percent of samples. fia=2.45 indicates this compound is found in pairs in all but 45 percent of tested samples A function named predict needs to be present for this to work. If the function name of the prediction function is different, the function name has to be provided in the parameter functionNamePredict.
fia( model, dataSet, factors, nSeed = 6, numberOfSamples = 100, maxFeatures = 10000, innerLoop = 300, verbose = TRUE, maxNumberAllTests = 5, firstLevel = 1, saveMemory = FALSE, kerasClearMemory = 0, functionNamePredict = "predict", parameterNameObject = "object", parameterNameData = "x", ... )
fia( model, dataSet, factors, nSeed = 6, numberOfSamples = 100, maxFeatures = 10000, innerLoop = 300, verbose = TRUE, maxNumberAllTests = 5, firstLevel = 1, saveMemory = FALSE, kerasClearMemory = 0, functionNamePredict = "predict", parameterNameObject = "object", parameterNameData = "x", ... )
model |
A predictive model. Make sure to have loaded all required packages before starting this function |
dataSet |
An object containing data, columns=features, rows=samples. This should be either a matrix or a dataframe, depending on which of these two the specific prediction function requires |
factors |
A factor vector with group membership of each sample in the data set. Order of levels must correspond to the number predicted by the model |
nSeed |
Number of times that the test will be repeated, selecting different random features |
numberOfSamples |
Number of samples that will be randomly chosen from each group |
maxFeatures |
Maximum number of features that will be tested. Larger numbers will be split into child nodes without testing to increase speed |
innerLoop |
Number of repeated loops to test additional child nodes |
verbose |
A logical vector to turn messages on or off |
maxNumberAllTests |
Combinations of features of this length or shorter will not be split in half to create two children, but into multiple children with one feature left out each. This is done make sure no combination is missed. |
firstLevel |
Numeric value of first level or group. Usually 1 but for glm such as in the example this needs to be 0. |
saveMemory |
Save memory by performing only two predictions per step, which will be much slower. If you are using keras, use parameter kerasClearMemory=2 instead to free more memory and be a lot faster. FALSE to turn off. |
kerasClearMemory |
Save memory by clearing model from memory and reloading the model between chunks of predictions. Will only work when using package keras. 0=off, 1=medium (reload between repeat with different seeds), 2=maximum memory savings (reload after each run for a single sample). This will write a model file to the working directory. |
functionNamePredict |
The name of the prediction function. This only needs to be changed if the prediction function is not called predict |
parameterNameObject |
The name of the parameter for passing the model to the prediction function |
parameterNameData |
The name of the parameter for passing the data to the prediction function |
... |
Optional, additional parameters that will be passed to the prediction function. |
A list of results: scoresSummary A vector of fia scores for the whole dataset; scores contains vectors of fia scores for each predicted group; scoresIndividual A list of fia scores for each individual sample; fiaListPerSample A list of important combinations of features for each predicted sample; fiaMatrix A list of fia scores for each predicted group.
#First, define group membership and create the example feature data group<-factor(c(rep("Group1",4),rep("Group2",5))) names(group)<-paste("Sample",1:9,sep="") dataset<-data.frame( Feature1=c(5.1,5.0,6.0,2.9,4.8,4.6,4.9,3.8,5.1), Feature2=c(2.6,4.0,3.2,1.2,3.1,2.1,4.5,6.1,1.3), Feature3=c(3.1,6.1,5.8,5.1,3.8,6.1,3.4,4.0,4.4), Feature4=c(5.3,5.2,3.1,2.7,3.2,2.8,5.9,5.8,3.1), Feature5=c(3.2,4.4,4.8,4.9,6.0,3.6,6.1,3.9,3.5), Feature6=c(6.8,6.7,7.2,7.0,7.3,7.1,7.2,6.9,6.8) ) rownames(dataset)<-names(group) #train a model - here we use a logit model instead of ANN as a demonstration mod<-glm(group~Feature1+Feature2+Feature3+Feature4+Feature5+Feature6, data=data.frame(group=group,dataset),family="binomial") fiaresults<-fia(model=mod,dataSet=dataset,factors=group,parameterNameData="newdata", firstLevel=0,type="response") fiaresults$scores
#First, define group membership and create the example feature data group<-factor(c(rep("Group1",4),rep("Group2",5))) names(group)<-paste("Sample",1:9,sep="") dataset<-data.frame( Feature1=c(5.1,5.0,6.0,2.9,4.8,4.6,4.9,3.8,5.1), Feature2=c(2.6,4.0,3.2,1.2,3.1,2.1,4.5,6.1,1.3), Feature3=c(3.1,6.1,5.8,5.1,3.8,6.1,3.4,4.0,4.4), Feature4=c(5.3,5.2,3.1,2.7,3.2,2.8,5.9,5.8,3.1), Feature5=c(3.2,4.4,4.8,4.9,6.0,3.6,6.1,3.9,3.5), Feature6=c(6.8,6.7,7.2,7.0,7.3,7.1,7.2,6.9,6.8) ) rownames(dataset)<-names(group) #train a model - here we use a logit model instead of ANN as a demonstration mod<-glm(group~Feature1+Feature2+Feature3+Feature4+Feature5+Feature6, data=data.frame(group=group,dataset),family="binomial") fiaresults<-fia(model=mod,dataSet=dataset,factors=group,parameterNameData="newdata", firstLevel=0,type="response") fiaresults$scores
This function returns a list of all objects of the current package environment. This may be helpful for debugging or for accessing NMR spectral data and the raw bin data.
getEnv()
getEnv()
A list containing all objects from the local package environment.
tempList<-getEnv()
tempList<-getEnv()
This function decreases the intensity of the current NMR spectrum plot.
intMin(dimension = "1D", refreshPlot = TRUE, value = NULL)
intMin(dimension = "1D", refreshPlot = TRUE, value = NULL)
dimension |
Dimension to use. Defaults to "1D" |
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
value |
Set exact value. Defaults to NULL |
None
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() intMin()
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() intMin()
This function increases the intensity of the current NMR spectrum plot.
intPlus(dimension = "1D", refreshPlot = TRUE)
intPlus(dimension = "1D", refreshPlot = TRUE)
dimension |
Dimension to use. Defaults to "1D" |
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() intPlus()
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() intPlus()
This function moves left the plot region of the current NMR plot.
left(refreshPlot = TRUE)
left(refreshPlot = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="1D",binwidth1D=.5, noiseRemoval="No",trimZeros="No",tryParallel=TRUE, PQNScaling="No",saveFiles="No",referenceScaling="No", fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn() left()
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="1D",binwidth1D=.5, noiseRemoval="No",trimZeros="No",tryParallel=TRUE, PQNScaling="No",saveFiles="No",referenceScaling="No", fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn() left()
This function performs logarithm transformation. Will not work with negative data.
logTrafo(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
logTrafo(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
mrbinResults |
An mrbin object |
verbose |
Should a summary be printed? |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
An invisible mrbin object
resetEnv() results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", logTrafo="No", binwidth1D=0.05,signal_to_noise1D=50,verbose=TRUE,PCA="No",tryParallel=TRUE, NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin")))) results<-logTrafo(results)
resetEnv() results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", logTrafo="No", binwidth1D=0.05,signal_to_noise1D=50,verbose=TRUE,PCA="No",tryParallel=TRUE, NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin")))) results<-logTrafo(results)
This function edits interactively or non-interactively the metadata filed of the provided mrbin object.
metadatamrbin(mrbinResults, metadata = NULL, graphics = graphics)
metadatamrbin(mrbinResults, metadata = NULL, graphics = graphics)
mrbinResults |
An mrbin object |
metadata |
An optional list of objects to be changed. If provided, interactive mode is deactivated |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
An invisible mrbin object
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-metadatamrbin(results,metadata=list(projectTitle="Test project"))
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-metadatamrbin(results,metadata=list(projectTitle="Test project"))
This function guides the user through the set-up of parameters, starts binning and performs the chosen data processing steps. If a list of parameters is provided and silent is set to TRUE, no user input is requested and binning and data processing are performed silently.
mrbin( silent = FALSE, setDefault = FALSE, parameters = NULL, metadata = NULL, graphics = TRUE )
mrbin( silent = FALSE, setDefault = FALSE, parameters = NULL, metadata = NULL, graphics = TRUE )
silent |
If TRUE, the user will be asked no questions and binning and data analysis will run according to the current parameters. Defaults to FALSE. |
setDefault |
If TRUE, all current parameters will be replaced by the default parameters (before loading any provided parameters sets). Defaults to FALSE. |
parameters |
Optional: A list of parameters, see examples for details. If omitted, the user will be asked through a series of question to set the parameters. |
metadata |
Optional: A list of metadata. If omitted, the user can add metadata after generating bin data. |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
An invisible object of type "mrbin" containing bins (data after processing), parameters, and factors
# Set parameters in command line. results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list( dimension="1D",binwidth1D=0.01,tryParallel=TRUE, signal_to_noise1D=25,noiseThreshold=0.75,useAsNames="Spectrum titles", NMRfolders=c( system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) ))
# Set parameters in command line. results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list( dimension="1D",binwidth1D=0.01,tryParallel=TRUE, signal_to_noise1D=25,noiseThreshold=0.75,useAsNames="Spectrum titles", NMRfolders=c( system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) ))
This function reads parameters from the global variable mrbin.env$mrbin$parameters and performs the following operations: Reading NMR files, creating bins, removing solvent area, removing additional user-defined areas, summing up bins that contain unstable peaks such as citric acid, removes noise bins, crops HSQC spectra to the diagonal area, performs PQN scaling, replaces negative values, log transforms and displays a PCA plot. Parameters are then saved in a text file. These can be recreated using recreatemrbin().
mrbinrun( createbins = TRUE, process = TRUE, mrbinResults = NULL, silent = TRUE, graphics = TRUE )
mrbinrun( createbins = TRUE, process = TRUE, mrbinResults = NULL, silent = TRUE, graphics = TRUE )
createbins |
If TRUE, new bin data is generated |
process |
If TRUE, bin data is processed, e.g. by noise removal, atnv, etc. |
mrbinResults |
An mrbin object. Needs to be provided only if createbins is FALSE |
silent |
If set to FALSE, no new time calculation is performed |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
An invisible mrbin object
resetEnv() setParam(parameters=list(dimension="2D",binwidth2D=0.1,binheight=5, binRegion=c(8,1,15,140),PQNScaling="No",tryParallel=TRUE,useAsNames="Spectrum titles", fixNegatives="No",logTrafo="No",signal_to_noise2D=10,solventRegion=c(5.5,4.2), NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/2/12/pdata/10",package="mrbin"), system.file("extdata/3/12/pdata/10",package="mrbin")))) results<-mrbinrun()
resetEnv() setParam(parameters=list(dimension="2D",binwidth2D=0.1,binheight=5, binRegion=c(8,1,15,140),PQNScaling="No",tryParallel=TRUE,useAsNames="Spectrum titles", fixNegatives="No",logTrafo="No",signal_to_noise2D=10,solventRegion=c(5.5,4.2), NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/2/12/pdata/10",package="mrbin"), system.file("extdata/3/12/pdata/10",package="mrbin")))) results<-mrbinrun()
This function plots heatmaps based on rank order, using heatmap from the stats package
mrheatmap( results, binlist = NULL, samplelist = NULL, annotate = FALSE, cexRow = 0.7, cexCol = 0.8, margins = c(4, 6), Colv = NA, Rowv = NULL, closeDevice = TRUE, ... )
mrheatmap( results, binlist = NULL, samplelist = NULL, annotate = FALSE, cexRow = 0.7, cexCol = 0.8, margins = c(4, 6), Colv = NA, Rowv = NULL, closeDevice = TRUE, ... )
results |
Either an mrbin object or a numeric matrix containing sample names as rownames and feature names as columns names. |
binlist |
A vector containing bin names as they are generated by mrbin (colnames). If provided, only these columns will be shown. |
samplelist |
A vector containing sample names (rownames). If provided, only these rows will be shown. |
annotate |
Should peak annotations be shown? This requires annotation data in the mrbin object. |
cexRow |
Font size for row labels |
cexCol |
Font size for column labels |
margins |
Determines the plot margins. |
Colv |
Determines if and how the column dendrogram should be computed and reordered. Default: NA (dendrogram will not be used) |
Rowv |
Determines if and how the row dendrogram should be computed and reordered. Default: NULL (dendrogram will be used) |
closeDevice |
Should previous plots be closed prior to plotting? |
... |
Additional graphical parameters that will be passed to the stats function heatmap |
None
resetEnv() # First create NMR bin data, then plot some differential bins. results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(verbose=FALSE, dimension="1D",binwidth1D=0.01,PCA="No",showSpectrumPreview="No", signal_to_noise1D=25,noiseThreshold=0.75,useAsNames="Spectrum titles", NMRfolders=c( system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) metadata<-c(0,0,1) #Find significant signals pvalues<-rep(NA,ncol(results$bins)) names(pvalues)<-colnames(results$bins) for(i in 1:ncol(results$bins)){ model<-stats::lm(intensity~treatment, data=data.frame(intensity=results$bins[,i],treatment=metadata)) pvalues[i]<-stats::anova(model)$"Pr(>F)"[1] } significantBins<-names(sort(pvalues)[1:30]) metaboliteIdentities=matrix(c(1.346,1.324,21,23, 4.12,4.1,70.8578,71.653, 3.052,3.043,30.5,33.5, 4.066,4.059,57,59.5, 5.7,6.0,0,150), ncol=4,byrow=TRUE) #Annotate the dataset with signal identities rownames(metaboliteIdentities)=c("Lactate","Lactate","Creatinine","Creatinine","Urea") results<-annotatemrbin(results,metaboliteIdentities=metaboliteIdentities) mrheatmap(results=results, binlist=significantBins,annotate=TRUE, main="Significant signals")
resetEnv() # First create NMR bin data, then plot some differential bins. results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(verbose=FALSE, dimension="1D",binwidth1D=0.01,PCA="No",showSpectrumPreview="No", signal_to_noise1D=25,noiseThreshold=0.75,useAsNames="Spectrum titles", NMRfolders=c( system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) metadata<-c(0,0,1) #Find significant signals pvalues<-rep(NA,ncol(results$bins)) names(pvalues)<-colnames(results$bins) for(i in 1:ncol(results$bins)){ model<-stats::lm(intensity~treatment, data=data.frame(intensity=results$bins[,i],treatment=metadata)) pvalues[i]<-stats::anova(model)$"Pr(>F)"[1] } significantBins<-names(sort(pvalues)[1:30]) metaboliteIdentities=matrix(c(1.346,1.324,21,23, 4.12,4.1,70.8578,71.653, 3.052,3.043,30.5,33.5, 4.066,4.059,57,59.5, 5.7,6.0,0,150), ncol=4,byrow=TRUE) #Annotate the dataset with signal identities rownames(metaboliteIdentities)=c("Lactate","Lactate","Creatinine","Creatinine","Urea") results<-annotatemrbin(results,metaboliteIdentities=metaboliteIdentities) mrheatmap(results=results, binlist=significantBins,annotate=TRUE, main="Significant signals")
This function plots NMR spectra. A menu of commands is displayed to edit the plot view and add spectra. Multiple spectra will be overlaid, and if both 1D and 2D spectra are selected, they are shown in two plots with matched ranges.
mrplot( hideMenu = FALSE, folders = NULL, dimensions = NULL, intensity1D = NULL, zoom = NULL, color = NULL, background = NULL, lwd = 1, plotTitle = "", showNames = "Spectrum titles", graphics = TRUE, highlight = NULL, binlist = NULL, annotate = NULL, metaboliteIdentities = NULL, ... )
mrplot( hideMenu = FALSE, folders = NULL, dimensions = NULL, intensity1D = NULL, zoom = NULL, color = NULL, background = NULL, lwd = 1, plotTitle = "", showNames = "Spectrum titles", graphics = TRUE, highlight = NULL, binlist = NULL, annotate = NULL, metaboliteIdentities = NULL, ... )
hideMenu |
Do not show the menu. Defaults to FALSE |
folders |
Optional vector of folder names of spectra to load. Defaults to NULL |
dimensions |
Optional vector dimensions of spectra to load. Defaults to NULL |
intensity1D |
Optional value of initial 1D intensity. Defaults to NULL |
zoom |
Optional vector of initial zoom area. Defaults to NULL |
color |
Defines the color of the spectrum plot. If NULL, a rainbow theme is used for 2D NMR |
background |
Background color, defaults to NULL (no background fill, usually results in a white background) |
lwd |
Line width, defaults to 1 |
plotTitle |
Plot title, defaults to "" (empty) |
showNames |
Display list of spectrum titles in plot, defaults to "Spectrum titles". Other options are "" and "Folder names" |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
highlight |
A vector of up to 2 frequencies that will be highlighted in the plot. If 2 values are provided the distance in Hz is shown as well. Defaults to NULL. |
binlist |
Optional: A vector containing bin names as they are generated by mrbin. These bins will be marked by rectangles in the plot. This could be useful for metabolite identification when having a list of significantly changing signals. Default is NULL. |
annotate |
Should peak annotation regions be shown? |
metaboliteIdentities |
Optional: A file path or 4-column matrix where each row belongs to one unique metabolite signal (left, right, top, bottom borders). Row names are metabolite names. For a file, this needs to be the file path for a .csv file containing such a matrix, the first columns containing metabolite names and the first row being a header. Each row belongs to one unique metabolite signal (left, right, top, bottom borders). Row names are metabolite names. |
... |
Additional graphical parameters that will be passed to the functions plot, lines, and/or contour |
None
resetEnv() metaboliteIdentities=matrix(c(1.346,1.324,21,23, 4.12,4.1,70.8578,71.653, 3.052,3.043,30.5,33.5, 4.066,4.059,57,59.5, 2.582,2.479,46,49, 2.737,2.634,46,49), ncol=4,byrow=TRUE) rownames(metaboliteIdentities)=c("Lactate","Lactate","Creatinine","Creatinine","Citrate","Citrate") mrplot(folders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")), dimensions=c("2D","1D","1D","1D"),zoom=c(2.8,2.4,20,60), highlight=c(2.564,2.537), binlist=c("2.725,2.675","2.575,2.525"), annotate=TRUE,metaboliteIdentities=metaboliteIdentities, plotTitle="Significant Bins",intensity1D=24,hideMenu=TRUE)
resetEnv() metaboliteIdentities=matrix(c(1.346,1.324,21,23, 4.12,4.1,70.8578,71.653, 3.052,3.043,30.5,33.5, 4.066,4.059,57,59.5, 2.582,2.479,46,49, 2.737,2.634,46,49), ncol=4,byrow=TRUE) rownames(metaboliteIdentities)=c("Lactate","Lactate","Creatinine","Creatinine","Citrate","Citrate") mrplot(folders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")), dimensions=c("2D","1D","1D","1D"),zoom=c(2.8,2.4,20,60), highlight=c(2.564,2.537), binlist=c("2.725,2.675","2.575,2.525"), annotate=TRUE,metaboliteIdentities=metaboliteIdentities, plotTitle="Significant Bins",intensity1D=24,hideMenu=TRUE)
This function plots the current NMR spectrum. If no parameters are provided, parameters are read from the mrbin.env environment variables, set by mrbin. To change the plot, use zoom(), zoomIn(), zoomOut(), intPlus(), intMin(), left(), right(). For 2D data use additionally: contMin(), contPlus(), up(), down()
plotMultiNMR( region = NULL, rectangleRegions = NULL, rectangleColors = c("darkseagreen3", "orange", "blue", "red", "yellow", "gray", "purple"), density = NULL, cex.axis = 0.7, rectangleFront = FALSE, correctOffset2D = TRUE, polygonRegion = NULL, maxPlots = Inf, setContours = TRUE, color = NULL, add = FALSE, showGrid = FALSE, buffer = TRUE, manualScale = TRUE, plotTitle = "", renewSpectrum = TRUE, restrictToRange = FALSE, enableSplit = TRUE, dimension = NULL, lwd = 1, background = NULL, titles = NULL, plotCurrent = TRUE, ... )
plotMultiNMR( region = NULL, rectangleRegions = NULL, rectangleColors = c("darkseagreen3", "orange", "blue", "red", "yellow", "gray", "purple"), density = NULL, cex.axis = 0.7, rectangleFront = FALSE, correctOffset2D = TRUE, polygonRegion = NULL, maxPlots = Inf, setContours = TRUE, color = NULL, add = FALSE, showGrid = FALSE, buffer = TRUE, manualScale = TRUE, plotTitle = "", renewSpectrum = TRUE, restrictToRange = FALSE, enableSplit = TRUE, dimension = NULL, lwd = 1, background = NULL, titles = NULL, plotCurrent = TRUE, ... )
region |
A vector defining the plot region (left, right, top, bottom) or "all" for the whole spectrum |
rectangleRegions |
A 4-column matrix defining areas where to plot rectangles |
rectangleColors |
Define colors for the rectangles |
density |
Shading lines for the rectangles |
cex.axis |
Font size of axis tick labels. |
rectangleFront |
Plot rectangles in front of spectrum rather than in background (only 2D) |
correctOffset2D |
Do a basic offset correction so 2D spectra have a baseline close to 0. Defaults to TRUE |
polygonRegion |
Defines 4 corners of a polygon to be plotted |
maxPlots |
The maximum number of 2D plots to be overlaid |
setContours |
Should upper and lower contour levels be calculated of the old ones be reused? Default: TRUE |
color |
Defines the color of the spectrum plot. If NULL, a rainbow theme is used for 2D NMR |
add |
If TRUE, additional spectrum plots are overlaid with the current plot |
showGrid |
Shows a grid of data points. Defaults to FALSE |
buffer |
Speed up plotting by loading a plot. Defaults to TRUE |
manualScale |
If TRUE, scaling factor is taken from environment variables |
plotTitle |
Defines the main title of the plot |
renewSpectrum |
Should a new size-reduced spectrum for quicker plotting be calculated, or can the old one be used? Default: TRUE |
restrictToRange |
Restrict plot area to range of available data points. Defaults to FALSE |
enableSplit |
Allow split plots for showing 1D and 2D spectra simultaneously |
dimension |
If not provided, this will be taken from package environment |
lwd |
Line width, defaults to 1 |
background |
Background color, defaults to NULL (no background fill, usually results in a white background) |
titles |
Display list of spectrum titles in plot, defaults to NULL |
plotCurrent |
Should the first (current) spectrum in the list be plotted, defaults to TRUE |
... |
Additional graphical parameters that will be passed to the functions plot, lines, and/or contour |
None
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotMultiNMR()
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotMultiNMR()
This function plots the current NMR spectrum. If no parameters are provided, parameters are read from the mrbin.env environment variables, set by mrbin. To change the plot, use zoom(), zoomIn(), zoomOut(), intPlus(), intMin(), left(), right(). For 2D data use additionally: contMin(), contPlus(), up(), down()
plotNMR( region = NULL, rectangleRegions = NULL, rectangleColors = c("darkseagreen3", "orange", "blue", "red", "yellow", "gray", "purple"), density = NULL, rectangleFront = FALSE, polygonRegion = NULL, color = NULL, add = FALSE, showGrid = FALSE, manualScale = TRUE, plotTitle = "", title = NULL, titleCounter = NULL, hideNegative = FALSE, restrictToRange = FALSE, currentSpectrumOriginal = NULL, spectrumTMP = NULL, renewSpectrum = TRUE, cex.axis = 0.7, perspective = FALSE, noise = NULL, dimension = NULL, plotDelay = 0.1, lwd = 1, background = NULL, ... )
plotNMR( region = NULL, rectangleRegions = NULL, rectangleColors = c("darkseagreen3", "orange", "blue", "red", "yellow", "gray", "purple"), density = NULL, rectangleFront = FALSE, polygonRegion = NULL, color = NULL, add = FALSE, showGrid = FALSE, manualScale = TRUE, plotTitle = "", title = NULL, titleCounter = NULL, hideNegative = FALSE, restrictToRange = FALSE, currentSpectrumOriginal = NULL, spectrumTMP = NULL, renewSpectrum = TRUE, cex.axis = 0.7, perspective = FALSE, noise = NULL, dimension = NULL, plotDelay = 0.1, lwd = 1, background = NULL, ... )
region |
A vector defining the plot region (left, right, top, bottom) or "all" for the whole spectrum |
rectangleRegions |
A 4-column matrix defining areas where to plot rectangles |
rectangleColors |
Define colors for the rectangles |
density |
Shading lines for the rectangles |
rectangleFront |
Plot rectangles in front of spectrum rather than in background (only 2D) |
polygonRegion |
Defines 4 corners of a polygon to be plotted |
color |
Defines the color of the spectrum plot. If NULL, a rainbow theme is used for 2D NMR |
add |
If TRUE, additional spectrum plots are overlaid with the current plot |
showGrid |
Shows a grid of data points. Defaults to FALSE |
manualScale |
If TRUE, scaling factor is taken from environment variables |
plotTitle |
Defines the main title of the plot |
title |
Display the spectrum title in plot, defaults to NULL |
titleCounter |
Count of the spectrum title for positioning in plot, defaults to NULL |
hideNegative |
Should negative parts of the 2D spectrum be hidden? Defaults to FALSE |
restrictToRange |
Restrict plot area to range of available data points. Defaults to FALSE |
currentSpectrumOriginal |
Optional spectral data. If omitted, data from the environment variables is used |
spectrumTMP |
A size-reduced spectrum for quicker plotting. Defaults to NULL |
renewSpectrum |
Should a new size-reduced spectrum for quicker plotting be calculated, or can the old one be used? Default: TRUE |
cex.axis |
Font size of axis tick labels. |
perspective |
If TRUE, a perspective plot will be displayed for 2D data instead of the regular topographic view |
noise |
If provided, a line or plane at this level will be added to the plot to indicate noise level |
dimension |
"1D' or "2D". If not provided, this will be deduced from the data |
plotDelay |
Add a small delay in seconds to force RStudio to update plots |
lwd |
Line width, defaults to 1 |
background |
Background color, defaults to NULL (no background fill, usually results in a white background) |
... |
Additional graphical parameters that will be passed to the functions plot, lines, and/or contour |
An (invisible) dimension-reduced spectrum, either a matrix or a vector
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR()
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR()
This function performs PCA, then plots PC1 and PC2.
plotPCA( mrbinResults, defineGroups = TRUE, loadings = FALSE, legendPosition = "bottomleft", annotate = TRUE, verbose = TRUE )
plotPCA( mrbinResults, defineGroups = TRUE, loadings = FALSE, legendPosition = "bottomleft", annotate = TRUE, verbose = TRUE )
mrbinResults |
An mrbin object |
defineGroups |
Should groups be colored differently? |
loadings |
Should loadings be plotted instead of scores? |
legendPosition |
Where should the legend be plotted, Defaults to "left", other options include "top", "topright", etc. |
annotate |
Should loadings be annotated with metabolite identities, if available in $metadata? |
verbose |
Should a summary be displayed? |
An invisible prcomp result object
results<-mrbin(silent=TRUE,setDefault=FALSE,parameters=list(dimension="2D", binRegion=c(8,1,15,140),binwidth2D=0.1,binheight=4,solventRegion=c(5.5,4.2), PQNScaling="No",noiseRemoval="Yes",trimZeros="Yes",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",signal_to_noise2D=10, NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/2/12/pdata/10",package="mrbin"), system.file("extdata/3/12/pdata/10",package="mrbin")))) plotPCA(results)
results<-mrbin(silent=TRUE,setDefault=FALSE,parameters=list(dimension="2D", binRegion=c(8,1,15,140),binwidth2D=0.1,binheight=4,solventRegion=c(5.5,4.2), PQNScaling="No",noiseRemoval="Yes",trimZeros="Yes",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",signal_to_noise2D=10, NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/2/12/pdata/10",package="mrbin"), system.file("extdata/3/12/pdata/10",package="mrbin")))) plotPCA(results)
This function plots boxplots (bin-wise and sample-wise) as visual quality indicators. It also performs PCA, then plots PC1 and PC2 and loading plots.
plotResults(mrbinResults, defineGroups = TRUE, process = TRUE, silent = FALSE)
plotResults(mrbinResults, defineGroups = TRUE, process = TRUE, silent = FALSE)
mrbinResults |
An mrbin object |
defineGroups |
Should group membership be highlighted in PCA? |
process |
If set to FALSE, the file name will be extended by "Raw" to indicate that data has not been processed yet |
silent |
If set to TRUE, plots will be saved but not shown for the binning step for speed purposes |
None
results<-mrbin(silent=TRUE,setDefault=FALSE,parameters=list(dimension="2D", binRegion=c(8,1,15,140),binwidth2D=0.2,binheight=4,solventRegion=c(5.5,4.2), PQNScaling="No",noiseRemoval="Yes",trimZeros="Yes",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",signal_to_noise2D=10, NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/2/12/pdata/10",package="mrbin")))) plotResults(results)
results<-mrbin(silent=TRUE,setDefault=FALSE,parameters=list(dimension="2D", binRegion=c(8,1,15,140),binwidth2D=0.2,binheight=4,solventRegion=c(5.5,4.2), PQNScaling="No",noiseRemoval="Yes",trimZeros="Yes",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",signal_to_noise2D=10, NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin"), system.file("extdata/2/12/pdata/10",package="mrbin")))) plotResults(results)
This function performs PQN scaling. To further exclude unreliable noise, only the most intense signals are used. For 1H and 1H-13C HSQC spectra, most of the sugar regions can be excluded to avoid a dominating effect of the multiple glucose signals.
PQNScaling( NMRdata, ignoreGlucose = "Yes", dimension = "1D", ppmNames = "borders", sugarArea = c(5.4, 3.35, 72, 100), minimumFeatures = 40, showHist = FALSE, verbose = TRUE, errorsAsWarnings = FALSE )
PQNScaling( NMRdata, ignoreGlucose = "Yes", dimension = "1D", ppmNames = "borders", sugarArea = c(5.4, 3.35, 72, 100), minimumFeatures = 40, showHist = FALSE, verbose = TRUE, errorsAsWarnings = FALSE )
NMRdata |
A matrix containing NMR data or an mrbin object. Columns=frequencies,rows=samples |
ignoreGlucose |
A character value ("Yes" or "No") |
dimension |
A character value ("1D" or "2D") |
ppmNames |
A character value ("borders" or "mean") |
sugarArea |
A numeric vector defining the the borders of glucose area |
minimumFeatures |
A numeric value defining minimum feature number used |
showHist |
A logical value, default is FALSE |
verbose |
Should a summary be printed? |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
An invisible matrix or mrbin object containing scaled NMR data.
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-PQNScaling(results)
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-PQNScaling(results)
This function predicts group membership and returns a numeric vector with results.
predictWrapper( model, dataSet, functionNamePredict = "predict", firstLevel = 1, parameterNameObject = "object", parameterNameData = "x", dataFrameFlag = FALSE, ... )
predictWrapper( model, dataSet, functionNamePredict = "predict", firstLevel = 1, parameterNameObject = "object", parameterNameData = "x", dataFrameFlag = FALSE, ... )
model |
A predictive model. Make sure to have loaded all required packages before starting this function |
dataSet |
A matrix or dataframe containing data, depending on what your predict function requires. Columns=features, rows=samples |
functionNamePredict |
The name of the prediction function. This only needs to be changed if the prediction function is not called predict |
firstLevel |
Numeric value of first level or group. Usually 1 but for glm such as in the example this needs to be 0. |
parameterNameObject |
The name of the parameter for passing the model to the prediction function |
parameterNameData |
The name of the parameter for passing the data to the prediction function |
dataFrameFlag |
Logical value indicating whether the data object is a data frame rather than a matrix. |
... |
Optional, additional parameters that will be passed to the prediction function. |
A numeric (integer) vector of predicted group memberships.
#First, define group membership and create the example feature data group<-factor(c(rep("Group1",4),rep("Group2",5))) names(group)<-paste("Sample",1:9,sep="") dataset<-data.frame( Feature1=c(5.1,5.0,6.0,2.9,4.8,4.6,4.9,3.8,5.1), Feature2=c(2.6,4.0,3.2,1.2,3.1,2.1,4.5,6.1,1.3), Feature3=c(3.1,6.1,5.8,5.1,3.8,6.1,3.4,4.0,4.4), Feature4=c(5.3,5.2,3.1,2.7,3.2,2.8,5.9,5.8,3.1), Feature5=c(3.2,4.4,4.8,4.9,6.0,3.6,6.1,3.9,3.5) ) rownames(dataset)<-names(group) #train a model - here we use a logit model instead of ANN as a demonstration mod<-glm(group~Feature1+Feature2+Feature3+Feature4+Feature5, data=data.frame(group=group,dataset),family="binomial") predictWrapper(model=mod,dataSet=dataset,firstLevel=0,type="response")
#First, define group membership and create the example feature data group<-factor(c(rep("Group1",4),rep("Group2",5))) names(group)<-paste("Sample",1:9,sep="") dataset<-data.frame( Feature1=c(5.1,5.0,6.0,2.9,4.8,4.6,4.9,3.8,5.1), Feature2=c(2.6,4.0,3.2,1.2,3.1,2.1,4.5,6.1,1.3), Feature3=c(3.1,6.1,5.8,5.1,3.8,6.1,3.4,4.0,4.4), Feature4=c(5.3,5.2,3.1,2.7,3.2,2.8,5.9,5.8,3.1), Feature5=c(3.2,4.4,4.8,4.9,6.0,3.6,6.1,3.9,3.5) ) rownames(dataset)<-names(group) #train a model - here we use a logit model instead of ANN as a demonstration mod<-glm(group~Feature1+Feature2+Feature3+Feature4+Feature5, data=data.frame(group=group,dataset),family="binomial") predictWrapper(model=mod,dataSet=dataset,firstLevel=0,type="response")
This function reads parameters from the global variable mrbin.env$mrbin$parameters and prints the required R code for creating a data set to the screen.
printParameters()
printParameters()
None
printParameters()
printParameters()
This function can change variables in the current package environment. This may be helpful for debugging or for some plotting functions.
putToEnv(variableList)
putToEnv(variableList)
variableList |
A list containing all objects to be saved in the local package environment. |
None
putToEnv(list(bins=NULL))
putToEnv(list(bins=NULL))
This function reads Bruker NMR data. 1D and 2D data are supported.
readBruker( folder = NULL, dimension = NULL, onlyTitles = FALSE, useAsNames = "Spectrum titles", checkFiles = FALSE )
readBruker( folder = NULL, dimension = NULL, onlyTitles = FALSE, useAsNames = "Spectrum titles", checkFiles = FALSE )
folder |
Defines the exact NMR data folder. If NULL, mrbin parameter set is used |
dimension |
Defines the data dimension, "1D" or "2D". Only used if not NULL |
onlyTitles |
Read only spectrum titles, but no data. Defaults to FALSE |
useAsNames |
How should sample names be generated |
checkFiles |
Only check if the folder exists or contains NMR data. Defaults to FALSE |
An (invisible) list containing spectral data and the spectrum name
exampleData<-readBruker(folder=system.file("extdata/1/10/pdata/10",package="mrbin"), dimension="1D")
exampleData<-readBruker(folder=system.file("extdata/1/10/pdata/10",package="mrbin"), dimension="1D")
This function reads parameters from a text file that was created during a previous run or mrbin(). After reading, the data can be recreated using mrbin(). File names in $parameters might need to be updated.
recreatemrbin(filename = NULL, graphics = TRUE)
recreatemrbin(filename = NULL, graphics = TRUE)
filename |
File path/name of the mrbin parameter file to be loaded |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
None
# Insert full folder path and file name recreatemrbin(system.file("extdata/mrbin.txt",package="mrbin"))
# Insert full folder path and file name recreatemrbin(system.file("extdata/mrbin.txt",package="mrbin"))
This function removes a spectrum from the plot list.
removeFromPlot(folder = NULL, dimension = "1D")
removeFromPlot(folder = NULL, dimension = "1D")
folder |
Defines the exact NMR data folder. |
dimension |
Defines the data dimension, "1D" or "2D". |
none
removeFromPlot()
removeFromPlot()
This function checks for each bin (column) whether its level is below the individual noise level times the signal-to-noise ratio. If less than the defined threshold level are above noise*SNR, the whole bin is removed.
removeNoise(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
removeNoise(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
mrbinResults |
An mrbin object |
verbose |
Should a summary be printed? |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
An invisible mrbin object
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,noiseRemoval="No",PQNScaling="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-removeNoise(results)
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,noiseRemoval="No",PQNScaling="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-removeNoise(results)
This function lets the user pick spectra from a list for removal from data analysis.
removeSpectrum( mrbinResults = NULL, spectra = NULL, verbose = TRUE, errorsAsWarnings = FALSE, graphics = TRUE )
removeSpectrum( mrbinResults = NULL, spectra = NULL, verbose = TRUE, errorsAsWarnings = FALSE, graphics = TRUE )
mrbinResults |
An mrbin object. If not provided, the function works on the package environment |
spectra |
Character vector with NMR folder names to be excluded. If provided, no interactive selection will be shown |
verbose |
Should a summary be printed? |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
An invisible mrbin object (only if an mrbin object was provided)
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", noiseRemoval="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-removeSpectrum(results, spectra=c(system.file("extdata/2/10/pdata/10",package="mrbin")))
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", noiseRemoval="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-removeSpectrum(results, spectra=c(system.file("extdata/2/10/pdata/10",package="mrbin")))
This function resets the parameter variables.
resetEnv()
resetEnv()
None
resetEnv()
resetEnv()
This function moves right the plot region of the current NMR plot.
right(refreshPlot = TRUE)
right(refreshPlot = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="1D",binwidth1D=.5, noiseRemoval="No",trimZeros="No",tryParallel=TRUE, PQNScaling="No",saveFiles="No",referenceScaling="No", fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn() right()
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="1D",binwidth1D=.5, noiseRemoval="No",trimZeros="No",tryParallel=TRUE, PQNScaling="No",saveFiles="No",referenceScaling="No", fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn() right()
This function lets the user pick a spectrum from the list of spectra analysis. This function is meant only for use within the mrbin function.
setCurrentSpectrum(spectrumNumber = NULL, graphics = TRUE)
setCurrentSpectrum(spectrumNumber = NULL, graphics = TRUE)
spectrumNumber |
If provided, this number will be used; defaults to NULL |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
None
setCurrentSpectrum(spectrumNumber=1)
setCurrentSpectrum(spectrumNumber=1)
This function edits the dilution factors of an mrbin object but does not change the bin data.
setDilutionFactors( mrbinObject, dilutionFactors = NULL, errorsAsWarnings = FALSE, alwaysShowOptionKeep = FALSE, graphics = TRUE )
setDilutionFactors( mrbinObject, dilutionFactors = NULL, errorsAsWarnings = FALSE, alwaysShowOptionKeep = FALSE, graphics = TRUE )
mrbinObject |
An mrbin object |
dilutionFactors |
An optional vector of dilution factors. If provided, no user input is requested |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
alwaysShowOptionKeep |
If TRUE, you will be asked to keep current values even if they do not match the current dataset. |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
An invisible mrbin object
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-setDilutionFactors(results,dilutionFactors=c(1.5,2))
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-setDilutionFactors(results,dilutionFactors=c(1.5,2))
This function reads parameters from the global variable mrbin.env$mrbin$parameters and plots exemplary spectra and respective noise levels. Plots will be saved if saveFiles is set to "Yes".
setNoiseLevels( mrbinObject, plotOnly = FALSE, showSpectrumPreview = NULL, silent = FALSE, graphics = TRUE )
setNoiseLevels( mrbinObject, plotOnly = FALSE, showSpectrumPreview = NULL, silent = FALSE, graphics = TRUE )
mrbinObject |
An mrbin object |
plotOnly |
Should only noise plots be generated (TRUE), or should noise levels be adjusted interactively (FALSE) |
showSpectrumPreview |
Should plots be shown? If not provided, this value will be taken from the mrbin object parameters |
silent |
If set to TRUE, plots will not be shown but might still be saved |
graphics |
Controls whether pop-up windows are shown for selections. Defaults to TRUE. |
An invisible mrbin object
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-setNoiseLevels(results,plotOnly=TRUE)
results<-mrbin(silent=TRUE, parameters=list(verbose=TRUE,dimension="1D",PQNScaling="No", binwidth1D=0.04,signal_to_noise1D=1,PCA="No",binRegion=c(9.5,0.5,10,156), saveFiles="No",referenceScaling="No",noiseRemoval="No", fixNegatives="No",logTrafo="No",noiseThreshold=.05,tryParallel=TRUE, NMRfolders=c(system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")) )) results<-setNoiseLevels(results,plotOnly=TRUE)
This function moves up or down the 1D plot region of the current NMR plot.
setOffset(offsetValue = NULL)
setOffset(offsetValue = NULL)
offsetValue |
The new offset value. Defaults to NULL |
None
setOffset(0)
setOffset(0)
This function set parameters and checks parameters for consistency.
setParam(parameters = NULL, metadata = NULL)
setParam(parameters = NULL, metadata = NULL)
parameters |
List of parameters to be set |
metadata |
List of metadata to be set |
None
setParam(parameters=list(dimension="1D"))
setParam(parameters=list(dimension="1D"))
This function adds time stamps to an mrbin object and returns it. Is used only within functions making changes to mrbin objects.
timeStampMrbin( mrbinObject, functionName = "InProgress...", versionNumber = "0", changeDetails = "InProgress...", steps = 0, comment = "" )
timeStampMrbin( mrbinObject, functionName = "InProgress...", versionNumber = "0", changeDetails = "InProgress...", steps = 0, comment = "" )
mrbinObject |
An mrbin object |
functionName |
Name of the package and function calling this command |
versionNumber |
Version number of the package calling this command |
changeDetails |
Details of changes made to the mrbin object |
steps |
Indicates which step to perform: 0 (only pre-change), 1 (only post-change) |
comment |
An optional character vector describing the change |
An (invisible) mrbin object
mrbinObject<-createmrbin() mrbinObject<-timeStampMrbin(mrbinObject)
mrbinObject<-createmrbin() mrbinObject<-timeStampMrbin(mrbinObject)
This function removes zero-values bins. These might be created during removal of solvent and additional areas, or at the edges of the spectrum.
trimZeros(mrbinResults)
trimZeros(mrbinResults)
mrbinResults |
An mrbin object |
An invisible mrbin object
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", logTrafo="No", binwidth1D=0.05,signal_to_noise1D=50, verbose=TRUE, PCA="No", trimZeros="No",tryParallel=TRUE, NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin")))) results<-trimZeros(results)
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", logTrafo="No", binwidth1D=0.05,signal_to_noise1D=50, verbose=TRUE, PCA="No", trimZeros="No",tryParallel=TRUE, NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin")))) results<-trimZeros(results)
This function performs scaling of binned data to unit variance so that each bin has variance 1 and mean 0. This is rarely necessary, but might be advantageous, e.g. in artificial neural networks.
unitVarianceScaling(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
unitVarianceScaling(mrbinResults, verbose = TRUE, errorsAsWarnings = FALSE)
mrbinResults |
An mrbin object |
verbose |
Should a summary be printed? |
errorsAsWarnings |
If TRUE, errors will be turned into warnings. Should be used with care, as errors indicate undocumented changes to the data. |
An invisible mrbin object containing scaled NMR data.
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-unitVarianceScaling(results)
results<-mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D", binwidth1D=0.05,PQNScaling="No",PCA="No",tryParallel=TRUE,logTrafo="No", NMRfolders=c(system.file("extdata/1/10/pdata/10",package="mrbin"), system.file("extdata/2/10/pdata/10",package="mrbin"), system.file("extdata/3/10/pdata/10",package="mrbin")))) results<-unitVarianceScaling(results)
This function moves up the plot region of the current NMR plot (only 2D).
up(refreshPlot = TRUE)
up(refreshPlot = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
None
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="2D",binwidth2D=0.5, binheight=3,PQNScaling="No",referenceScaling="No",binRegion=c(4,3,60,65), noiseRemoval="No",trimZeros="No",cropHSQC="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE,saveFiles="No", NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) plotNMR() zoomIn() up()
resetEnv() mrbin(silent=TRUE,parameters=list(dimension="2D",binwidth2D=0.5, binheight=3,PQNScaling="No",referenceScaling="No",binRegion=c(4,3,60,65), noiseRemoval="No",trimZeros="No",cropHSQC="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE,saveFiles="No", NMRfolders=c(system.file("extdata/1/12/pdata/10",package="mrbin")))) plotNMR() zoomIn() up()
This function changes the plot region of the current NMR plot. Can be called with no arguments: zoom(). In this case the user will be asked for manual input.
zoom( left = NULL, right = NULL, top = NULL, bottom = NULL, refreshPlot = TRUE, dimension = "2D" )
zoom( left = NULL, right = NULL, top = NULL, bottom = NULL, refreshPlot = TRUE, dimension = "2D" )
left |
New left boundary |
right |
New right boundary |
top |
New top boundary |
bottom |
New bottom boundary |
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
dimension |
Dimension of the data. Defaults to "2D" |
An invisible value indicating if a change occurred
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoom(left=4.6,right=2,top=10,bottom=150)
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoom(left=4.6,right=2,top=10,bottom=150)
This function zooms into the plot region of the current NMR plot.
zoomIn(refreshPlot = TRUE, x = TRUE, y = TRUE)
zoomIn(refreshPlot = TRUE, x = TRUE, y = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
x |
Change x axis? Defaults to TRUE |
y |
Change y axis? Defaults to TRUE |
None
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn()
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn()
This function zooms out from the plot region of the current NMR plot.
zoomOut(refreshPlot = TRUE, x = TRUE, y = TRUE)
zoomOut(refreshPlot = TRUE, x = TRUE, y = TRUE)
refreshPlot |
Refresh plot automatically. Defaults to TRUE |
x |
Change x axis? Defaults to TRUE |
y |
Change y axis? Defaults to TRUE |
None
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn() zoomOut()
mrbin(silent=TRUE,setDefault=TRUE,parameters=list(dimension="1D",binwidth1D=.1, PQNScaling="No",noiseRemoval="No",trimZeros="No",tryParallel=TRUE, fixNegatives="No",logTrafo="No",PCA="No",verbose=TRUE, NMRfolders=system.file("extdata/1/10/pdata/10",package="mrbin"))) plotNMR() zoomIn() zoomOut()