LFQDataTransformer | R Documentation |
Decorate LFQData with Methods for transforming Intensities
Decorate LFQData with Methods for transforming Intensities
lfq
LFQData object
new()
initialize
LFQDataTransformer$new(lfqdata)
lfqdata
LFQData object to transform
log2()
log2 transform data
LFQDataTransformer$log2(force = FALSE)
force
if FALSE, then data already log2 transformed will not be transformed a second time. TRUE force log transformation.
LFQDataTransformer
get_scales()
get mean and variance and standard deviation in each sample
LFQDataTransformer$get_scales()
list with means and mads
robscale()
robust scale data
LFQDataTransformer$robscale( preserveMean = TRUE, colname = "transformedIntensity" )
preserveMean
should original mean value be preserved TRUE, if FALSE then center at zero
colname
new name of transformed column
LFQDataTransformer (self)
robscale_subset()
log2 transform and robust scale data based on subset
LFQDataTransformer$robscale_subset( lfqsubset, preserveMean = TRUE, colname = "transformedIntensity" )
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
LFQDataTransformer (self)
intensity_array()
Transforms intensities
LFQDataTransformer$intensity_array(.func = log2, force = FALSE)
.func
transformation function working with arrays e.g. log2, log10, asinh etc.
force
transformation on already transformed data.
LFQDataTransformer (self)
intensity_matrix()
pass a function which works with matrices, e.g., vsn::justvsn
LFQDataTransformer$intensity_matrix(.func = robust_scale, force = FALSE)
.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
LFQDataTransformer (self)
clone()
The objects of this class are cloneable with this method.
LFQDataTransformer$clone(deep = FALSE)
deep
Whether to make a deep clone.
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()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.