表达式集 - 现象数据

发布于 2024-12-04 05:07:47 字数 3334 浏览 0 评论 0原文

首先我必须说,我刚刚开始使用 R 进行编程。我无法创建数据的表达式集。当我尝试将分析数据和表型数据放在一起制作表达式集时,出现错误:

validObject(.Object) 中的错误:“无效类 “ExpressionSet”对象:assayData 和之间的样本名称不同 现象数据”

请看一下示例数据、我制作的表型数据表和 R 程序。我想应该修改表型数据才能使其正常工作。

请让我知道如何解决此问题并更改表型数据。

AssayData                                                       
    0h-1    0h-2    6h-1    6h-2    12h-1   12h-2   24h-1   24h-2   48h-1   48h-2   72h-1   72h-2   96h-1   96h-2
171407  4.021342514 4.021342514 6.847201005 6.847201005 3.189312274 3.189312274 3.322687671 3.322687671 4.929574559 4.929574559 4.040127938 4.040127938 3.181587044 3.181587044
171415  267.8091012 267.8091012 358.8511895 358.8511895 266.4562608 266.4562608 210.259177  210.259177  243.1496956 243.1496956 248.2780935 248.2780935 235.7079055 235.7079055
171426  13.3620332  13.3620332  5.581083074 5.581083074 12.5236932  12.5236932  8.433621131 8.433621131 13.07390505 13.07390505 12.94673202 12.94673202 23.43214156 23.43214156
171453  37.65310777 37.65310777 27.88942772 27.88942772 54.7409581  54.7409581  78.86045287 78.86045287 63.61655487 63.61655487 67.31327606 67.31327606 62.35426899 62.35426899

PhenoData                                                       
        condition   time    rep                                         
0h-1    Control 0   1                                           
0h-2    Control 0   2                                           
6h-1    treatment   6   1                                           
6h-2    treatment   6   2                                           
12h-1   treatment   12  1                                           
12h-2   treatment   12  2                                           
24h-1   treatment   24  1                                           
24h-2   treatment   24  2                                           
48h-1   treatment   48  1                                           
48h-2   treatment   48  2                                           
72h-1   treatment   72  1                                           
72h-2   treatment   72  2                                           
96h-1   treatment   96  1                                           
96h-2   treatment   96  2   

我的代码:

library(""Biobase"")                                                        
library(""betr"")                                                                                                   
exprs <- as.matrix(read.table(""Timecourse-Assaydata.txt"", header=TRUE, sep=""\t"", row.names=1, as.is=TRUE))                                                      
pData <- read.table(""Timecourse-Phenodata.txt"", row.names=1, header=TRUE, sep=""\t"")                                                     
metadata <- data.frame(labelDescription = c(""Hour of treatment"", ""Treatment time"", ""number of replicates""), row.names = c(""condition"", ""time"", ""rep""))                                                      
phenoData <- new(""AnnotatedDataFrame"", data = pData, varMetadata = metadata)                                                  

exprspop <- new(""ExpressionSet"", exprs = exprs, phenoData = phenoData)    

validObject(.Object) 中的错误:“无效类 “ExpressionSet”对象:assayData 和之间的样本名称不同 现象数据”

I must start by saying that I'm just beginning to program using R. I'm unable to create expressionset of my data. When I try to put assaydata and phenodata together to make expressionset, I get an error:

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

Please take a look at the sample data, the phenodata table I made and R-program. I guess that the phenodata should be modified to get this working.

Please let me know how to solve this and alter phenodata.

AssayData                                                       
    0h-1    0h-2    6h-1    6h-2    12h-1   12h-2   24h-1   24h-2   48h-1   48h-2   72h-1   72h-2   96h-1   96h-2
171407  4.021342514 4.021342514 6.847201005 6.847201005 3.189312274 3.189312274 3.322687671 3.322687671 4.929574559 4.929574559 4.040127938 4.040127938 3.181587044 3.181587044
171415  267.8091012 267.8091012 358.8511895 358.8511895 266.4562608 266.4562608 210.259177  210.259177  243.1496956 243.1496956 248.2780935 248.2780935 235.7079055 235.7079055
171426  13.3620332  13.3620332  5.581083074 5.581083074 12.5236932  12.5236932  8.433621131 8.433621131 13.07390505 13.07390505 12.94673202 12.94673202 23.43214156 23.43214156
171453  37.65310777 37.65310777 27.88942772 27.88942772 54.7409581  54.7409581  78.86045287 78.86045287 63.61655487 63.61655487 67.31327606 67.31327606 62.35426899 62.35426899

PhenoData                                                       
        condition   time    rep                                         
0h-1    Control 0   1                                           
0h-2    Control 0   2                                           
6h-1    treatment   6   1                                           
6h-2    treatment   6   2                                           
12h-1   treatment   12  1                                           
12h-2   treatment   12  2                                           
24h-1   treatment   24  1                                           
24h-2   treatment   24  2                                           
48h-1   treatment   48  1                                           
48h-2   treatment   48  2                                           
72h-1   treatment   72  1                                           
72h-2   treatment   72  2                                           
96h-1   treatment   96  1                                           
96h-2   treatment   96  2   

