Question: DESeq2: subset dds or vsd to plot PCA with specific genes only
0
gravatar for Cece
7 months ago by
Cece0
United States/Houston
Cece0 wrote:

Hi All,

I've run DESeq2 on my counts comparing two conditions, treated vs untreated. I have my dds object and have generated my vsd object using the command:

vsd <- vst(dds, blind = FALSE)

then plotted my PCA using:

plotPCA(vsd, intgroup = "condition", ntop = 500)

However, I'd like to produce another plot using just a subset, which is those genes I identified as DE (padj < 0.05). My problem is, when I try to extract a subset from the vsd data using:

de <- rownames(res[res$padj<0.05 & !is.na(res$padj), ])
de_mat <- assay(vsd)[de,]

Then try to use this object to plot the PCA:

plotPCA(de_mat, intgroup = "condition", ntop = 500)

I receive the error message:

Error in (function (classes, fdef, mtable)  : 
 unable to find an inherited method for function ‘plotPCA’ for signature ‘"matrix"’

Which makes sense because de_mat is a matrix and vsd is not. Can anyone help me with another way to extract my subset of genes from the dds/ vsd object so I can use the subsequent object to plot a PCA?

I need to confirm, via PCA, that this subset does indeed discriminate between the two groups sufficient to justify my downstream analyses. My PCA using the full gene set shows mixing of the groups and it would be great to be able to justify using a great visual like a PCA for just the DE genes at this point, so that I can show clear separation of the groups.

I greatly appreciate all help in advance. If anyone has ideas on other visuals, I'm open to those as well. I've already covered heatmaps and volcano plots, though; it's just that my PI really likes the idea of the DE genes only PCA.

subset rna-seq plotpca deseq2 R • 662 views
ADD COMMENTlink modified 7 months ago by Kevin Blighe50k • written 7 months ago by Cece0
1
gravatar for Kevin Blighe
7 months ago by
Kevin Blighe50k
Kevin Blighe50k wrote:

Hey,

The issue is that plotPCA() is a DESeq2-specific function - it does not work with data-matrices or data-frames. To generate your PCA bi-plot, you will have to do:

plotPCA(vsd, intgroup = "condition", ntop = 500)

...or:

plotPCA(vsd[de,], intgroup = "condition", ntop = 500)

For now, I will not discuss the validity of running PCA in a biased fashion.

If you want to run PCA analyses on a simple data-matrix or data-frame, then you can use my own package: https://github.com/kevinblighe/PCAtools

Kevin

ADD COMMENTlink modified 7 months ago • written 7 months ago by Kevin Blighe50k

Thanks, Kevin,

Subsetting vsd worked great for me. I've also looked at PCATools, which looks really comprehensive but a little intimidating to me. My counts data is in a text file, with genes as rows and columns as samples:

          sample1   sample2    sample3
gene1    1063       1092       1487
gene2    240        309        329
gene3    47         26         31

My phenotypic data is also a text file, with samples as rows and each column representing a different phenotypic trait:

           Age    Gender    condition
sample2    13     Female    treated
sample2    15     Male      treated
sample3    8      Female    untreated

How do I import this data into PCATools?

Cheers, Cece

ADD REPLYlink modified 6 months ago • written 6 months ago by Cece0

Hey, you would just have to do:

require(PCAtools)
p <- pca(x = MyData, metadata = MyMetadata, removeVar = 0.1)

However, I have a strict check in place whereby the rownames of MyMetadata have to be the same as the colnames of MyData (same names and in same order).

For this, as per DESeq2's function, the input data should be the transformed counts.

Don't worry if you just want to generate a bi-plot - that is easy with DESeq2's function.

ADD REPLYlink modified 6 months ago • written 6 months ago by Kevin Blighe50k
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.3.0
Traffic: 1904 users visited in the last hour