Help Subsetting DDS for plotPCA for contrast groups
1
0
Entering edit mode
yee • 0
@41361920
Last seen 9 months ago
United States

Hello all,

I'm having trouble extracting and subsetting my dds for plotPCA. I only have one interested column called condition which I converted to factor along with the levels inside, c("Control", "Treatment1", "Treatment2", "Treatment3"). However, the code still prints out errors during the dds subset. For context, I generated my dds from DESeqDataSetFromTximport. I've succesfully plotted my global PCA, however I wanted to view different contrast groups to see the patterns, e.g. Treatment 1 vs Treatment 3 on PCA.

Though I get these error messages on colinearity and this one:

# Check if the column "condition" exists in colData
 if ("condition" %in% colnames(colData(dds))) { 
 colData(dds)$condition <- factor(colData(dds)$condition, levels = c("Control_Diet", "High_Fat_Diet", "Prophylactic", "Therapeutic"))
 } else {
 stop("Column 'condition' not found in colData(dds). Check your metadata.") }

> No warning message, so ran clear 
 # Define the levels of interest for subsetting
 levels_of_interest <- c("Prophylactic", "Therapeutic") 
>Ran clear
# Subset for levels of interest
 subset_dds <- dds[, colData(dds)$condition %in% levels_of_interest] 
>Ran clear
# Run DESeq2 analysis on the subset (optional)
subset_dds <- DESeq(subset_dds)
>Error in designAndArgChecker(object, betaPrior) : 
  full model matrix is less than full rank
Rstudio plotPCA DESeq2 • 755 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 17 hours ago
United States

Try droplevels on the condition:

dds$condition
ADD COMMENT
0
Entering edit mode

Hello!

Thank you for helping, I ended up being able to plot and subset it by selecting the factor levels, then went and transformed it to rlog and then just used plotPCA like normal.

Subset the DESeqDataSet for "Treatment2" and "Treatment6" groups

subset_dds <- dds[, dds$condition %in% c("Treatment2", "Treatment6")]

rld_subset <- rlog(subset_dds, blind = FALSE) # You can use VST as well if preferred

Create PCA plot with name tags, title, and print as PDF

plotPCA(rld_subset, intgroup = "condition") + ggtitle("Treat2 vs Treat6 Groups")

geom_text(aes(label = colData(rld_subset) $sample.name), vjust = -0.5, hjust = -0.5)

ADD REPLY

Login before adding your answer.

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