Search
Question: Is DESeq2 PCAplot already scaled?
0
gravatar for sofiagreen72211
11 weeks ago by
sofiagreen722110 wrote:

Hi All,

I'm trying to draw scaled PCA plot for my sequencing data while using DESeq2. The code, I am using is:

ds <- DESeqDataSetFromMatrix(countData=counts, colData=samples, design=~condition) 
ds$condition <- relevel(ds$condition, "Ctrl")
ds <- ds[rowSums(counts(ds)>1) >= 2, ] #PCA plot

# transformation
rld_ds <- rlog(ds, blind=FALSE) #regularized log-transformation

#PCA plot1
plotPCA(rld_ds, intgroup = c("SampleName"))

# PCA plot 2 using ggplot2
(pcadata <- plotPCA(rld_ds, intgroup = c( "condition", "SampleName"), returnData=TRUE))
(percentVar <- round(100 * attr(pcadata, "percentVar"))

ggplot(pcadata, aes(PC1, PC2, color=condition, label=SampleName)) +
  geom_point(size=3) +
  geom_text(aes(label=SampleName),hjust=.5, vjust=-1, size=3) +
  xlab(paste0("PC1: ",percentVar[1],"% variance")) + 
  ylab(paste0("PC2: ",percentVar[2],"% variance")) #plot 2

Now, my question:

Are these PCA plots already scaled due to rld transformation? if not, how can I do that?

Thanks,

Sofia

 

ADD COMMENTlink modified 11 weeks ago by Steve Lianoglou12k • written 11 weeks ago by sofiagreen722110
1
gravatar for Steve Lianoglou
11 weeks ago by
Genentech
Steve Lianoglou12k wrote:

You can take a look at the source for plotPCA by fetching it like so:

library(DESeq2)
getMethod("plotPCA", "DESeqTransform")

You will find in there the call to prcomp that does the PCA, namely:

pca <- prcomp(t(assay(object)[select, ]))

and a call to ?prcomp will show you the default values for the center and scale. paramenters (TRUE, and FALSE, respecitvely).

If you want to change the behavior, you can make your own pcaPlot function by copying the the code of that function into your own and tweaking accordingly.

ADD COMMENTlink written 11 weeks ago by Steve Lianoglou12k

Hi Steve:

Thank you for your quick response.

As I am passing rlog transformation object (rld_ds) to plotPCA which stabilizes variance applied to the raw data, so do I still need to scale my PCAplot with:

pca <- prcomp(rld_ds, center=T, scale=T)

Thank you for your time. I look forward to learning your advice. 

Sofia

ADD REPLYlink written 11 weeks ago by sofiagreen722110
1

I think it's best not to scale the data (make all the genes have same variance). I've posted an argument on the support site before about this, but it's impossible to find again. Basically, the rlog or vst put the data on a scale so there are no systematic differences due to the dynamic range. Forcing each gene to have variance one makes it worse (reduces signal and amplifies noise).

ADD REPLYlink written 10 weeks ago by Michael Love15k

Hi Michael:

Thank you very much for your reply. :)

Many thanks,

Sofia

ADD REPLYlink written 10 weeks ago by sofiagreen722110

I've tried to find that post several times now, too! Sadly I've had no luck with it either :-/

ADD REPLYlink modified 10 weeks ago • written 10 weeks ago by Steve Lianoglou12k
1

Is Scaling / normalizing by row in heatmap of DESeq2 it?

ADD REPLYlink written 10 weeks ago by James W. MacDonald45k

Yes! Thanks, bookmarked...

ADD REPLYlink written 10 weeks ago by Michael Love15k

How did you divine that post?

Are you a God?

 

ADD REPLYlink written 10 weeks ago by Steve Lianoglou12k
1

I utilized my l33t Google skillz:

pca plot scale love site:support.bioconductor.org

the search on this site is worthless, so I always just use Google directly with the site qualifier. It's the first hit on the second page (at least based on what Google thinks I want).

ADD REPLYlink written 10 weeks ago by James W. MacDonald45k

nice move -- strangely(?), it's also the it's also the first on the second page for me, too.

Maybe the search box on this site should just urlencode a google query with site:support.bioconductor.org appended to the end and bypass the internal search functionality entirely.

ADD REPLYlink written 10 weeks ago by Steve Lianoglou12k

DESeq2 plotPCA and scale

ADD REPLYlink written 10 weeks ago by sofiagreen722110
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 180 users visited in the last hour