Search
Question: sampleNames differ between assayData and phenoData
1
gravatar for Biorunner88
17 months ago by
Biorunner8810
Spain
Biorunner8810 wrote:

Sorry for this question, but for some reason something is happening that I'm not able to find. I'm having the next problem while creating the expression set.

 

 

    pd <- data.frame(state = colnames(q@mat))
    rownames(pd) <- pd[,1]
    pd[,1] <- 1
    pheno = new("AnnotatedDataFrame", data=pd)
    x = q@mat 
    
    es =  ExpressionSet(assayData=x, phenoData = pheno)

 

I get

Error in validObject(.Object) :
  invalid class “ExpressionSet” object: sampleNames differ between assayData and phenoData

 

While it seems that they all have the same names in the same order.

> colnames(x) == rownames(pd)
  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [30] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [59] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
 [88] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[117] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[146] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[175] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

 

If I add

colnames(x) <- rownames(pd)

to the code then I can run the script without any problem. Why?

Thanks for your time.

ADD COMMENTlink modified 17 months ago by Martin Morgan ♦♦ 20k • written 17 months ago by Biorunner8810
1
gravatar for Martin Morgan
17 months ago by
Martin Morgan ♦♦ 20k
United States
Martin Morgan ♦♦ 20k wrote:

The validity test uses `identical()`, so you could try identical(colnames(x), rownames(pd)) and if that fails all.equal(colnames(x), rownames(pd)). I'd guess that one or the other (probably colnames(x)) has an attribute

> df = data.frame(x=1, row.names="a") 
> m = matrix(1, 1, 1, dimnames=list(NULL, "a"))
> e = ExpressionSet(m, AnnotatedDataFrame(df))
> colnames(m) = structure(colnames(m), foo="")
> colnames(m)
[1] "a"
attr(,"foo")
[1] ""
> e = ExpressionSet(m, AnnotatedDataFrame(df))
Error in validObject(.Object) : 
  invalid class "ExpressionSet" object: sampleNames differ between assayData and phenoData

Probably setting rownames on pd removes the attributes. FWIW it's better practice to use the constructor AnnotatedDataFrame() rather than new(); also all() would help summarize the test of equality.

 

ADD COMMENTlink written 17 months ago by Martin Morgan ♦♦ 20k

The identical() test returns a FALSE, so thats is the problem.

Thanks for the answer.

ADD REPLYlink written 17 months ago by Biorunner8810
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 2.2.0
Traffic: 178 users visited in the last hour