LFQData: LFQData R6 class

LFQDataR Documentation

LFQData R6 class

Description

LFQData R6 class

LFQData R6 class

Public fields

config

AnalysisConfiguration

data

data.frame or tibble matching AnalysisConfiguration.

is_pep

todo

prefix

e.g. "peptide_", "protein_", "compound_"

Methods

Public methods


Method new()

initialize

Usage
LFQData$new(data, config, is_pep = TRUE, prefix = "ms_", setup = FALSE)
Arguments
data

data.frame

config

configuration

is_pep

todo

prefix

will be use as output prefix

setup

is data setup needed, default = FALSE, if TRUE, calls setup_analysis on data first.


Method get_copy()

get deep copy

Usage
LFQData$get_copy()

Method get_sample()

samples subset of data

Usage
LFQData$get_sample(size = 100, seed = NULL)
Arguments
size

size of subset default 100

seed

set seed


Method get_subset()

get subset of data

Usage
LFQData$get_subset(x)
Arguments
x

data frame with columns containing subject_Id


Method subject_Id()

get subject ID columns

Usage
LFQData$subject_Id()

Method is_transformed()

is data transformed

Usage
LFQData$is_transformed(is_transformed)
Arguments
is_transformed

logical

Returns

logical


Method remove_small_intensities()

some software is reporting NA's as 0, you must remove it from your data

Usage
LFQData$remove_small_intensities(threshold = 4)
Arguments
threshold

default 4.

Returns

self


Method filter_proteins_by_peptide_count()

remove proteins with less than X peptides

Usage
LFQData$filter_proteins_by_peptide_count()
Returns

self


Method omit_NA()

Omit NA from intensities per hierarchy (e.g. protein or peptide), idea is to use it for normalization For instance if a peptide has a missing value in more then nrNA of the samples within a condition it will be removed

Usage
LFQData$omit_NA(nrNA = 0, factorDepth = NULL)
Arguments
nrNA

number of NA values

factorDepth

you control for nrNA per condition or experiment etc. e.g. factorDepth = 0 then per experiment

Returns

LFQData with NA omitted.


Method complete_cases()

some software is reporting NA's as 0, you must remove it from your data

Usage
LFQData$complete_cases()
Arguments
threshold

default 4.

Returns

self


Method to_wide()

converts the data to wide

Usage
LFQData$to_wide(as.matrix = FALSE, value = c("response", "nr_children"))
Arguments
as.matrix

return as data.frame or matrix

value

either response or nr chidren

Returns

list with data, annotation, and configuration


Method factors()

Annotation table

Usage
LFQData$factors()
Returns

data.frame


Method hierarchy()

Hierarchy table

Usage
LFQData$hierarchy()

Method response()

name of response variable

Usage
LFQData$response()
Returns

data.frame


Method rename_response()

new name of response variable

Usage
LFQData$rename_response(newname = "Intensity")
Arguments
newname

default Intensity


Method hierarchy_counts()

number of elements at each level

Usage
LFQData$hierarchy_counts()

Method summarize_hierarchy()

e.g. number of peptides per protein etc

Usage
LFQData$summarize_hierarchy()
Returns

data.frame


Method get_Plotter()

get Plotter

Usage
LFQData$get_Plotter()
Returns

LFQDataPlotter


Method get_Writer()

get Writer

Usage
LFQData$get_Writer(format = "xlsx")
Arguments
format

array of formats to write to supported are xlsx, csv and html

Returns

LFQDataPlotter


Method get_Summariser()

get Summariser

Usage
LFQData$get_Summariser()
Returns

LFQDataSummarizer


Method get_Stats()

Get LFQDataStats. For more details see LFQDataStats.

Usage
LFQData$get_Stats(stats = c("everything", "interaction", "all"))
Arguments
stats

default interaction, computes statistics within interaction.

Returns

LFQDataStats


Method get_Transformer()

get Stats

Usage
LFQData$get_Transformer()
Returns

LFQDataTransformer


Method get_Aggregator()

get Aggregator

Usage
LFQData$get_Aggregator()
Returns

LFQDataAggregator


Method filter_difference()

get difference of self with other if other is subset of self

Usage
LFQData$filter_difference(other)
Arguments
other

a filtered LFQData set

Details

Use to compare filtering results obtained from self, e.g. which proteins and peptides were removed (other)

Returns

LFQData


Method clone()

The objects of this class are cloneable with this method.

Usage
LFQData$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Other LFQData: LFQDataAggregator, LFQDataPlotter, LFQDataStats, LFQDataSummariser, LFQDataToSummarizedExperiment(), LFQDataWriter

Examples


istar <- sim_lfq_data_peptide_config()
#LFQData$debug("omit_NA")
lfqdata <- LFQData$new(istar$data, istar$config)
lfqdata$filter_proteins_by_peptide_count()
tmp <- lfqdata$to_wide()
testthat::expect_equal(nrow(tmp$data) , nrow(tmp$rowdata))
testthat::expect_equal(ncol(tmp$data) , nrow(tmp$annotation) + ncol(tmp$rowdata))

stopifnot("data.frame" %in% class(tmp$data))
tmp <- lfqdata$to_wide(as.matrix = TRUE)
stopifnot("matrix" %in% class(tmp$data))
stopifnot(lfqdata$is_transformed()==FALSE)
lfqdata$summarize_hierarchy()

# filter for missing values

f1 <- lfqdata$omit_NA(nrNA = 0)
stopifnot(f1$hierarchy_counts() <= lfqdata$hierarchy_counts())

f2 <- lfqdata$omit_NA(factorDepth = 0)
stopifnot(f2$hierarchy_counts() <= lfqdata$hierarchy_counts())

lfqdata$response()
lfqdata$rename_response("peptide.intensity")
lfqdata$response()
stopifnot("LFQData" %in% class(lfqdata$get_copy()))
stopifnot("LFQDataTransformer" %in% class(lfqdata$get_Transformer()))
stopifnot("LFQDataStats" %in% class(lfqdata$get_Stats()))
stopifnot("LFQDataSummariser" %in% class(lfqdata$get_Summariser()))
stopifnot("LFQDataPlotter" %in% class(lfqdata$get_Plotter()))
stopifnot("LFQDataWriter" %in% class(lfqdata$get_Writer()))
stopifnot("LFQDataAggregator" %in% class(lfqdata$get_Aggregator()))

lfqdata2 <- lfqdata$get_copy()
lfqdata2$data <- lfqdata2$data[1:100,]
res <- lfqdata$filter_difference(lfqdata2)
stopifnot(nrow(res$data) == nrow(lfqdata$data) - 100)

tmp <- lfqdata$get_sample(5, seed = 4)
stopifnot(nrow(tmp$hierarchy()) == 5)

lw <- lfqdata$get_Writer()
stopifnot(names(lw$get_wide()) %in% c("data", "annotation"))

stopifnot("data.frame" %in% class(lw$get_long()))


wolski/prolfqua documentation built on Oct. 31, 2024, 9:22 a.m.