我有一个包含17个变量的df(我的样本),其条件位置是我希望基于单个基因“光系统II蛋白D1 1”绘制的条件
View(metadata)
sample location
<chr> <chr>
1 X1344 West
2 X1345 West
3 X1365 West
4 X1366 West
5 X1367 West
6 X1419 West
7 X1420 West
8 X1421 West
9 X1473 Mid
10 X1475 Mid
11 X1528 Mid
12 X1584 East
13 X1585 East
14 X1586 East
15 X1678 East
16 X1679 East
17 X1680 East
View(countdata)
func X1344 X1345 X1365 X1366 X1367 X1419 X1420 X1421 X1473 X1475 X1528 X1584 X1585 X1586 X1678 X1679 X1680
photosystem II protein D1 1 11208 6807 3483 4091 12198 7229 7404 5606 6059 7456 4007 2514 5709 2424 2346 4447 5567
ddsMat已这样创建:
ddsMat <- DESeqDataSetFromMatrix(countData = countdata,
colData = metadata,
design = ~ location)
绘图时:
library(DeSeq2)
plotCounts(ddsMat, "photosystem II protein D1 1", intgroup=c("location"))
默认情况下,该函数按字母顺序绘制“条件”,例如:East-Mid-West。但是我想订购它们,以便可以在西-东-东图表上看到它们。
有没有办法做到这一点? 谢谢,
答案 0 :(得分:0)
我发现您可以像这样手动更改顺序:
ddsMat$location <- factor(ddsMat$location, levels=c("West", "Mid", "East"))