error in relevel.default - 'relevel' only for (unordered) factors when setting baseline
1
0
Entering edit mode
Yihan • 0
@8e03f28b
Last seen 2.6 years ago
United States

I'm trying to use relevel to set the baseline to "WT" by specifying the reference level

Code should be placed in three backticks as shown below


keep <- rowSums(counts(ddsHTSeq)) >= 10
ddsHTSeq_filtered <- ddsHTSeq[keep,]

ddsHTSeq_filtered$Genotype <- relevel(ddsHTSeq_filtered$Genotype, ref = "WT")


> Error in relevel.default(ddsHTSeq_filtered$Genotype, ref = "WT") :   
> 'relevel' only for (unordered) factors

Here is what the sample sheet/table looks like. This genotype is divided into "mdx" and "WT" on the 3rd column.

DESeq2 • 7.3k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 7 hours ago
United States

If you are dispatching on relevel.default, it's because your input isn't already a factor. You can make it a factor and also specify the baseline at the same time. See ?factor

ADD COMMENT
0
Entering edit mode

The code before I did relevel is this. Did it fail to make factors?

ddsHTSeq_filtered$group <- factor(paste0(ddsHTSeq_filtered$Age, ddsHTSeq_filtered$Genotype, ddsHTSeq_filtered$Tissue))

ddsHTSeq_filtered$Genotype <- relevel(ddsHTSeq_filtered$Genotype, ref = "WT")

ADD REPLY
0
Entering edit mode

The code you present does nothing to the Genotype column that you then try to relevel. So yes, it made a factor for the combined Age, Gentotype, Tissue group, but why do you think that would affect the Genotype column?

ADD REPLY
0
Entering edit mode

To clarify, this line

ddsHTSeq_filtered$group <- factor(paste0(ddsHTSeq_filtered$Age, ddsHTSeq_filtered$Genotype, ddsHTSeq_filtered$Tissue))

adds a new 'group' column to your ddsHTSeq_filtered object by pasteing three existing columns together. But it doesn't do anything to those three other columns.

ADD REPLY
0
Entering edit mode

Thanks for clarifying, this is very helpful!

ADD REPLY

Login before adding your answer.

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