plot_pepNMFCon: NMF plots

plot_pepNMFConR Documentation

NMF plots

Description

plot_pepNMFCon plots the consensus heat maps from the NMF classification of peptide log2FC.

plot_prnNMFCon plots the consensus heat maps from the NMF classification of protein log2FC.

plot_pepNMFCoef plots the coefficient heat maps from the NMF classification of peptide log2FC.

plot_prnNMFCoef plots the coefficient heat maps from the NMF classification of protein log2FC.

Usage

plot_pepNMFCon(
  col_select = NULL,
  scale_log2r = TRUE,
  complete_cases = FALSE,
  impute_na = TRUE,
  df2 = NULL,
  filename = NULL,
  annot_cols = NULL,
  annot_colnames = NULL,
  rank = NULL,
  ...
)

plot_prnNMFCon(
  col_select = NULL,
  scale_log2r = TRUE,
  complete_cases = FALSE,
  impute_na = TRUE,
  df2 = NULL,
  filename = NULL,
  annot_cols = NULL,
  annot_colnames = NULL,
  rank = NULL,
  ...
)

plot_pepNMFCoef(
  col_select = NULL,
  scale_log2r = TRUE,
  complete_cases = FALSE,
  impute_na = TRUE,
  df2 = NULL,
  filename = NULL,
  annot_cols = NULL,
  annot_colnames = NULL,
  rank = NULL,
  ...
)

