get_fold_change_matrix: Prepare a fold change matrix

View source: R/rnaseq_related.R

get_fold_change_matrixR Documentation

Prepare a fold change matrix

Description

This function returns a dataframe having first column gene names and subsequent columns are fold change values for the comparisons passed through sample_comparisons.

Usage

get_fold_change_matrix(x, sample_comparisons, genes)

Arguments

x

an abject of class "parcutils". This is an output of the function run_deseq_analysis().

sample_comparisons

a character vector denoting sample comparisons for which fold change values to be derived.

genes

a character vector denoting gene names for which fold change values to be derived.

Value

a dataframe.

Examples

count_file <- system.file("extdata","toy_counts.txt" , package = "parcutils")
count_data <- readr::read_delim(count_file, delim = "\t")

sample_info <- count_data %>% colnames() %>% .[-1]  %>%
 tibble::tibble(samples = . , groups = rep(c("control" ,"treatment1" , "treatment2"), each = 3) )


res <- run_deseq_analysis(counts = count_data ,
                         sample_info = sample_info,
                         column_geneid = "gene_id" ,
                         group_numerator = c("treatment1", "treatment2") ,
                         group_denominator = c("control"))

genes = parcutils::get_genes_by_regulation(x = res, sample_comparison = "treatment2_VS_control") %>% names()

fc_df <- get_fold_change_matrix(x = res, sample_comparison = c("treatment2_VS_control" , "treatment1_VS_control"), genes = genes)

print(fc_df)


cparsania/parcutils documentation built on Oct. 27, 2024, 4:55 a.m.