A class representing a nested representation of pairwise comparisons given a pairwise design.
Details
Pairwise Comparison Class
This class serves as a superclass for all methods of pairwise comparisons considered in this package. It defines the shared public and private methods common to all subclass.
Pairwise comparisons are used in experimental designs with test vs control samples, comparing their expression tags to determine deregulation between conditions.
This function filters the results table based on specified groups and batches. Note that the term "filter" in this context does not refer to a statistical filter.
Attributes
expr_data: An ExprData object.results: A nested data.frame with columns "batch", "group", and a nested "data" column containing:baseMean: Numeric vector with the base mean of expression value
log2FoldChange: Numeric vector with the log2FC
lfcSE: Numeric vector with the log2FC standard error
pvalue: Numeric vector with the p-values
padj: Numeric vector with the adjusted p-values
status: Factor vector with four levels: undetected, filtered, outlier, analyzed
tag_id: Character vector with the tag id
opts: Important options defined during initialization.
Methods
Method filter_and_get_results()
Retrieve the results table after filtering for specific groups/batches and with the option to add new columns to extend the tag ID.
Usage
PairwiseComp$filter_and_get_results(
in_batch,
in_group,
verbose = FALSE,
add_ids = c("gid", "symbol", "uniprot", "protein_names", "type", "tax_name"),
safe_translate = FALSE
)Arguments
in_batchVector of batch codes; select or report only samples in these batches
in_groupVector of group codes; select or report only samples in these groups
verboseIf TRUE, the column names are replaced with more meaningful names
add_idsCharacter vector; see
toargument of methodgenerate_translate_dictfrom class Annotation Available options are: "gid", "symbol", "uniprot", "protein_names", "type", and "tax_name"safe_translateIf TRUE, the function will keep original ids if the translation fails
Method generate_a_list()
Generate a list of deregulated genes for a specific comparison based on given criteria.
Usage
PairwiseComp$generate_a_list(
in_batch,
in_group,
id = "symbol",
use_padj = TRUE,
type = "deregulated",
lfc_abs_lim = 1,
min_signif = 0.05,
ranking = "log2FoldChange",
top_x = NULL
)Arguments
in_batchVector of batch codes; select or report only samples in these batches
in_groupVector of group codes; select or report only samples in these groups
idCharacter vector; see
toargument of methodgenerate_translate_dictfrom class Annotationuse_padjWhether to use the adjusted p-value or not
typeType of deregulation: "deregulated", "upregulated", or "downregulated"
lfc_abs_limThreshold for log fold change
min_signifThreshold for significance
rankingA character string specifying the value to use for ranking. Can be either "log2FoldChange" (default) or "z" for a z-score calculated from the p-value and fold change direction.
top_xAn integer. If not NULL (the default), the list is restricted to the top
top_xgenes after ranking.
Method cross_args_and_generate_lists()
Generate crossed lists of genes from all comparisons in nested results using multiple filtering criteria.
Arguments
cross_idCharacter vector; see
idargument ingenerate_a_listmethoduse_padjWhether to use the adjusted p-value or not
cross_typeVector of deregulation types; see
typeargument ingenerate_a_listmethod Available options are: "deregulated", "upregulated", "downregulated" (default: c("deregulated", "upregulated", "downregulated"))cross_lfc_abs_limVector of log fold change thresholds; see
lfc_abs_limargument ingenerate_a_listmethodcross_min_signifVector of significance thresholds; see
min_signifargument ingenerate_a_listmethodtop_xAn integer. If not NULL (the default), the list is restricted to the top
top_xgenes after ranking.
Method write_to_xlsx()
Write comparison results to xlsx
Usage
PairwiseComp$write_to_xlsx(
file_suffix = "_pairwiseComp.xlsx",
output_folder = ".",
in_batch = NULL
)Method extract_data_for_plot()
Return data for plots
Usage
PairwiseComp$extract_data_for_plot(
use_padj = TRUE,
lfc_abs_lim = 1,
min_signif = 0.05,
tag_id_select = "symbol",
tag_id_show = "symbol",
select_ids = NULL,
select_batches = NULL,
max_tags = 15,
in_batches = NULL,
hard_select = FALSE,
safe_translate = TRUE
)Arguments
use_padjWhether to use the adjusted p-value or not
lfc_abs_limThreshold for log fold change
min_signifThreshold for significance
tag_id_selectTag ID used for selection. Tag id can be "gid", "tgid", "txid", "symbol" or "uniprot"
tag_id_showTag ID used for plots. Tag id can be "gid", "tgid", "txid", "symbol" or "uniprot"
select_idsVector of IDs (
tag_id_select) to select the genesselect_batchesvector of batch to mark for selection
max_tagsmaximum number of tags to show
in_batchesvector of batches code to keep (default all)
hard_selectwhether to remove unselected data
safe_translateIf TRUE, the function will keep original ids if the translation fails
Method plot_lfc_per_group_facet_tags()
Return LFC per group with tags as facet plot(s)
Usage
PairwiseComp$plot_lfc_per_group_facet_tags(geoms = c("bar", "errorbar"), ...)Method plot_de()
Return plot(s)
Usage
PairwiseComp$plot_de(
plot_type,
lfc_limits = NULL,
geoms = "point",
show_selected_ids = TRUE,
text_in_box = FALSE,
max_nrow = 5,
tag_ids_size = 4,
tag_ids_alpha = 0.5,
log2_expr = TRUE,
batch_layout = "facet_grid_x",
facet_scales = "fixed",
facet_space = "fixed",
...
)Arguments
plot_typeplot to draw either:
"ma" : MA-plot
"vulcano" : vulcano-plot
"lfc_per_group" : lfc per group
"lfc_per_group_facet_tags" : lfc per group with tag facet
lfc_limitsvalues to draw hline and or vline for lfc
geomsvector with geoms to add:
point : compatible with all
bar : only for "lfc_per_group_facet_tags"
line : only for "lfc_per_group*"
errorbar : only for "lfc_per_group_facet_tags"
show_selected_idswhether or not to show the selected ids (not compatible with
lfc_per_group*)text_in_boxwhether or not to use box to plot text (show_selected_ids)
max_nrowmaximum of facet row for the nested wrap facetting
tag_ids_sizesize when tag ids are plotted in plot area
tag_ids_alphaalpha when tag ids are plotted in plot area
log2_exprWhether to use log2(x+2) transform for expression data
batch_layoutDefine the type of layout for batch
"facet_nested_wrap"
"facet_grid_x"
"facet_grid_y"
"color_selected" represent all batch on the same plot with a focus on a selected batch;only with plot_type "lfc_per_group_facet_tags" with
color_selectedwe must useselect_batchesfromextract_data_for_plot
facet_scalesscales = "fixed" by default
facet_spacespace = "fixed" by default
...options passed to extract_data_for_plot method
Method build_tag_hclust()
Return tag hclust "NA" values are replaced with 0
Usage
PairwiseComp$build_tag_hclust(
data = NULL,
meth_dist = "minkowski",
meth_value = "z",
meth_clust = "centroid",
max_abs_value = 100,
...
)Arguments
dataOptional data similar to extract_data_for_plot output
meth_distmethod to compute distance, see
dist()functionmeth_valuevalue to compute distance
"z"
"log2FoldChange"
meth_clustmethod to compute clustering, see
hclust()functionmax_abs_valuemaximum absolute value to consider
...options passed to extract_data_for_plot method
Method plot_heatmap()
Return HEATmap for a batch
Usage
PairwiseComp$plot_heatmap(
meth_tag_dist = "minkowski",
meth_tag_clust = "centroid",
meth_tag_value = "z",
max_abs_value_hclust = 100,
plot_value = "z",
max_abs_value_plot = 5,
cut_tree_k = NULL,
show_selected_ids = FALSE,
meth_tag_dist2 = "minkowski",
meth_tag_value2 = "z",
meth_tag_clust2 = "ward.D2",
max_abs_value_hclust2 = 100,
...
)Arguments
meth_tag_distmeth_distforbuild_tag_hclust()meth_tag_clustmeth_clustforbuild_tag_hclust()meth_tag_valuemeth_valueforbuild_tag_hclust()max_abs_value_hclustmax_abs_valueforbuild_tag_hclust()plot_valuevalue to plot
max_abs_value_plotmaximum value for values to plot
cut_tree_kif provided with cut the heatmap into pieces based on the hclust
"log2FoldChange"
"z" : z-score
show_selected_idswhether to show or not the selected ids.
meth_tag_dist2meth_distforbuild_tag_hclust()when finding gene cluster if cut_tree_k is not nullmeth_tag_value2meth_valueforbuild_tag_hclust()when finding gene cluster if cut_tree_k is not nullmeth_tag_clust2meth_clustforbuild_tag_hclust()when finding gene cluster if cut_tree_k is not nullmax_abs_value_hclust2max_abs_valueforbuild_tag_hclust()when finding gene cluster if cut_tree_k is not null...options passed to extract_data_for_plot method