LFQDataTransformer: Decorate LFQData with Methods for transforming Intensities

LFQDataTransformerR Documentation

Decorate LFQData with Methods for transforming Intensities

Description

Decorate LFQData with Methods for transforming Intensities

Decorate LFQData with Methods for transforming Intensities

Public fields

lfq

LFQData object

Methods

Public methods


Method new()

initialize

Usage
LFQDataTransformer$new(lfqdata)
Arguments
lfqdata

LFQData object to transform


Method log2()

log2 transform data

Usage
LFQDataTransformer$log2(force = FALSE)
Arguments
force

if FALSE, then data already log2 transformed will not be transformed a second time. TRUE force log transformation.

Returns

LFQDataTransformer


Method get_scales()

get mean and variance and standard deviation in each sample

Usage
LFQDataTransformer$get_scales()
Returns

list with means and mads


Method robscale()

robust scale data

Usage
LFQDataTransformer$robscale(
  preserveMean = TRUE,
  colname = "transformedIntensity"
)
Arguments
preserveMean

should original mean value be preserved TRUE, if FALSE then center at zero

colname

new name of transformed column

Returns

LFQDataTransformer (self)


Method robscale_subset()

log2 transform and robust scale data based on subset

Usage
LFQDataTransformer$robscale_subset(
  lfqsubset,
  preserveMean = TRUE,
  colname = "transformedIntensity"
)
Arguments
lfqsubset

LFQData subset to use for normalization

preserveMean

should original mean value be preserved TRUE, if FALSE then center at zero

colname

- how to name the transformed intensities, default transformedIntensity

Returns

LFQDataTransformer (self)


Method intensity_array()

Transforms intensities

Usage
LFQDataTransformer$intensity_array(.func = log2, force = FALSE)
Arguments
.func

transformation function working with arrays e.g. log2, log10, asinh etc.

force

transformation on already transformed data.

Returns

LFQDataTransformer (self)


Method intensity_matrix()

pass a function which works with matrices, e.g., vsn::justvsn

Usage
LFQDataTransformer$intensity_matrix(.func = robust_scale, force = FALSE)
Arguments
.func

any function taking a matrix and returning a matrix (columns sample, rows feature e.g. base::scale) default robust_scale

force

transformation on data already transformed

Returns

LFQDataTransformer (self)


Method clone()

The objects of this class are cloneable with this method.

Usage
LFQDataTransformer$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


istar <- prolfqua_data('data_ionstar')$filtered()
istar$config <- old2new(istar$config)
data <- istar$data |> dplyr::filter(protein_Id %in% sample(protein_Id, 100))
lfqdata <- LFQData$new(data, istar$config)

lfqcopy <- lfqdata$get_copy()
lfqTrans <- lfqcopy$get_Transformer()

x <- lfqTrans$intensity_array(log2)
x$lfq$config$table$is_response_transformed
x <- x$intensity_matrix(robust_scale)
plotter <- x$lfq$get_Plotter()
plotter$intensity_distribution_density()

# transform by asinh root and scale

lfqcopy <- lfqdata$get_copy()
lfqTrans <- lfqcopy$get_Transformer()
x <- lfqTrans$intensity_array(asinh)
mads1 <- mean(x$get_scales()$mads)
x <- lfqTrans$intensity_matrix(robust_scale, force = TRUE)
mads2 <- mean(x$get_scales()$mads)

stopifnot(abs(mads1 - mads2) < 1e-8)


stopifnot(abs(mean(x$get_scales()$medians)) < 1e-8)
lfqcopy <- lfqdata$get_copy()
lfqTrans <- lfqcopy$get_Transformer()
lfqTrans$log2()
before <- lfqTrans$get_scales()
lfqTrans$robscale()
after <- lfqTrans$get_scales()
stopifnot(abs(mean(before$medians) - mean(after$medians)) < 1e-8)
stopifnot(abs(mean(before$mads) - mean(after$mads)) < 1e-8)

# normalize data using vsn
lfqcopy <- lfqdata$get_copy()
lfqTrans <- lfqcopy$get_Transformer()
lfqTransCheck <- lfqcopy$get_Transformer()

lfqTransCheck$log2()
lfqTransCheck$get_scales()
lfqTransCheck$lfq$get_Plotter()$intensity_distribution_density()

if(require("vsn")){
 res <- lfqTrans$intensity_matrix( .func = vsn::justvsn)
 res$lfq$get_Plotter()$intensity_distribution_density()
 res$get_scales()
}
if(require("preprocessCore")){
quant <- function(y){
 ynorm <- preprocessCore::normalize.quantiles(y)
 rownames(ynorm) <- rownames(y)
 colnames(ynorm) <- colnames(y)
 return(ynorm)
}
 res <- lfqTrans$intensity_matrix( .func = quant)
 res$lfq$get_Plotter()$intensity_distribution_density()
}


wolski/prolfqua documentation built on Dec. 4, 2024, 11:18 p.m.