plot_prnTrend: Visualization of trend results

plot_prnTrendR Documentation

Visualization of trend results

Description

plot_prnTrend plots the trends of protein expressions from anal_prnTrend.

Usage

plot_prnTrend(
  col_select = NULL,
  col_order = NULL,
  n_clust = NULL,
  scale_log2r = TRUE,
  complete_cases = FALSE,
  impute_na = FALSE,
  df2 = NULL,
  filename = NULL,
  theme = NULL,
  ...
)

Arguments

col_select

Character string to a column key in expt_smry.xlsx. At the NULL default, the column key of Select in expt_smry.xlsx will be used. In the case of no samples being specified under Select, the column key of Sample_ID will be used. The non-empty entries under the ascribing column will be used in indicated analysis.

col_order

Character string to a column key in expt_smry.xlsx. Numeric values under which will be used for the left-to-right arrangement of samples in graphic outputs or top-to-bottom arrangement in text outputs. At the NULL default, the column key Order will be used. If values under column Order are left blank, samples will be ordered by their names.

n_clust

Numeric vector; the cluster ID(s) corresponding to anal_prnTrend for visualization. At the NULL default, all available cluster IDs will be used.

scale_log2r

Logical; at the TRUE default, input files with _Z[...].txt in name will be used. Otherwise, files with _N[...].txt in name will be taken. An error will be thrown if no files are matched under given conditions.

complete_cases

Logical; if TRUE, only cases that are complete with no missing values will be used. The default is FALSE.

impute_na

Logical; at the TRUE default, input files with _impNA[...].txt in name will be loaded. Otherwise, files without _impNA in name will be taken. An error will be thrown if no files are matched under given conditions.

df2

Character vector or string; the name(s) of secondary data file(s). An informatic task, i.e. anal_prnTrend(...) against a primary df generates secondary files such as Protein_Trend_Z_nclust6.txt etc. See also prnHist for the description of a primary df; normPSM for the lists of df and df2.

filename

A representative file name to outputs. By default, it will be determined automatically by the name of the current call.

theme

A ggplot2 theme, i.e., theme_bw(), or a custom theme. At the NULL default, a system theme will be applied.

...

filter2_: Variable argument statements for the row filtration against data in secondary file(s) of [...]Protein_Trend_[...].txt. See also prnGSPAHM for the format of filter2_ statements.

arrange2_: Variable argument statements for the row ordering against data in secondary file(s) of [...]Protein_Trend_[...].txt. See also prnGSPAHM for the format of arrange2_ statements.

Additional parameters for use in plot_ functions:
ymin, the minimum y at log2 scale;
ymax, the maximum y at log2 scale;
ybreaks, the breaks in y-axis at log2 scale;
nrow, the number of rows;
width, the width of plot;
height, the height of plot;
color, the color of lines;
alpha, the transparency of lines.

Details

The function reads Protein_Trend_[...].txt files under the .../Protein/Trend directory.

Protein_Trend_[...].txt

Key Descrption
id a gene name or an acession number for protein data
cluster a cluster ID assigned to an id
group a name of the sample group for a id
log2FC the mean log2FC of an id under a group at a given cluster

See Also

Metadata
load_expts for metadata preparation and a reduced working example in data normalization

Data normalization
normPSM for extended examples in PSM data normalization
PSM2Pep for extended examples in PSM to peptide summarization
mergePep for extended examples in peptide data merging
standPep for extended examples in peptide data normalization
Pep2Prn for extended examples in peptide to protein summarization
standPrn for extended examples in protein data normalization.
purgePSM and purgePep for extended examples in data purging
pepHist and prnHist for extended examples in histogram visualization.
extract_raws and extract_psm_raws for extracting MS file names

Variable arguments of 'filter_...'
contain_str, contain_chars_in, not_contain_str, not_contain_chars_in, start_with_str, end_with_str, start_with_chars_in and ends_with_chars_in for data subsetting by character strings

Missing values
pepImp and prnImp for missing value imputation

