knitr::opts_chunk$set(echo = TRUE, message=FALSE)
if (!require("DESeq2")) { BiocManager::install("DESeq2") } library(knitr) # for function "kable"
countfile_url <- "https://raw.githubusercontent.com/PacktPublishing/R-Bioinformatics-Cookbook/master/datasets/ch1/modencodefly_count_table.txt" countfile <- "modencodefly_count_table.txt" if (!file.exists(countfile)) { download.file(countfile_url,countfile) } count_dataframe <- readr::read_tsv(countfile) kable(head(count_dataframe))
genes <- count_dataframe[['gene']] count_dataframe[['gene']] <- NULL count_matrix <- as.matrix(count_dataframe) rownames(count_matrix) <- genes
phenofile_url <- "https://raw.githubusercontent.com/PacktPublishing/R-Bioinformatics-Cookbook/master/datasets/ch1/modencodefly_phenodata.txt" phenofile <- "modencodefly_phenodata.txt" if (!file.exists(phenofile)) { download.file(phenofile_url,phenofile) } pheno_data <- readr::read_table2(phenofile) kable(head(pheno_data))
experiments_of_interest <- c("L1Larvae", "L2Larvae") columns_of_interest <- which( pheno_data[['stage']] %in% experiments_of_interest ) counts_of_interest <- count_matrix[,columns_of_interest] kable(head(counts_of_interest))
library(magrittr) grouping <- pheno_data[['stage']][columns_of_interest] %>% forcats::as_factor() grouping
library("DESeq2") dds <- DESeqDataSetFromMatrix(countData = as.data.frame(counts_of_interest), colData = grouping, design = ~ stage)
dds <- DESeq(dds)
# res <- results(dds, contrast=c("stage","L2Larvae","L1Larvae")) # head(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.