Plots of an LFQData object: intensity distributions, boxplots per protein, heatmaps of intensities, correlations
and missing values, PCA, pairs plots and UpSet plots of missingness. Obtained with LFQData$get_Plotter(); the
write_* methods write per-protein plots to PDF files.
Create various visualization of the LFQData
Methods
LFQDataPlotter$new()
create LFQDataPlotter
Usage
LFQDataPlotter$new(lfqdata, prefix = "ms_")Arguments
lfqdataLFQData object with the data and its configuration
prefixwill be prepended to outputs written
LFQDataPlotter$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
arrangearrange by either mean or var
not_naTRUE arrange by number of NA's, FALSE by arrange by intensity
rownamesshow rownames (default FALSE - do not show.)
max_rownames_charsmaximum displayed row label length
max_sample_label_charsmaximum displayed sample label length. Labels keep their suffix because sample prefixes are often shared.
LFQDataPlotter$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.
By default only the n_most_variable most variable features are shown and the rows are clustered.
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.
With row_order, the heatmap shows exactly these features in this order, without clustering. Use it
to compare two states of the same data row by row, e.g. before and after imputation: imputation changes the
per-feature sd, so the most variable set and the clustering would differ between the two heatmaps.
Usage
LFQDataPlotter$heatmap(
na_fraction = 1,
rownames = FALSE,
max_rownames_chars = 60,
max_sample_label_chars = 20,
n_most_variable = 1000,
row_order = NULL,
top_n
)Arguments
na_fractionmaximum fraction of missing values per row. The default keeps every row that can be meaningfully z-scored.
rownamesshow rownames (default FALSE - do not show.)
max_rownames_charsmaximum displayed row label length
max_sample_label_charsmaximum displayed sample label length. Labels keep their suffix because sample prefixes are often shared.
n_most_variablekeep the
n_most_variablemost variable features (default 1000);NULLorInfkeeps all features. Not together withrow_order.row_orderfeature IDs (rownames of
LFQData$data_wide()) to show, in this order, without row clustering; defaultNULLselects and clusters the most variable features.top_ndeprecated, use
n_most_variable
LFQDataPlotter$heatmap_cor()
heatmap of sample correlations.
The Spearman correlation among all samples is computed. Then the euclidean distance is used to compute the distances.
Arguments
max_sample_label_charsmaximum displayed sample label length. Labels keep their suffix because sample prefixes are often shared.
methodcorrelation method:
"pearson"(default),"spearman"or"kendall"forstats::cor()on pairwise complete observations, or a function of the matrix returning a sample-by-sample correlation matrix
LFQDataPlotter$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)LFQDataPlotter$missingness_histogram()
histogram of intensities given number of missing in conditions
LFQDataPlotter$intensity_distribution_density()
density distribution of intensities
LFQDataPlotter$intensity_distribution_violin()
Violinplot showing distribution of intensities in all samples
LFQDataPlotter$pairs_smooth()
pairsplot of intensities
LFQDataPlotter$sample_correlation()
plot of sample correlations
Arguments
methodcorrelation method:
"pearson"(default),"spearman"or"kendall"forstats::cor()on pairwise complete observations, or a function of the matrix returning a sample-by-sample correlation matrix
LFQDataPlotter$write_boxplots()
write boxplots to file
LFQDataPlotter$write_pdf()
write figure to pdf
Examples
istar <- sim_lfq_data_peptide_config()
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, mean, N, avg_peptide_abd, Replicate.
#> setup_analysis: added 36 rows with NA response for feature and sample combinations absent from the input.
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$missingness_histogram()))
stopifnot(methods::is(lfqplotter$na_heatmap(), "Heatmap"))
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()))