在MATLAB中创建火山图时出错 [英] Error in creating a volcano plot in MATLAB
问题描述
我是MATLAB的新手,我要做的第一个任务是创建火山图.我一直在使用文档来了解它并开始使用.
I am a complete newbie to MATLAB and the first task I have is to create a volcano plot. I have been using the documentation to understand about it and get started.
我试图在虚拟值上运行它-
I tried to run it on dummy values -
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
是a
和b
中3个数据点的p值列表
My understanding is that a
represents the gene expression values for condition 1, b
for condition 2, and c
is the list of p-values for the 3 data points in a
and b
.
但是运行此代码会给我错误-
However running this code gives me the error -
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)
谁能解释我要去哪里错了?
Can anyone explain where I am going wrong?
推荐答案
由于使用行向量,因此遇到了问题.
You're encountering an issue because you are using row vectors.
在mavolcanoplot
函数内部(您可以通过在命令窗口中键入edit mavolcanoplot
来查看文件),有一个用于检查输入的本地函数,称为check_inputdata
.
Inside the mavolcanoplot
function (you can see the file by typing edit mavolcanoplot
in the command window) there is a local function for checking the inputs, called check_inputdata
.
您的数据通过所有验证检查,然后遇到以下部分:
Your data passes all of the validation checks, and then encounters this section:
% 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元素数组而失败!
This reduces your inputs to their mean. Later in the main function (line 127) you encounter the error as described, where paramStruct.goodVals
is a 3 element array, which is now trying to index a 1 element array and fails!
这基本上是调试和阅读文档的一课,其中指出
This is basically a lesson in debugging and reading the documentation, which states
DataX,DataY:如果矩阵,每行是一个基因,则每一列都是一个样本,并且计算每个基因的平均表达值 >.
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.
您应该使用以下等效方法之一创建列向量输入
You should use one of these equivalent methods to create column vector inputs
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中创建火山图时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!