How to generate a PCA scree plot in DESeq2?
2
0
Entering edit mode
@candicechudvm-10038
Last seen 6.5 years ago

Hi all,

I've watched this video and wants to visualize the PCA scree plot to check my PCA plot that was generated in DESeq2. 

Is there any way I can do it in DESeq2 or in other Bioconductor packages?

pca deseq2 PCA scree plot • 4.3k views
ADD COMMENT
2
Entering edit mode
@mikelove
Last seen 1 day ago
United States

I'd recommend just using your own code to do the PCA.

You can copy out the first lines of the plotPCA function to get started, see ?plotPCA.

Then you'll just want to plot the amounts in 'percentVar'.

ADD COMMENT
1
Entering edit mode

Hi Michael,

Thank you for your help! Our RNA-seq research has been published in Scientific Reports: https://www.nature.com/articles/s41598-017-16603-y. Your work and technical supports are appreciated and acknowledged in the references and the acknowledgment section. 

ADD REPLY
1
Entering edit mode

Cheers. that's very kind of you.

ADD REPLY
2
Entering edit mode
@candicechudvm-10038
Last seen 6.5 years ago

Hi Micheal,

Thank you so much!!!

I manage to generate the PCA scree plot by following your instruction.

Here is my script:

     library(DESeq2)
     library(matrixStats)
     
     #How to get PCA plot?
     ##how to obtain d.deseq was described in DESeq2 manual
     
     cds=estimateDispersions(dds)
     vsd=varianceStabilizingTransformation(cds)
     plotPCA(vsd,intgroup=c("condition","timepoints"))
     
     #How to get PCA scree plot?
     
     ## calculate the variance for each gene
     rv <- rowVars(assay(vsd))

     ## select the ntop genes by variance
     select <- order(rv, decreasing=TRUE)[seq_len(min(500, length(rv)))]
     
     ## perform a PCA on the data in assay(x) for the selected genes
     pca <- prcomp(t(assay(vsd)[select,]))
     
     ## the contribution to the total variance for each component
     percentVar <- pca$sdev^2 / sum( pca$sdev^2 )
     
     ##plot the "percentVar"
     scree_plot=data.frame(percentVar)
     scree_plot[,2]<- c(1:24)

     colnames(scree_plot)<-c("variance","component_number")
     ggplot(scree_plot, mapping=aes(x=component_number, y=variance))+geom_bar(stat="identity")

ADD COMMENT

Login before adding your answer.

Traffic: 712 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