Performs normalisation on intensities. For median normalisation the normalised intensity is the original intensity minus the run median plus the global median. This is also the way it is implemented in the Spectronaut search engine.

normalise(data, sample, intensity_log2, method = "median")

Arguments

data

a data frame containing at least sample names and intensity values. Please note that if the data frame is grouped, the normalisation will be computed by group.

sample

a character column in the data data frame that contains the sample names.

intensity_log2

a numeric column in the data data frame that contains the log2 transformed intensity values to be normalised.

method

a character value specifying the method to be used for normalisation. Default is "median".

Value

A data frame with a column called normalised_intensity_log2 containing the normalised intensity values.

Examples

data <- data.frame(
  r_file_name = c("s1", "s2", "s3", "s1", "s2", "s3"),
  intensity_log2 = c(18, 19, 17, 20, 21, 19)
)

normalise(data,
  sample = r_file_name,
  intensity_log2 = intensity_log2,
  method = "median"
)
#> # A tibble: 6 × 3
#>   r_file_name intensity_log2 normalised_intensity_log2
#>   <chr>                <dbl>                     <dbl>
#> 1 s1                      18                        18
#> 2 s2                      19                        18
#> 3 s3                      17                        18
#> 4 s1                      20                        20
#> 5 s2                      21                        20
#> 6 s3                      19                        20