在 MATLAB 中创建火山图时出错
Error in creating a volcano plot in MATLAB
我是 MATLAB 的新手,我的第一个任务是创建火山图。我一直在使用 the documentation 了解它并开始使用。
我尝试 运行 它的虚拟值 -
a=[1 2 3]
b=[4.6 2.7 4.5]
c=[0.05 0.33 0.45]
然后我运行 -
SigStructure = mavolcanoplot(a, b, c)
我的理解是a
表示条件1的基因表达值,b
表示条件2,c
是3个数据点的p值列表在 a
和 b
.
但是 运行 宁此代码给了我错误 -
Index exceeds matrix dimensions.
Error in mavolcanoplot (line 127)
appdata.effect = X(paramStruct.goodVals) - Y(paramStruct.goodVals);
Error in volc (line 4)
SigStructure = mavolcanoplot(a, b, c)
谁能解释我哪里出错了?
您遇到问题是因为您使用的是行向量。
在 mavolcanoplot
函数中(您可以通过在命令 window 中键入 edit mavolcanoplot
查看文件)有一个用于检查输入的本地函数,称为 check_inputdata
.
您的数据通过了所有验证检查,然后遇到此部分:
% Here, 'X' and 'Y' are the local names for your inputs 'a' and 'b'
% Below code is directly from mavolcanoplot.m:
% Handle the matrix input. Use its mean values per row
if size(X, 2) > 1
X = mean(X,2);
end
if size(Y, 2) > 1
Y = mean(Y,2);
end
这会将您的输入降低到它们的平均值。稍后在主函数(第 127 行)中,您遇到了所描述的错误,其中 paramStruct.goodVals
是一个 3 元素数组,它现在试图索引一个 1 元素数组但失败了!
这基本上是调试和阅读文档的一课,其中说明
DataX, DataY: If a [...] matrix, each row is a gene, each column is a sample and an average expression value is calculated for each gene.
您应该使用其中一种等效方法创建列向量输入
a=[1 2 3].'; % Using transpose (.') to create a column vector from a row vector
b=[4.6; 2.7; 4.5]; % Creating a column vector using the semi-colon operator to end each row
c=[0.05
0.33
0.45]; % Using actual code layout to create a column vector
我是 MATLAB 的新手,我的第一个任务是创建火山图。我一直在使用 the documentation 了解它并开始使用。
我尝试 运行 它的虚拟值 -
a=[1 2 3]
b=[4.6 2.7 4.5]
c=[0.05 0.33 0.45]
然后我运行 -
SigStructure = mavolcanoplot(a, b, c)
我的理解是a
表示条件1的基因表达值,b
表示条件2,c
是3个数据点的p值列表在 a
和 b
.
但是 运行 宁此代码给了我错误 -
Index exceeds matrix dimensions.
Error in mavolcanoplot (line 127)
appdata.effect = X(paramStruct.goodVals) - Y(paramStruct.goodVals);
Error in volc (line 4)
SigStructure = mavolcanoplot(a, b, c)
谁能解释我哪里出错了?
您遇到问题是因为您使用的是行向量。
在 mavolcanoplot
函数中(您可以通过在命令 window 中键入 edit mavolcanoplot
查看文件)有一个用于检查输入的本地函数,称为 check_inputdata
.
您的数据通过了所有验证检查,然后遇到此部分:
% Here, 'X' and 'Y' are the local names for your inputs 'a' and 'b'
% Below code is directly from mavolcanoplot.m:
% Handle the matrix input. Use its mean values per row
if size(X, 2) > 1
X = mean(X,2);
end
if size(Y, 2) > 1
Y = mean(Y,2);
end
这会将您的输入降低到它们的平均值。稍后在主函数(第 127 行)中,您遇到了所描述的错误,其中 paramStruct.goodVals
是一个 3 元素数组,它现在试图索引一个 1 元素数组但失败了!
这基本上是调试和阅读文档的一课,其中说明
DataX, DataY: If a [...] matrix, each row is a gene, each column is a sample and an average expression value is calculated for each gene.
您应该使用其中一种等效方法创建列向量输入
a=[1 2 3].'; % Using transpose (.') to create a column vector from a row vector
b=[4.6; 2.7; 4.5]; % Creating a column vector using the semi-colon operator to end each row
c=[0.05
0.33
0.45]; % Using actual code layout to create a column vector