deseq_results_into_list: From DESeq2 results to a list of data.frames

View source: R/deseq_results_into_list.R

deseq_results_into_listR Documentation

From DESeq2 results to a list of data.frames

Description

This function only works with categorical contrasts

Usage

deseq_results_into_list(
  deseq_results,
  trait,
  physeq_obj = NULL,
  taxon_lvls_added = "all",
  sort_p.val = TRUE
)

Arguments

deseq_results

a DESeq2 results object

trait

A character with the variable name to compare contrasts within

physeq_obj

the phyloseq object you used, if any

taxon_lvls_added

A character with the taxonomic levels to add to each results data.frame

sort_p.val

a logical saying whether you want the 'padj' column sorted or not

Value

A list of pairwise contrasts based on the factor levels of the trait variable

Examples


library(phyloseq)
library(DESeq2)
filepath <- system.file("extdata", "study_1457_split_library_seqs_and_mapping.zip", package="phyloseq")
kostic <- microbio_me_qiime(filepath)

kostic = subset_samples(kostic, DIAGNOSIS != "None")

diagdds = phyloseq_to_deseq2(kostic, ~ OSH_DIAGNOSIS)

# calculate geometric means prior to estimate size factors

 gMeans = apply(counts(diagdds), 1, function(x, na.rm=TRUE) exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x)))

# do the glm modelling

diagdds2 = estimateSizeFactors(diagdds, geoMeans = gMeans)
diagdds = DESeq(diagdds2, fitType="local")

res_list_with_Phyloseq <- deseq_results_into_list(deseq_results = diagdds,
                        trait = "OSH_DIAGNOSIS",
                        physeq_obj = kostic,
                        taxon_lvls_added = c("Phylum", "Class", "Genus")
                        )

res_list_withOut_Phyloseq <- deseq_results_into_list(deseq_results = diagdds,
                        trait = "OSH_DIAGNOSIS"
                        )

g-antonello/gautils2 documentation built on Nov. 28, 2022, 9:39 a.m.