Revision d0c13affeb1def1f728f0e57c64e55fc9dc7cb25 authored by Alexey Sergushichev on 21 December 2019, 15:46:32 UTC, committed by Alexey Sergushichev on 21 December 2019, 15:46:32 UTC
1 parent d227226
deseqAnalysis.R
#https://support.bioconductor.org/p/67600/#67612
#https://github.com/ctlab/sysbio-training/blob/master/masters-2019/rnaseq/mnt/scripts/do_deseq2.R
deseqAnalysis <- function (es, fieldValues) {
fieldValues <- replace(fieldValues, fieldValues == "", NA)
es.copy <- es
es.copy$Comparison <- fieldValues
es.copy <- es.copy[, !is.na(fieldValues)]
dds <- DESeq2::DESeqDataSetFromMatrix(exprs(es.copy), pData(es.copy), design=~Comparison)
populatedDds <- DESeq2::DESeq(dds)
de <- DESeq2::lfcShrink(populatedDds, contrast = c('Comparison', 'B', 'A'), cooksCutoff = FALSE)
deDf <- as.data.frame(de)
toRemove <- intersect(colnames(fData(es)), colnames(deDf))
fData(es)[, toRemove] <- NULL
es$Comparsion <- fieldValues
fData(es) <- cbind(fData(es), deDf)
assign("es", es, envir = parent.frame())
f <- tempfile(pattern = "de", tmpdir = getwd(), fileext = ".bin")
writeBin(protolite::serialize_pb(as.list(de)), f)
jsonlite::toJSON(f)
}
Computing file changes ...