Skip to contents

LFQDataPlotter —- Create various visualization of the LFQdata

LFQDataPlotter —- Create various visualization of the LFQdata

Value

An R6 class generator.

Public fields

lfq

LFQData object

prefix

prefix to figure names when writing, e.g. protein_

Methods


Method new()

create LFQDataPlotter

Usage

LFQDataPlotter$new(lfqdata, prefix = "ms_")

Arguments

lfqdata

LFQData

prefix

will be prepended to outputs written


Method raster()

plot intensities in raster

Usage

LFQDataPlotter$raster(
  arrange = c("mean", "var"),
  not_na = FALSE,
  rownames = FALSE,
  max_rownames_chars = 60,
  max_sample_label_chars = 20
)

Arguments

arrange

arrange by either mean or var

not_na

TRUE arrange by number of NA's, FALSE by arrange by intensity

rownames

show rownames (default FALSE - do not show.)

max_rownames_chars

maximum displayed row label length

max_sample_label_chars

maximum displayed sample label length. Labels keep their suffix because sample prefixes are often shared.

Returns

ComplexHeatmap::Heatmap


Method heatmap()

heatmap of intensities - columns are samples, rows are proteins or peptides.

The abundances of each protein (row) are z-scored. Afterward, the mean abundance for each protein is zero, and the standard variation is one. z-scoring allows to compare (cluster) the proteins according to the difference in the expression in the samples. Without the z-scoring, the proteins would group according to their abundance, e.g., high abundant proteins would be one cluster.

Only the top_n most variable features are shown. Row clustering uses stats::hclust, which errors above 65536 features, so the rows are ranked by their variability statistic (CV for untransformed data, sd for transformed data; see LFQDataStats) and the most variable are kept. This keeps the heatmap feasible and legible for peptide-list / entrapment searches with tens of thousands of features.

Usage

LFQDataPlotter$heatmap(
  na_fraction = 1,
  rownames = FALSE,
  max_rownames_chars = 60,
  max_sample_label_chars = 20,
  top_n = 1000
)

Arguments

na_fraction

maximum fraction of missing values per row. The default keeps every row that can be meaningfully z-scored.

rownames

show rownames (default FALSE - do not show.)

max_rownames_chars

maximum displayed row label length

max_sample_label_chars

maximum displayed sample label length. Labels keep their suffix because sample prefixes are often shared.

top_n

keep the top_n most variable features (default 1000); NULL or Inf keeps all features.

Returns

ComplexHeatmap::Heatmap


Method heatmap_cor()

heatmap of sample correlations.

The Spearman correlation among all samples is computed. Then the euclidean distance is used to compute the distances.

Usage

LFQDataPlotter$heatmap_cor(max_sample_label_chars = 20)

Arguments

max_sample_label_chars

maximum displayed sample label length. Labels keep their suffix because sample prefixes are often shared.

Returns

ComplexHeatmap::Heatmap


Method pca()

PCA plot

A PCA is applied and the first and second principal component are shown. Features with missing values are removed. To keep all features, impute first, e.g. with AggregateLimpa in impute_only mode.

Usage

LFQDataPlotter$pca(PC = c(1, 2), add_txt = TRUE, nudge = 0.1)

Arguments

PC

default c(1,2) - first and second principal component

add_txt

show sample names

nudge

default 0.1 nudge point labels

Returns

ggplot


Method pca_plotly()

pca plot

Usage

LFQDataPlotter$pca_plotly(PC = c(1, 2), add_txt = FALSE)

Arguments

PC

default c(1,2) - first and second principal component

add_txt

show sample names

Returns

plotly


Method boxplots()

boxplots for all proteins

Usage

LFQDataPlotter$boxplots(facet = TRUE)

Arguments

facet

enable facet wrap if hierarchy_depth less then hierarchy lenght.

Returns

tibble with column boxplots containing ggplot objects


Method missigness_histogram()

histogram of intensities given number of missing in conditions

Usage

LFQDataPlotter$missigness_histogram()

Returns

ggplot


Method na_heatmap()

heatmap of features with missing values

Usage

LFQDataPlotter$na_heatmap()

Returns

ComplexHeatmap::Heatmap


Method intensity_distribution_density()

density distribution of intensities

Usage

LFQDataPlotter$intensity_distribution_density(
  legend = NA,
  max_legend_samples = 16
)

