feature_level_diagnostics: Ploting peptide measurements

feature_level_diagnosticsR Documentation

Ploting peptide measurements

Description

Creates a peptide faceted ggplot2 plot of the value in measure_col vs order_col (if 'NULL', x-axis is simply a sample name order). Additionally, the resulting plot can also be colored either by batch factor, by quality factor (e.g. imputated/non-imputed) and, if needed, faceted by another batch factor, e.g. an instrument. If the non-linear curve was fit, this can also be added to the plot, see functions specific to each case below

Usage

plot_single_feature(feature_name, df_long, sample_annotation = NULL,
  sample_id_col = "FullRunName", measure_col = "Intensity",
  feature_id_col = "peptide_group_label", geom = c("point", "line"),
  qual_col = NULL, qual_value = NULL, batch_col = "MS_batch",
  color_by_batch = FALSE, color_scheme = "brewer",
  order_col = "order", vline_color = "red", facet_col = NULL,
  filename = NULL, width = NA, height = NA, units = c("cm", "in",
  "mm"), plot_title = NULL, theme = "classic", ylimits = NULL,
  base_size = 20)

plot_peptides_of_one_protein(protein_name, peptide_annotation = NULL,
  protein_col = "ProteinName", df_long, sample_annotation = NULL,
  sample_id_col = "FullRunName", measure_col = "Intensity",
  feature_id_col = "peptide_group_label", geom = c("point", "line"),
  qual_col = NULL, qual_value = NULL, batch_col = "MS_batch",
  color_by_batch = FALSE, color_scheme = "brewer",
  order_col = "order", vline_color = "red", facet_col = NULL,
  filename = NULL, width = NA, height = NA, units = c("cm", "in",
  "mm"), plot_title = sprintf("Peptides of %s protein", protein_name),
  theme = "classic", base_size = 20)

plot_spike_in(spike_ins = "BOVIN", peptide_annotation = NULL,
  protein_col = "ProteinName", df_long, sample_annotation = NULL,
  sample_id_col = "FullRunName", measure_col = "Intensity",
  feature_id_col = "peptide_group_label", geom = c("point", "line"),
  qual_col = NULL, qual_value = NULL, batch_col = "MS_batch",
  color_by_batch = FALSE, color_scheme = "brewer",
  order_col = "order", vline_color = "red", facet_col = NULL,
  filename = NULL, width = NA, height = NA, units = c("cm", "in",
  "mm"), plot_title = sprintf("Spike-in %s plots", spike_ins),
  theme = "classic", base_size = 20)

plot_iRT(irt_pattern = "iRT", peptide_annotation = NULL,
  protein_col = "ProteinName", df_long, sample_annotation = NULL,
  sample_id_col = "FullRunName", measure_col = "Intensity",
  feature_id_col = "peptide_group_label", geom = c("point", "line"),
  qual_col = NULL, qual_value = NULL, batch_col = "MS_batch",
  color_by_batch = FALSE, color_scheme = "brewer",
  order_col = "order", vline_color = "red", facet_col = NULL,
  filename = NULL, width = NA, height = NA, units = c("cm", "in",
  "mm"), plot_title = "iRT peptide profile", theme = "classic",
  base_size = 20)

plot_with_fitting_curve(feature_name, fit_df, fit_value_col = "fit",
  df_long, sample_annotation = NULL, sample_id_col = "FullRunName",
  measure_col = "Intensity", feature_id_col = "peptide_group_label",
  geom = c("point", "line"), qual_col = NULL, qual_value = NULL,
  batch_col = "MS_batch", color_by_batch = FALSE,
  color_scheme = "brewer", order_col = "order", vline_color = "grey",
  facet_col = NULL, filename = NULL, width = NA, height = NA,
  units = c("cm", "in", "mm"),
  plot_title = sprintf("Fitting curve of %s \n                                                         peptide",
  paste(feature_name, collapse = " ")), theme = "classic",
  base_size = 20)

Arguments

feature_name

name of the selected feature (e.g. peptide) for diagnostic profiling

df_long

data frame where each row is a single feature in a single sample. It minimally has a sample_id_col, a feature_id_col and a measure_col, but usually also an m_score (in OpenSWATH output result file). See help("example_proteome") for more details.

sample_annotation

data frame with:

  1. sample_id_col (this can be repeated as row names)

  2. biological covariates

  3. technical covariates (batches etc)

. See help("example_sample_annotation")

sample_id_col

name of the column in sample_annotation table, where the filenames (colnames of the data_matrix are found).

measure_col

if df_long is among the parameters, it is the column with expression/abundance/intensity; otherwise, it is used internally for consistency.

feature_id_col

name of the column with feature/gene/peptide/protein ID used in the long format representation df_long. In the wide formatted representation data_matrix this corresponds to the row names.

geom

whether to show the feature as points and/or connect by lines (accepted values are: 1. point, line and c('point', 'line'))

qual_col

column to color point by certain value denoted by qual_value. Design with inferred/requant values in OpenSWATH output data, which means argument value has to be set to m_score.

qual_value

