What is the difference between these two arguments for log fold change shrinkage?
1
0
Entering edit mode
m-bihie ▴ 10
@4f002f4c
Last seen 20 months ago
Canada

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

data: https://assets.datacamp.com/production/repositories/1766/datasets/bf1d0eff910f1b2cad36e5acdc2a182e95c63965/fibrosis_smoc2_rawcounts_unordered.csv

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( )
DESeq • 746 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 1 day ago
United States

Can you describe how the plots are different?

ADD COMMENT

Login before adding your answer.

Traffic: 952 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6