Changing the sample order in the PCA plot
1
0
Entering edit mode
turtle888 • 0
@48cb0748
Last seen 8 weeks ago
Denmark

Hi,

I'm wondering, how can you change the order in the PCA plot labeling:

I have "day0", "day1, "day2", "day8" and "day15", and by default, it puts "day15" before "day2" because of the alphabetical/numerical order. How can I fix it, so that "day15" comes at last?


plotPCA(vsd, intgroup="condition")
#
# levels(condition) gives
#[1] "day0"  "day1"  "day2"  "day8"  "day15"
# so, the order is correct here.

Thank you.

DESeq2 • 172 views
ADD COMMENT
1
Entering edit mode
ATpoint ★ 2.0k
@atpoint-13662
Last seen 3 hours ago
Germany

You have to change the factor levels in the vsd object itself, so vsd$condition <- factor(as.character(vsd$condition), levels=c("day0", "day1", "day2", "day8", "day15")).

Example:

library(DESeq2)

dds <- makeExampleDESeqDataSet()
vsd <- vst(dds, nsub=3)

vsd$condition <- relevel(vsd$condition, ref = "B")
plotPCA(vsd, "condition")
ADD COMMENT
0
Entering edit mode

Thank you. It worked!

ADD REPLY

Login before adding your answer.

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