简体   繁体   English

无法使用 R 的 kohonen package 引用在 som 分析中聚集的基因

[英]Not able to refer back to genes clustered in som analysis using R's kohonen package

I am stuck in a problem, I am trying to apply SOM analysis using the kohonen package in R.我遇到了一个问题,我正在尝试使用 R 中的 kohonen package 应用 SOM 分析。 The dataset I am using is a gene expression dataframe.我使用的数据集是基因表达 dataframe。 I am using the code given below,我正在使用下面给出的代码,

dim(bink)
[1]  401 1198

Where bink is a dataframe having expression values for 1198 genes, where gene names are in the columns as shown below,其中 bink 是 dataframe 具有 1198 个基因的表达值,其中基因名称在如下所示的列中,

在此处输入图像描述

The rest of the code is given below,下面给出代码的rest,

grid <- somgrid(xdim = 5, ydim = 5, topo = "hexagonal")

som.wines <- som(scale(bink), grid = somgrid(xdim = 5, ydim = 5, "hexagonal"))
str(som.wines)
plot(som.wines, type = "mapping")

After applying the code above I get the plot shown below,应用上面的代码后,我得到如下所示的 plot,

在此处输入图像描述

But I am not able to get the name of the genes clustered in each circle, I have tried to use the answer given here for which the code is given below,但是我无法获得聚集在每个圆圈中的基因名称,我尝试使用此处给出的答案,代码如下所示,

x= attr(som.wines$data,"scaled:center")

y= attr(som.mines$data,"scaled:scale")

for (i in 1:ncol(som.wines$data)){
z[,i] = som.wines$data[,i][som.wines$unit.classif==1] * y[i]+x[i]
}

Then I am getting the error given below,然后我收到下面给出的错误,

# Error in 1:ncol(som.wines$data) : argument of length 0

I also tried changing the way to access the data by using som.wines$data[[1]] but it does not work.我还尝试使用som.wines$data[[1]]更改访问数据的方式,但它不起作用。

Is there any way to solve this problem?有没有办法解决这个问题?

Thanks谢谢

Using data(wines) as an example.data(wines)为例。

som.wines <- som(scale(wines), grid = somgrid(5, 5, "hexagonal"))

Each big circle in your plot is a cluster of samples found in the data by rows. plot 中的每个大圆圈都是按行在数据中找到的一组样本。 The profiles of the clusters are stored in som.wines$codes .集群的配置文件存储在som.wines$codes中。 Each line here is a cluster, V1 - Vx.这里的每一行都是一个簇,V1 - Vx。 This corresponds, obviously, to the number of big circles.显然,这对应于大圆圈的数量。 You find the associated rows, ie the original data, in som.wines$unit.classif .您可以在som.wines$unit.classif中找到相关的行,即原始数据。

Associate the clusters with your original data with将集群与您的原始数据相关联

cbind(wines, cluster=som.wines$unit.classif)

The arrangement of big circles used in the plot correspond with numbers in som.wines$codes in that the bottom right big circle is V1 and the top left is Vx , ie the last cluster. plot 中使用的大圆圈的排列与som.wines$codes中的数字相对应,右下角的大圆圈是V1 ,左上角是Vx ,即最后一个簇。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM