View source: R/sample_metadata.R
add_contrast | R Documentation |
Note that a MS-DAP contrast for "A vs B" will return foldchanges for B/A in downstream output tables and data visualizations. For example, for the contrast "control vs disease" a positive log2 foldchange implies protein abundances are higher in the "disease" sample group.
Throughout this function, all samples where the column "exclude" is set to TRUE are disregarded.
add_contrast(
dataset,
colname_condition_variable,
values_condition1,
values_condition2,
colname_additional_variables = NULL
)
dataset |
your dataset. Make sure you've already imported sample metadata |
colname_condition_variable |
sample metadata column name that should be used for the experimental condition. Typically, this is the "group" column. Should be any of the values in |
values_condition1 |
array of values from column |
values_condition2 |
analogous to |
colname_additional_variables |
optionally, sample metadata column names that should be used as additional regression variables (only the subset of |
print_contrasts()
to print an overview of defined contrasts, remove_contrasts()
to remove all current contrasts (and respective filtering and DEA results)
## Not run:
# first, remove all existing contrasts (and their respecive DEA results)
dataset = remove_contrasts(dataset)
# Assume that column "group" in your sample metadata table specifies sample groups
# The following example will create the contrast "WT vs KO"
dataset = add_contrast(dataset, "group", "WT", "KO")
# If the sample metadata table contains a column "batch" that should be used as
# a regression variable (works for ebayes/deqms/msqrob), we can add it as follows:
dataset = add_contrast(dataset, "group", "WT", "KO", colname_additional_variables = "batch")
# Elaborate example; create a contrast while matching multiple values per group.
# Testing all motor- and visual-cortex samples (described in the "brain_region"
# column) against prefrontal cortex samples, with additional regression variables
# batch and age.
# In this example, the sample metadata table must contain columns
# "brain_region", "batch", "age"
dataset = add_contrast(
dataset,
# this parameter describes 1 column name in `dataset$samples`
colname_condition_variable = "brain_region",
# values in "brain_region" that are the first group in A/B testing
values_condition1 = c("motor_cortex", "visual_cortex"),
# analogous, but for the second group in A/B testing.
# note that you may alternatively this to `NA` to indicate
# "everything except values in values_condition1"
values_condition2 = c("prefrontal_cortex"),
# a vector/array of 0 or more column names in dataset$samples
# that should be used as additional regression variables
colname_additional_variables = c("batch", "age")
)
# Assume that the sample metadata table contains a column "group" with values
# "A", "B", "C", "D". The following code will create the contrast "A vs B,C,D"
# by setting the second set of values to `NA`
dataset = add_contrast(
dataset,
colname_condition_variable = "group",
values_condition1 = "A",
values_condition2 = NA
)
## The "group" column in the sample table is used for group definitions in
## "all group" filtering. We here create two contrasts based on different
## regression variables in the sample tabel.
dataset = remove_contrasts(dataset) # optionally, remove previously defined contrasts
dataset = add_contrast(
dataset,
colname_condition_variable = "genotype",
values_condition1 = "control",
values_condition2 = "knockout",
colname_additional_variables = "batch"
)
dataset = add_contrast(
dataset,
colname_condition_variable = "genotype",
values_condition1 = "control",
values_condition2 = c("knockout", "mutant1"),
# note that we have the flexibility to add different regression variables per contrast
colname_additional_variables = "batch"
)
# print an overview of all contrasts
print_contrasts(dataset)
# apply typical MS-DAP pipeline
dataset = analysis_quickstart(
dataset,
filter_min_detect = 0, ## if DDA, we might not require minimum MS/MS counts
filter_min_quant = 3,
filter_fraction_detect = 0,
filter_fraction_quant = 0.75,
filter_by_contrast = FALSE, ## we only want filtering across all groups
filter_min_peptide_per_prot = 2, ## 2 peptides per protein
dea_algorithm = "deqms",
norm_algorithm = c("vwmb", "modebetween_protein"),
output_qc_report = TRUE,
output_abundance_tables = TRUE,
output_dir = "C:/temp", ## you may set this to NA to skip the QC report
output_within_timestamped_subdirectory = TRUE
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.