Question: How to extract factor levels of coldata from deseq object?
0
gravatar for ariel
5 months ago by
ariel0
ariel0 wrote:

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 factor coldata levels • 184 views
ADD COMMENTlink modified 5 months ago by Michael Love24k • written 5 months ago by ariel0
Answer: How to extract factor levels of coldata from deseq object?
2
gravatar for Michael Love
5 months ago by
Michael Love24k
United States
Michael Love24k wrote:

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 COMMENTlink written 5 months ago by Michael Love24k

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 REPLYlink written 5 months ago by ariel0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 200 users visited in the last hour