sampleNames differ between assayData and phenoData
1
1
Entering edit mode
@noncodinggene-7018
Last seen 5.8 years ago

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.

expresionset • 4.1k views
ADD COMMENT
1
Entering edit mode
@martin-morgan-1513
Last seen 2 days ago
United States

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 COMMENT
0
Entering edit mode

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

Thanks for the answer.

ADD REPLY

Login before adding your answer.

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