library(scater)
library(scran)
library(batchelor)
library(edgeR)
library(tidyverse)
library(patchwork)
library(DT)
fontsize <- theme(axis.text=element_text(size=12), axis.title=element_text(size=16))

Source: Multi-sample comparisons of the OSCA book.

0.1 Exercise 1 - differential expression

Identify label-specific DE genes that are significant in cluster 4 yet not DE in any other label.

Plot the top-ranked gene for inspection.

# load RObjects until this point

load("../Robjects/10_exercise1.RData")
# get cluster 4's 'unique.degs':

# 2nd cluster in is.de
cx <- "4"
other.labels <- setdiff(colnames(not.de), cx)
unique.degs <- is.de[,cx]!=0 & rowMeans(not.de[,other.labels])==1
unique.degs <- names(which(unique.degs))
head(unique.degs)
## [1] "ENSG00000204475" "ENSG00000102780" "ENSG00000261560" "ENSG00000182871"
# Choosing the top-ranked gene for inspection:
de.inspec <- list()
de.inspec[[cx]] <- de.results[[cx]] 
de.inspec[[cx]] <- de.inspec[[cx]][order(de.inspec[[cx]]$PValue),]
de.inspec[[cx]] <- de.inspec[[cx]][rownames(de.inspec[[cx]]) %in% unique.degs,]

# plot expression of top gene
# use plotExpression()
sizeFactors(summed.filt) <- NULL
plotExpression(logNormCounts(summed.filt), 
    features=rownames(de.inspec[[cx]])[1],
    x="Sample", colour_by="Sample", 
    other_fields="label") + 
    facet_wrap(~label) +
  ggtitle(glue::glue("{cx}: {rownames(de.inspec[[cx]])[1]}"))