Informatics
pepSig and prnSig for significance tests
pepVol and prnVol for volcano plot visualization
prnGSPA for gene set enrichment analysis by protein significance pVals
gspaMap for mapping GSPA to volcano plot visualization
prnGSPAHM for heat map and network visualization of GSPA results
prnGSVA for gene set variance analysis
prnGSEA for data preparation for online GSEA.
pepMDS and prnMDS for MDS visualization
pepPCA and prnPCA for PCA visualization
pepLDA and prnLDA for LDA visualization
pepHM and prnHM for heat map visualization
pepCorr_logFC, prnCorr_logFC, pepCorr_logInt and prnCorr_logInt for correlation plots
anal_prnTrend and plot_prnTrend for trend analysis and visualization
anal_pepNMF, anal_prnNMF, plot_pepNMFCon, plot_prnNMFCon, plot_pepNMFCoef, plot_prnNMFCoef and plot_metaNMF for NMF analysis and visualization

Custom databases
Uni2Entrez for lookups between UniProt accessions and Entrez IDs
Ref2Entrez for lookups among RefSeq accessions, gene names and Entrez IDs
prepGO for gene ontology
prepMSig for molecular signatures
prepString and anal_prnString for STRING-DB

Column keys in PSM, peptide and protein outputs
system.file("extdata", "psm_keys.txt", package = "proteoQ")
system.file("extdata", "peptide_keys.txt", package = "proteoQ")
system.file("extdata", "protein_keys.txt", package = "proteoQ")

Examples


# ===================================
# Trend analysis
# ===================================

## !!!require the brief working example in `?load_expts`

## global option
scale_log2r <- TRUE


# ===================================
# Analysis
# ===================================
## base (proteins, with sample order supervision)
anal_prnTrend(
  impute_na = FALSE,
  col_order = Order,
  n_clust = c(5:6), 
)

## against selected samples
anal_prnTrend(
  col_select = BI,
  impute_na = FALSE,
  col_order = Order,
  n_clust = c(5:6), 
  filename = sel.txt,
)

## row filtration (proteins)
anal_prnTrend(
  impute_na = FALSE,
  col_order = Order,
  n_clust = c(5:6), 
  filter_prots_by = exprs(prot_n_pep >= 2),
)

## manual m degree of fuzziness (proteins)
anal_prnTrend(
  impute_na = FALSE,
  col_order = Order,
  n_clust = c(5:6), 
  filter_prots = exprs(prot_n_pep >= 2),
  m = 1.5,
  filename = my_m.txt,
)

## additional row filtration by pVals (proteins, impute_na = FALSE)
# if not yet, run prerequisitive significance tests at `impute_na = FALSE`
pepSig(
  impute_na = FALSE, 
  W2_bat = ~ Term["(W2.BI.TMT2-W2.BI.TMT1)", 
                  "(W2.JHU.TMT2-W2.JHU.TMT1)", 
                  "(W2.PNNL.TMT2-W2.PNNL.TMT1)"],
  W2_loc = ~ Term_2["W2.BI-W2.JHU", 
                    "W2.BI-W2.PNNL", 
                    "W2.JHU-W2.PNNL"],
  W16_vs_W2 = ~ Term_3["W16-W2"], 
)

prnSig(impute_na = FALSE)

# (`W16_vs_W2.pVal (W16-W2)` now a column key)
anal_prnTrend(
  impute_na = FALSE,
  col_order = Order,
  n_clust = c(5:6), 
  filter_prots_by_npep = exprs(prot_n_pep >= 3), 
  filter_prots_by_pval = exprs(`W16_vs_W2.pVal (W16-W2)` <= 1e-6), 
)

## additional row filtration by pVals (impute_na = TRUE)
# if not yet, run prerequisitive NA imputation and corresponding 
# significance tests at `impute_na = TRUE`
pepImp(m = 2, maxit = 2)
prnImp(m = 5, maxit = 5)

pepSig(
  impute_na = TRUE, 
  W2_bat = ~ Term["(W2.BI.TMT2-W2.BI.TMT1)", 
                  "(W2.JHU.TMT2-W2.JHU.TMT1)", 
                  "(W2.PNNL.TMT2-W2.PNNL.TMT1)"],
  W2_loc = ~ Term_2["W2.BI-W2.JHU", 
                    "W2.BI-W2.PNNL", 
                    "W2.JHU-W2.PNNL"],
  W16_vs_W2 = ~ Term_3["W16-W2"], 
)

prnSig(impute_na = TRUE)

anal_prnTrend(
  impute_na = TRUE,
  col_order = Order,
  n_clust = c(5:6), 
  filter_prots_by_npep = exprs(prot_n_pep >= 3), 
  filter_prots_by_pval = exprs(`W16_vs_W2.pVal (W16-W2)` <= 1e-6), 
)


