cor_de: Conduct a differential expression analysis using correlation...

Description Usage Arguments Details Value See Also Examples

Description

This function is designed to ingest data in the form output by functions like get_bw_data().

Usage

1
2
3
4
5
6
7
cor_de(
  data,
  condition,
  genes = NULL,
  method = c("spearman", "kendall", "pearson"),
  padj_method = stats::p.adjust.methods[1]
)

Arguments

data

A data frame where rows are samples and columns are genes and metadata.

condition

A string. The name of the column in data which contains the condition on which the differential expression is premised. This column should be logical, a factor with two levels or a numeric vector. The first level (or FALSE) is the baseline and the second level (or TRUE) is the disease/treatment. If the condition is numeric, then columns log2fc, base_med, case_med, base_mean and case_mean will be absent from the result.

genes

A character vector. The column names that contain the genes for the differential expression. If NULL, any genes in data found in mirmisc::get_gene_names() are used.

method

A string. The correlation test method. Must be "spearman", "kendall" or "pearson".

padj_method

A string. The method of adjusting the p-values for multiple hypothesis testing. Must be one of stats::p.adjust.methods().

Details

This function has no way of dealing with batch effects. To allow for these, you should correct your data (with e.g. linear_correct()) beforehand.

Value

A tibble with 8 columns:

See Also

Other differential expression methods: deseq(), edger()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
if (requireNamespace("mirmisc", quietly = TRUE)) {
  bwms_data <- get_combined_cohort_data(
    c("bw", "ms"),
    log2 = TRUE, tot_counts = TRUE,
    gene_predicate = ~ stats::median(.) > 0,
  ) %>%
    dplyr::filter(!is.na(meta_pre_eclampsia)) %>%
    dplyr::mutate(tot_counts = log2(tot_counts + 1))
  genes <- dplyr::intersect(mirmisc::get_gene_names(), names(bwms_data))
  bwms_corr <- linear_correct(
    bwms_data,
    correct_cols = genes,
    correct_for_cols = c("log2_tot_counts", "cohort",
                         "meta_q_pcr_actb_ct", "meta_q_pcr_ercc_ct"),
    keep_effect_cols = "meta_pre_eclampsia"
  )[[1]]
  cor_de(bwms_corr, "meta_pre_eclampsia")
}

mirvie/mirmodels documentation built on Jan. 14, 2022, 11:12 a.m.