My Code:

library(""Biobase"")                                                        
library(""betr"")                                                                                                   
exprs <- as.matrix(read.table(""Timecourse-Assaydata.txt"", header=TRUE, sep=""\t"", row.names=1, as.is=TRUE))                                                      
pData <- read.table(""Timecourse-Phenodata.txt"", row.names=1, header=TRUE, sep=""\t"")                                                     
metadata <- data.frame(labelDescription = c(""Hour of treatment"", ""Treatment time"", ""number of replicates""), row.names = c(""condition"", ""time"", ""rep""))                                                      
phenoData <- new(""AnnotatedDataFrame"", data = pData, varMetadata = metadata)                                                  

exprspop <- new(""ExpressionSet"", exprs = exprs, phenoData = phenoData)    

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情归归情 2024-12-11 05:07:47

此问题的正确位置是 Bioconductor 支持网站。最好提供一个可重现的示例来抓住问题的本质;创建可重现的示例通常有助于确定问题的原因。

library(Biobase)

exprs <- matrix(0, nrow=5, ncol=3,
                dimnames=list(letters[1:5], LETTERS[1:3]))
pData <- data.frame(id=c("foo", "bar", "baz"),
                    row.names=c("x", "y", "z"))
phenoData <- AnnotatedDataFrame(data=pData)

导致

> ExpressionSet(exprs, phenoData=phenoData)
Error in validObject(.Object) : 
  invalid class "ExpressionSet" object: sampleNames differ between assayData and
phenoData

问题在于exprscolname(即实验中样本的名称)与row.names不同pData(即样本的描述)

> row.names(pData)
[1] "x" "y" "z"
> colnames(exprs)
[1] "A" "B" "C"

,解决方案是使它们相同

> colnames(exprs) <- row.names(pData)
> eset <- ExpressionSet(exprs, phenoData=phenoData)
> eset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 5 features, 3 samples 
  element names: exprs 
protocolData: none
phenoData
  sampleNames: x y z
  varLabels: id
  varMetadata: labelDescription
featureData: none
experimentData: use 'experimentData(object)'
Annotation:  

可以使用 assayDataReplace() 将其他元素添加到现有的 ExpressionSet,例如,

> assayDataElement(eset, "foo") <- sqrt(exprs)
> eset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 5 features, 3 samples 
  element names: exprs, foo 
protocolData: none
phenoData
  sampleNames: x y z
  varLabels: id
  varMetadata: labelDescription
featureData: none
experimentData: use 'experimentData(object)'
Annotation:  

或从一开始

> env = new.env()
> env$exprs = exprs
> env$sqrt = sqrt(exprs)
> lockEnvironment(env)
> ExpressionSet(env, pData=pData)
ExpressionSet (storageMode: environment)
assayData: 5 features, 3 samples 
  element names: exprs, sqrt 
protocolData: none
phenoData: none
featureData: none
experimentData: use 'experimentData(object)'
Annotation: 

The correct place for this question is on the Bioconductor support site. It's better to provide a reproducible example that captures the essence of the problem; creating the reproducible example often helps to identify the reason for the problem.

library(Biobase)

exprs <- matrix(0, nrow=5, ncol=3,
                dimnames=list(letters[1:5], LETTERS[1:3]))
pData <- data.frame(id=c("foo", "bar", "baz"),
                    row.names=c("x", "y", "z"))
phenoData <- AnnotatedDataFrame(data=pData)

leading to

> ExpressionSet(exprs, phenoData=phenoData)
Error in validObject(.Object) : 
  invalid class "ExpressionSet" object: sampleNames differ between assayData and
phenoData

The problem is that the colname of exprs (i.e., the names of the samples in the experiment) differ frrom the row.names of pData (i.e., the description of the samples)

> row.names(pData)
[1] "x" "y" "z"
> colnames(exprs)
[1] "A" "B" "C"

and the solution is to make them the same

> colnames(exprs) <- row.names(pData)
> eset <- ExpressionSet(exprs, phenoData=phenoData)
> eset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 5 features, 3 samples 
  element names: exprs 
protocolData: none
phenoData
  sampleNames: x y z
  varLabels: id
  varMetadata: labelDescription
featureData: none
experimentData: use 'experimentData(object)'
Annotation:  

Additional elements can be added to an existing ExpressionSet using assayDataReplace(), e.g.,

> assayDataElement(eset, "foo") <- sqrt(exprs)
> eset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 5 features, 3 samples 
  element names: exprs, foo 
protocolData: none
phenoData
  sampleNames: x y z
  varLabels: id
  varMetadata: labelDescription
featureData: none
experimentData: use 'experimentData(object)'
Annotation:  

or from the start

> env = new.env()
> env$exprs = exprs
> env$sqrt = sqrt(exprs)
> lockEnvironment(env)
> ExpressionSet(env, pData=pData)
ExpressionSet (storageMode: environment)
assayData: 5 features, 3 samples 
  element names: exprs, sqrt 
protocolData: none
phenoData: none
featureData: none
experimentData: use 'experimentData(object)'
Annotation: 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文