plot_prnNMFCoef(
  col_select = NULL,
  scale_log2r = TRUE,
  complete_cases = FALSE,
  impute_na = TRUE,
  df2 = NULL,
  filename = NULL,
  annot_cols = NULL,
  annot_colnames = NULL,
  rank = 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.

scale_log2r

Logical; if TRUE, adjusts log2FC to the same scale of standard deviation across all samples. The default is TRUE. At scale_log2r = NA, the raw log2FC without normalization will be used.

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, the name(s) will be determined automatically. For text files, a typical file extension is .txt. For image files, they are typically saved via ggsave or pheatmap where the image type will be determined by the extension of the file name.

annot_cols

A character vector of column keys in expt_smry.xlsx. The values under the selected keys will be used to color-code sample IDs on the top of the indicated plot. The default is NULL without column annotation.

annot_colnames

A character vector of replacement name(s) to annot_cols. The default is NULL without name replacement.

rank

Numeric vector; the factorization rank(s) in nmf. At the NULL default, all available ranks from the results of anal_pepNMF or anal_pepNMF will be used.

...

filter2_: Variable argument statements for the row filtration against data in secondary file(s) of _NMF[...]_consensus.txt for consensus plots or _NMF[...]_coef.txt for coefficient plots. See also prnGSPAHM for the format of filter2_ statements.

arrange2_: Variable argument statements for the row ordering against data in secondary file(s) of _NMF[...]_consensus.txt for consensus plots or _NMF[...]_coef.txt for coefficient plots. See also prnGSPAHM for the format of arrange2_ statements.

Additional arguments for pheatmap

Details

The option of complete_cases will be forced to TRUE at impute_na = FALSE.

Value

Consensus heat maps from NMF classification.

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


# ===================================
# NMF
# ===================================

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

## global option
scale_log2r <- TRUE

library(NMF)

# ===================================
# Analysis
# ===================================
## base (proteins)
library(NMF)

anal_prnNMF(
  impute_na = FALSE,
  col_group = Group,
  rank = c(3:4),
  nrun = 20, 
)

# passing a different `method`
anal_prnNMF(
  impute_na = FALSE,
  col_group = Group,
  method = "lee",
  rank = c(3:4),
  nrun = 20, 
  filename = lee.txt,
)

## row filtration and selected samples (proteins)
anal_prnNMF(
  impute_na = FALSE,
  col_select = BI,
  col_group = Group,
  rank = c(3:4),
  nrun = 20, 
  filter_prots = exprs(prot_n_pep >= 3),
  filename = bi_npep3.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_prnNMF(
  impute_na = FALSE,
  col_group = Group,
  rank = c(3:4),
  nrun = 20, 
  filter_prots_by_npep = exprs(prot_n_pep >= 3), 
  filter_prots_by_pval = exprs(`W16_vs_W2.pVal (W16-W2)` <= 1e-6), 
  filename = pval.txt,
)

## 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_prnNMF(
  impute_na = TRUE,
  col_group = Group,
  rank = c(3:4),
  nrun = 20, 
  filter_prots_by_npep = exprs(prot_n_pep >= 3), 
  filter_prots_by_pval = exprs(`W16_vs_W2.pVal (W16-W2)` <= 1e-6), 
  filename = pval2.txt,
)

## analogous peptides
anal_pepNMF(
  impute_na = TRUE,
  col_group = Group,
  rank = c(3:4),
  nrun = 20, 
  filter_prots_by_npep = exprs(prot_n_pep >= 3), 
  filter_prots_by_pval = exprs(`W16_vs_W2.pVal (W16-W2)` <= 1e-6), 
)

anal_pepNMF(
  impute_na = FALSE,
  col_group = Group,
  rank = c(3:4),
  nrun = 20, 
  filter_prots_by_npep = exprs(prot_n_pep >= 3), 
  filter_prots_by_pval = exprs(`W16_vs_W2.pVal (W16-W2)` <= 1e-6), 
)


# ===================================
# consensus heat maps
# ===================================
## no NA imputation 
# proteins, all available ranks
library(NMF)

plot_prnNMFCon(
  impute_na = FALSE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 14,
  height = 14,
)

# analogous peptides
plot_pepNMFCon(
  impute_na = FALSE,
  col_select = BI,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  color = colorRampPalette(RColorBrewer::brewer.pal(n = 7, name = "Spectral"))(50), 
  width = 10,
  height = 10,
  filename = bi.pdf,
)

# manual selection of input data file(s)
# may be used for optimizing individual plots
plot_prnNMFCon(
  df2 = c("Protein_NMF_Z_rank3_consensus.txt", "Protein_NMF_Z_rank4_consensus.txt"),
  impute_na = FALSE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 14,
  height = 14,
)

## NA imputation 
# proteins, all available ranks
plot_prnNMFCon(
  impute_na = TRUE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 14,
  height = 14,
)

# analogous peptides
plot_pepNMFCon(
  impute_na = TRUE,
  col_select = BI,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 10,
  height = 10,
  filename = bi_con.png,
)


# ===================================
# coefficient heat maps
# ===================================
## no NA imputation 
# proteins, all available ranks
plot_prnNMFCoef(
  impute_na = FALSE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 12,
  height = 12,
)

# manual selection of input data file(s)
# may be used for optimizing individual plots
plot_prnNMFCoef(
  df2 = c("Protein_NMF_Z_rank3_coef.txt"),  
  impute_na = FALSE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 12,
  height = 12,
)

# analogous peptides
plot_pepNMFCoef(
  impute_na = FALSE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  color = colorRampPalette(brewer.pal(n = 7, name = "Spectral"))(50), 
  width = 12,
  height = 12,
)

## NA imputation 
# proteins, all available ranks
plot_prnNMFCoef(
  impute_na = TRUE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 10,
  height = 10,
)

# analogous peptides
plot_pepNMFCoef(
  impute_na = TRUE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  width = 10,
  height = 10,
)


# ===================================
# Metagene heat maps
# ===================================
## no NA imputation 
# proteins, all available ranks
plot_metaNMF(
  impute_na = FALSE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  
  # additional arguments for `pheatmap`
  fontsize = 8,
  fontsize_col = 5,
)

# proteins, selected sample(s)
plot_metaNMF(
  impute_na = FALSE,
  col_select = BI_1,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  fontsize = 8,
  fontsize_col = 5,
  cellwidth = 6, 
  filename = bi1.png,
)

# proteins, selected sample(s) and row ordering
plot_metaNMF(
  impute_na = FALSE,
  col_select = BI_1,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  fontsize = 8,
  fontsize_col = 5,
  cellwidth = 6, 
  cluster_rows = FALSE,
  arrange_prots_by = exprs(gene),
  filename = bi1_row_by_genes.png,
)

# manual selection of input .rda file(s)
# may be used for optimizing individual plots
plot_metaNMF(
  df2 = c("Protein_NMF_Z_rank3.rda"),  
  impute_na = FALSE,
  col_select = BI_1,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  fontsize = 8,
  fontsize_col = 5,
  cellwidth = 6, 
  cluster_rows = FALSE,
  arrange_prots_by = exprs(gene),
  filename = bi1_row_by_genes.png,
)

## NA imputation 
# proteins, all available ranks
plot_metaNMF(
  impute_na = TRUE,
  annot_cols = c("Color", "Alpha", "Shape"),
  annot_colnames = c("Lab", "Batch", "WHIM"),
  fontsize = 8,
  fontsize_col = 5,
)


qzhang503/proteoQ documentation built on Dec. 14, 2024, 12:27 p.m.