# ===================================
# Visualization
# ===================================
## base (proteins, no NA imputation) 
plot_prnTrend(
  col_order = Order, 
)

# at specific cluster ID(s)
# (`cluster` is a column key in `Protein_Trend_[...].txt`)
plot_prnTrend(
  impute_na = FALSE, 
  col_order = Order,
  filter2_by_clusters = exprs(cluster == 5),
  width = 8, 
  height = 10,
  filename = cl5.png,
)

# manual selection of secondary input data file(s)
# may be used for optimizing individual plots
plot_prnTrend(
  df2 = c("Protein_Trend_Z_nclust5.txt"),
  col_order = Order, 
  filename = n5.png,
)

# manual secondary input(s) at specific rank(s)
plot_prnTrend(
  df2 = c("Protein_Trend_Z_nclust5.txt"),
  impute_na = FALSE, 
  col_order = Order,
  filter2_by_clusters = exprs(cluster == 5),
  width = 8, 
  height = 10,
  filename = n5_cl5.png,
)

## NA imputation
# also save as pdf
plot_prnTrend(
  impute_na = TRUE,
  col_order = Order,
  filename = my.pdf,
)

## against selected samples
plot_prnTrend(
  col_order = Order, 
  col_select = BI,
  filename = bi.png,
)

## custom theme
library(ggplot2)
my_trend_theme <- theme_bw() + theme(
  axis.text.x  = element_text(angle=60, vjust=0.5, size=24),
  axis.ticks.x  = element_blank(), 
  axis.text.y  = element_text(angle=0, vjust=0.5, size=24),
  axis.title.x = element_text(colour="black", size=24),
  axis.title.y = element_text(colour="black", size=24),
  plot.title = element_text(face="bold", colour="black",
                            size=20, hjust=.5, vjust=.5),
  panel.grid.major.x = element_blank(),
  panel.grid.minor.x = element_blank(),
  panel.grid.major.y = element_blank(),
  panel.grid.minor.y = element_blank(),
  panel.background = element_rect(fill = '#0868ac', colour = 'red'),
  
  strip.text.x = element_text(size = 24, colour = "black", angle = 0),
  strip.text.y = element_text(size = 24, colour = "black", angle = 90),
  
  plot.margin = unit(c(5.5, 55, 5.5, 5.5), "points"), 
  
  legend.key = element_rect(colour = NA, fill = 'transparent'),
  legend.background = element_rect(colour = NA,  fill = "transparent"),
  legend.position = "none",
  legend.title = element_text(colour="black", size=18),
  legend.text = element_text(colour="black", size=18),
  legend.text.align = 0,
  legend.box = NULL
)

plot_prnTrend(
  col_order = Order, 
  col_select = BI,
  theme = my_trend_theme,
  filename = my_theme.png,
)

## no grouping 
# each sample under column `Select` forms its own group
anal_prnTrend(
  col_group = Select,
  col_order = Order,
  n_clust = 6, 
  filter_prots = exprs(prot_n_pep >= 2),
  filename = sample_ids_as_groups.txt,
)

plot_prnTrend(
  df2 = "sample_ids_as_groups_Protein_Trend_Z_nclust6.txt",
  filter2_by_clusters = exprs(cluster == 4),
  width = 24,
  height = 16,
)

## grouped by column `Term_2` in metadata
anal_prnTrend(
  col_group = Term_2,
  col_order = Order,
  n_clust = 6, 
  filter_prots = exprs(prot_n_pep >= 2),
  filename = term_2_grouping.txt,
)

plot_prnTrend(
  df2 = "term_2_grouping_Protein_Trend_Z_nclust6.txt",
  filter2_by_clusters = exprs(cluster == 3),
  width = 6,
  height = 6,
)

## Cytoscape visualization
# (Make sure that Cytoscape is open.)
# Human
cluego(
  df2 = "Protein_Trend_Z_nclust5.txt", 
  species = c(human = "Homo Sapiens"), 
  n_clust = c(3, 5)
)

# Mouse
cluego(
  df2 = "Protein_Trend_Z_nclust5.txt", 
  species = c(mouse = "Mus Musculus"), 
  n_clust = c(3:4)
)



qzhang503/proteoQ documentation built on March 16, 2024, 5:27 a.m.