atnv: A function replacing negative values.

View source: R/mrbin.R

atnvR Documentation

A function replacing negative values.

Description

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.

Usage

atnv(NMRdata, noiseLevels = NULL, verbose = TRUE, errorsAsWarnings = FALSE)

Arguments

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.

Value

An invisible matrix or mrbin object containing NMR data without negative values.

Examples

 resetEnv()
 Example<-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(Example$bins<=0)
 exampleNMRpositive<-atnv(NMRdata=Example$bins, noiseLevels=Example$parameters$noise_level_adjusted)
 sum(exampleNMRpositive<=0)

mrbin documentation built on June 22, 2024, 9:39 a.m.