Entering edit mode
I noticed two different MA plots when I use different inputs for the contrast argument in the lfcShrinkage() function. Both options worked for me but they produced different plots. Does anyone know why and what the difference entails? I used data from datacamp, so my apologies if someone cannot replicate the issue. I added the code I'm confused about betwen exclamation points.
data source: https://app.datacamp.com/learn/courses/rna-seq-with-bioconductor-in-r
Code should be placed in three backticks as shown below
rawcounts <- read_csv("fibrosis_smoc2_rawcounts_unordered.csv")
# Create genotype vector
genotype <- c("smoc2_oe", "smoc2_oe", "smoc2_oe", "smoc2_oe", "smoc2_oe", "smoc2_oe", "smoc2_oe")
# Create condition vector
condition <- c("fibrosis", "fibrosis", "fibrosis", "fibrosis", "normal", "normal", "normal")
# Create data frame
smoc2_metadata <- data.frame(genotype, condition)
rownames(smoc2_metadata) <- c("smoc2_fibrosis1", "smoc2_fibrosis2", "smoc2_fibrosis3", "smoc2_fibrosis4", "smoc2_normal1", "smoc2_normal3", "smoc2_normal4")
#work around to remove geneID column that has "...1" as a name
rawcountsfixed <- rawcounts %>%
select(-`...1`)
length(rownames(smoc2_metadata))
length(colnames(rawcountsfixed))
#reorder the rows of the metadata to match the order of columns in the counts data
idx <- match(colnames(rawcountsfixed),rownames(smoc2_metadata))
print(idx)
#use the output of the match() function to reorder the rows of the metadata to be in the same order as the columns in the count data
reordered_smoc2_metadata <- smoc2_metadata[idx, ]
# Create DESeq object
dds <- DESeqDataSetFromMatrix(countData = rawcountsfixed,
colData = reordered_smoc2_metadata,
design = ~ condition)
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#results
smoc2res <- results(dds,
contrast = c("condition", #I think this is the factor to
"fibrosis", #factor to compare
"normal"), #base level
alpha = 0.05)
#contrast arguments from datacamp
resNormDC <- lfcShrink(dds = dds,
res = smoc2res,
type = "normal",
contrast = c("condition", #I think this is the factor to
"fibrosis", #factor to compare
"normal") #base level
)
# -- plotMA with resNorm - DC way
plotMA(resNormDC)
#second contrast argument
resNorm2 <- lfcShrink(dds = dds,
res = smoc2res,
type = "normal",
coef = 2)
# -- plotMA with resNorm - 2nd way
plotMA(resNorm2)
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sessionInfo( )