In todays session we will work with some of Kindey and HindBrain ATAC-seq data.
I have already produced a summarisedexperiment of counts and put this in the data directory.
data/KidneyBrainCounts.RData
load("data/KidneyBrainCounts.RData")
<- kindeyBrainCounts
newDDS <- factor(c("HindBrain","HindBrain","Kidney","Kidney"))
Group colData(newDDS) <- DataFrame(data.frame(Group,row.names=colnames(kindeyBrainCounts)))
require(DESeq2)
require(tidyverse)
<- DESeqDataSet(newDDS,design=~Group)
atacDDS <- DESeq(atacDDS)
atacDDS <- results(atacDDS,contrast = c("Group","Kidney","HindBrain"),format = "GRanges")
myRes <- myRes[order(myRes$padj),]
myRes <- myRes[!is.na(myRes$log2FoldChange) & myRes$log2FoldChange > 0][1:1000]
upRegions <- myRes[!is.na(myRes$log2FoldChange) & myRes$log2FoldChange < 0,][1:1000] downRegions
library(BSgenome.Mmusculus.UCSC.mm10)
<- getSeq(BSgenome.Mmusculus.UCSC.mm10,resize(upRegions,fix = "center",width = 100))
upStrings <- getSeq(BSgenome.Mmusculus.UCSC.mm10,resize(downRegions,fix = "center",width = 100))
downStrings names(upStrings) <- as.character(resize(upRegions,fix = "center",width = 100))
names(downStrings) <- as.character(resize(downRegions,fix = "center",width = 100))
writeXStringSet(upStrings,file="UpRegions.fa")
writeXStringSet(downStrings,file="DownStrings.fa")
require(motifmatchr)
require(JASPAR2020)
<- file.path(system.file("extdata", package="JASPAR2020"),
db "JASPAR2020.sqlite")
<- list()
opts "tax_group"]] <- "vertebrates"
opts[["collection"]] <- "CORE"
opts[["all_versions"]] <- FALSE
opts[[require(TFBSTools)
<- getMatrixSet(db,opts)
motifs
<- newDDS[rowSums(assay(newDDS)) > 5,]
newDDS require(BSgenome.Mmusculus.UCSC.mm10)
<- addGCBias(newDDS,
newDDS genome = BSgenome.Mmusculus.UCSC.mm10)
<- matchMotifs(motifs, newDDS,
motif_ix genome = BSgenome.Mmusculus.UCSC.mm10)
deviations() <- computeDeviations(object = newDDS, annotations = motif_ix)
<- deviationScores(deviations)
devZscores
<- computeVariability(dev_Known)
variability_Known <- variability_Known[order(variability_Known$p_value),]
variability_Known
<- variability_Known[1:20,]
topVariable <- merge(topVariable[,1,drop=FALSE],devZscores,by=0)
devTop 1:2,]
devTop[
<- as.matrix(devTop[,-c(1:2)])
devToPlot rownames(devToPlot) <- devTop[,2]
library(pheatmap)
pheatmap(devToPlot)