value in qual_col to color. For OpenSWATH data, this argument value has to be set to 2 (this is an m_score value for imputed values (requant values).

batch_col

column in sample_annotation that should be used for batch comparison (or other, non-batch factor to be mapped to color in plots).

color_by_batch

(logical) whether to color points and connecting lines by batch factor as defined by batch_col.

color_scheme

a named vector of colors to map to batch_col, names corresponding to the levels of the factor. For continuous variables, vector doesn't need to be named.

order_col

column in sample_annotation that determines sample order. It is used for in initial assessment plots (plot_sample_mean_or_boxplot) and feature-level diagnostics (feature_level_diagnostics). Can be 'NULL' if sample order is irrelevant (e.g. in genomic experiments). For more details, order definition/inference, see define_sample_order and date_to_sample_order

vline_color

color of vertical lines, typically separating different MS batches in ordered runs; should be 'NULL' for experiments without intrinsic order

facet_col

column in sample_annotation with a batch factor to separate plots into facets; usually 2nd to batch_col. Most meaningful for multi-instrument MS experiments (where each instrument has its own order-associated effects (see order_col) or simultaneous examination of two batch factors (e.g. preparation day and measurement day). For single-instrument case should be set to 'NULL'

filename

path where the results are saved. If null the object is returned to the active window; otherwise, the object is save into the file. Currently only pdf and png format is supported

width

option determining the output image width

height

option determining the output image width

units

units: 'cm', 'in' or 'mm'

plot_title

title of the plot (e.g., processing step + representation level (fragments, transitions, proteins) + purpose (meanplot/corrplot etc))

theme

ggplot theme, by default classic. Can be easily overriden

ylimits

range of y-axis to plot feature-level trends

protein_name

name of the protein as defined in ProteinName

peptide_annotation

long format data frame with peptide ID and their corresponding protein and/or gene annotations. See help("example_peptide_annotation").

protein_col

column where protein names are specified

spike_ins

name of feature(s), typically proteins that were spiked in for control

irt_pattern

substring used to identify iRT proteins in the column 'ProteinName'

fit_df

data frame output of adjust_batch_trend_df to be plotted with the line

fit_value_col

column in fit_df where the values for fitting trend are found

Value

ggplot2 type plot of measure_col vs order_col, faceted by feature_name and (optionally) by batch_col

Examples

single_feature_plot <- plot_single_feature(feature_name = c("46213_NVGVSFYADKPEVTQEQK_2","10081_NVQGIIDILK_2"), 
df_long = example_proteome, example_sample_annotation, 
qual_col = NULL)

#color measurements by factor, related to order (MS_batch)
plot_single_feature(feature_name = c("46213_NVGVSFYADKPEVTQEQK_2","10081_NVQGIIDILK_2"), 
df_long = example_proteome, example_sample_annotation, 
qual_col = NULL, color_by_batch = TRUE, batch_col = 'MS_batch')

#color measurements by factor, with order-unrelated factor
single_feature_plot <- plot_single_feature(feature_name = c("46213_NVGVSFYADKPEVTQEQK_2","10081_NVQGIIDILK_2"), 
df_long = example_proteome, example_sample_annotation, 
qual_col = NULL, color_by_batch = TRUE, batch_col = 'Diet', geom = 'point', 
vline_color = NULL)

#saving the plot
## Not run: 
single_feature_plot <- plot_single_feature(feature_name = c("46213_NVGVSFYADKPEVTQEQK_2","10081_NVQGIIDILK_2"), 
df_long = example_proteome, example_sample_annotation, 
qual_col = NULL, filename = 'test_peptide.png', 
width = 28, height = 18, units = 'cm')

## End(Not run)

#to examine peptides of a single protein:
peptides_of_one_protein_plot <- plot_peptides_of_one_protein (
protein_name = "Haao", peptide_annotation = example_peptide_annotation,
protein_col = "Gene", df_long = example_proteome, 
sample_annotation = example_sample_annotation, 
order_col = 'order', sample_id_col = 'FullRunName', 
batch_col = 'MS_batch')

#saving the peptides of one protein
## Not run: 
 peptides_of_one_protein_plot <- plot_peptides_of_one_protein (
protein_name = "Haao", peptide_annotation = example_peptide_annotation,
protein_col = "Gene", df_long = example_proteome, 
sample_annotation = example_sample_annotation, 
order_col = 'order', sample_id_col = 'FullRunName', 
batch_col = 'MS_batch',
filename = 'test_protein.png', width = 14, height = 9, units = 'in')
## End(Not run)

#to illustrate spike-ins:
spike_in_plot <- plot_spike_in(spike_ins = "BOVINE_A1ag", 
peptide_annotation = example_peptide_annotation, protein_col = 'Gene', 
df_long = example_proteome, sample_annotation = example_sample_annotation, 
sample_id_col = 'FullRunName',
plot_title = "Spike-in BOVINE protein peptides")

#to illustrate iRT peptides:
irt_plot <- plot_iRT(irt_pattern = "iRT", 
peptide_annotation = example_peptide_annotation, 
df_long = example_proteome, sample_annotation = example_sample_annotation, 
protein_col = 'Gene')

#illustrate the fitting curve:
special_peptide = example_proteome$peptide_group_label == "10231_QDVDVWLWQQEGSSK_2"
loess_fit_70 <- adjust_batch_trend_df(example_proteome[special_peptide,], 
example_sample_annotation, span = 0.7)

fitting_curve_plot <- plot_with_fitting_curve(feature_name = "10231_QDVDVWLWQQEGSSK_2", 
df_long = example_proteome, sample_annotation = example_sample_annotation, 
fit_df = loess_fit_70, plot_title = "Curve fitting with 70% span")

#with curves colored by the corresponding batch:
fitting_curve_plot <- plot_with_fitting_curve(feature_name = "10231_QDVDVWLWQQEGSSK_2", 
df_long = example_proteome, sample_annotation = example_sample_annotation, 
fit_df = loess_fit_70, plot_title = "Curve fitting with 70% span", 
color_by_batch = TRUE, batch_col = 'MS_batch')


symbioticMe/proBatch documentation built on April 9, 2023, 11:59 a.m.