How to extract factor levels of coldata from deseq object?
1
0
Entering edit mode
ariel ▴ 20
@ariel-16886
Last seen 2.4 years ago
United States

Suppose I have run deseq like this:

my_coldata$varA = factor(mycoldata$varA, levels=c('control', 'case')
my_coldata$varB = factor(mycoldata$varB, levels=c(0,1))

dds =  DESeqDataSetFromMatrix(
    countData=my_counts,
    colData=my_coldata,
    design=~varA + varB
  )

deseq_obj = DESeq(
    dds,
    test='Wald',
    fitType='mean'
  )

I can access the metadata with colData(deseq_obj) but it comes as a matrix with factor and level information wiped out. Is there a way to access this information?

Maybe a suggestion would be to switch to DataFrames since that is becoming ever more standard in the r-verse.

Thanks!

deseq2 levels factor colData • 1.4k views
ADD COMMENT
2
Entering edit mode
@mikelove
Last seen 13 hours ago
United States

Check out the SummarizedExperiment package for details on how colData works. It is in fact a DataFrame.

You can just do dds$variable to print the variable and if it is a factor it will print the levels.

ADD COMMENT
0
Entering edit mode

I have a plotting routine to which I'm passing deseq_obj, and I was hoping I might get the levels in there. Well gollee, it IS a DataFrame. I had tried to extract the levels from the output of colData and thought I got an error and a matrix object. But as you said, it really is a DataFrame and has the levels. I can do colData(deseq_obj)$varA and get the levels.

ADD REPLY

Login before adding your answer.

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