Arguments

legend

show legend TRUE, FALSE do not show, NA selects automatically based on sample count.

max_legend_samples

maximum number of samples for automatic legend display.

Returns

ggplot


Method intensity_distribution_violin()

Violinplot showing distribution of intensities in all samples

Usage

LFQDataPlotter$intensity_distribution_violin()

Returns

ggplot


Method pairs_smooth()

pairsplot of intensities

Usage

LFQDataPlotter$pairs_smooth(max = 10)

Arguments

max

maximal number of samples to show

Returns

NULL


Method sample_correlation()

plot of sample correlations

Usage

LFQDataPlotter$sample_correlation()

Returns

NULL


Method upset_missing()

upset plot based on presence absence information

Usage

LFQDataPlotter$upset_missing()

Returns

plot


Method write_boxplots()

write boxplots to file

Usage

LFQDataPlotter$write_boxplots(path_qc, filename = NULL, width = 6, height = 6)

Arguments

path_qc

path to write to

filename

file to write into

width

fig width

height

fig height


Method write_pdf()

write figure to pdf

Usage

LFQDataPlotter$write_pdf(fig, path_qc, fig_name, width = 7, height = 7)

Arguments

fig

ggplot or ComplexHeatmap::Heatmap

path_qc

path to write to

fig_name

name of figure (no extension)

width

figure width

height

figure height

Returns

path the file was written to


Method clone()

The objects of this class are cloneable with this method.

Usage

LFQDataPlotter$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


istar <- sim_lfq_data_peptide_config()
#> creating sampleName from file_name column
#> completing cases
#> completing cases done
#> setup done

lfqdata <- LFQData$new(
 istar$data,
 istar$config)
lfqplotter <- lfqdata$get_Plotter()

stopifnot(methods::is(lfqplotter$heatmap(), "Heatmap"))
stopifnot(methods::is(lfqplotter$heatmap_cor(), "Heatmap"))
stopifnot("ggplot" %in% class(lfqplotter$pca()))
#> PCA: removed 16 of 28 features with missing values. To keep all features, impute missing values first, e.g. AggregateLimpa$new(lfqdata, impute_only = TRUE)$aggregate().
stopifnot("plotly" %in%  class(lfqplotter$pca_plotly()))
#> PCA: removed 16 of 28 features with missing values. To keep all features, impute missing values first, e.g. AggregateLimpa$new(lfqdata, impute_only = TRUE)$aggregate().
tmp <- lfqplotter$boxplots()
stopifnot("ggplot" %in%  class(tmp$boxplot[[1]]))
stopifnot("ggplot" %in% class(lfqplotter$missigness_histogram()))
#> isotopeLabel ~ group_

stopifnot(methods::is(lfqplotter$na_heatmap(), "Heatmap"))
#> rows with NA's: 16; all rows :28
class(lfqplotter$intensity_distribution_density())
#> [1] "ggplot2::ggplot" "ggplot"          "ggplot2::gg"     "S7_object"      
#> [5] "gg"             
class(lfqplotter$intensity_distribution_violin())
#> [1] "ggplot2::ggplot" "ggplot"          "ggplot2::gg"     "S7_object"      
#> [5] "gg"             
stopifnot(is.null(lfqplotter$pairs_smooth()))

stopifnot(class(lfqplotter$sample_correlation()) == "list")

stopifnot(methods::is(lfqplotter$raster(), "Heatmap"))
stopifnot("upset" == class(lfqplotter$upset_missing()))
#> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`.
#> ℹ See also `vignette("ggplot2-in-packages")` for more information.
#> ℹ The deprecated feature was likely used in the UpSetR package.
#>   Please report the issue at <https://github.com/hms-dbmi/UpSetR/issues>.
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
#> ℹ The deprecated feature was likely used in the UpSetR package.
#>   Please report the issue at <https://github.com/hms-dbmi/UpSetR/issues>.
#> Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
#> ℹ Please use the `linewidth` argument instead.
#> ℹ The deprecated feature was likely used in the UpSetR package.
#>   Please report the issue at <https://github.com/hms-dbmi/UpSetR/issues>.
wide <- lfqdata$data_wide(as.matrix = TRUE)
stopifnot(class(prolfqua::plot_sample_correlation(wide$data)) == "list")