简体   繁体   English

如何在R中读取特定的.Matrix文件

[英]how to read a specific .Matrix file in R

I have a .Matrix file, I have been told it is similar to .csv file, and I take a look by web browser, it looks like this: 我有一个.Matrix文件,有人告诉我它与.csv文件类似,并且我通过网络浏览器查看,看起来像这样:

%TransMat_H0004.E1.L1.S1.B1.T1

CLUSTER,,3,3,2,2,1,1,3,1,1,1,1,3,2,3,1,2,2,1,1,3,3,1,2,1,3,1,1,2,1,3,3,2,3,3,1,1,1,1,1,3,3,1,2,3,2,1,1,1,1,2,1,2,2,3,1,3,2,2,2,1,3,3,2,3,3,1,2,3,3,2,2,2,3,2,2,2,1,1,2,1,1,2,1,1,1,1,2,3,1,3,2,3,3,3,3,2,1,1,3,3,3,1,1,1,2,1,3,1,2,1,1,1,1,1,1,1,3,1,3,2,3,1,1,3,2,2,3,3,1,3,1,1,2,1,2,2,1,1,3,3,1,2,1,2,2,2,2,2,1,3,1,2,3,2,2,2,2,3,2,1,1,2,3,3,2,1,3,1,1,1,1,3,3,3,1,3,3,1,2,2,3,2,3,2,2,3,1,2,2,1,3,1,2,2,3,1,2,3,2,3,3,1,3,2,3,1,1,2,3,1,1,3,2,1,2,1,1,3,1,1,3,1,1,2,1,2,2,2,3,1,3,3,3,1,3,1,1,3,2,3,1,3,2,1,3,1,1,1,2,3,3,3,1,3,3,3,1,1,2,2,3,2,3,3,3,1,3,3,1,1,2,3,2,1,1,3,1,1,1,1,1,3,3,2,2,1,1,1,1,1,3,1,1,2,3,3,1,1,3,2,2,1,1,2,1,1,3,2,1,2,1,2,3,2,1,1,3,2,1,3,2,1,2,2,1,3,3,1,3,3,2,3,2,3,1,3,3,3,3,2,1,3,2,3,3,3,2,1,2,1,2,3,1,1,3,3,3,3,3,2,3,3,1,3,1,1,2,3,3,3,3,3,3,2,2,2,3,1,2,3,3,3,3,2,1,2,2,3,2,3,2,3,2,3,3,2,1,2,3,3,2,1,2,3,3,3,1,3,2,3,3,1,2,2,3,1,1,2,2,3,2,1,1,2,2,1,3,1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3,1,3,3,1 ,3,3,2,2,1,3,3,3,3,3,2,1,3,2,2,2,3,3,1,1,1,3,3,3,1,3,1 ,1,2,3,1,3,3,3,2,1,3,1,2,1,3,2,2,3,1,3,1,2,3,3,3,2 ,2,3,1,2,1,1,1,2,3,1,2,3,2,3,3,2,1,1,2,3,3,1,2,3,1 ,1,1,3,1,2,3,1,2,3,2,2,3,2,3,2,3,1,2,3,3,1,3,3,2,2 ,1,1,2,3,2,2,3,3,2,1,1,1,1,3,3,3,2,2,1,3,2,2,1,3,2,3 ,3,1,1,3,2,3,3,2,3,1,3,3,1,3,3,2,3,3,2,3,1,3,3,3,3 ,3,1,1,3,2,2,3,3,3,3,3,1,1,1,1,3,2,3,3,1,3,2,2,1,1,1 ,1,3,2,2,3,2,2,3,3,2,3,1,1,1,3,3,3,3,3,2,3,1,3,3,1,1 ,3,3,1,3,3,3,1,3,2,1,1,3,3,2,3,3,3,2,2,2,1,3,3,3,1,2 ,2,2,2,1,2,2,1,2,3,2,1,2,2,3,3,3,3,3,2,2,3,2,2,3,2 ,1,3,1,1,2,2,3,1,2,3,2,1,3,1,1,2,1,2,2,3,1,2,2,3,3 ,1,3,2,1,3,3,2,1,3,3,3,1,3,2,3,3,2,3,2,2,2,3,2,1,3,3 ,3,3,2,1,3,3,3,1,3,3,1,3,1,3,3,3

tSNE-1,,8.13846968090103,12.8635212043927,10.3864480425066,7.17083119797853,-72.7452686458686,-49.7960088439495,45.63460621346,-50.3693843293848,-53.2415432674881,-54.6891175204711,-46.4635164735514,4.49644447816871,3.98243750756555,-9.99729157677144,-98.1041739031645,14.4129117311442,21.8090838800674,-46.5547640077783,-65.8379505581324,39.8907136841164,45.2453417297103,-43.4054353275594,5.58370171555427,-82.6419520577671,42.7647608862027,-91.125151907502,-37.9838559192307,62.9924569510685,-69.108888726706,62.7774653919852,60.3873481045592,62.825 tSNE-1,,8.13846968090103,12.8635212043927,10.3864480425066,7.17083119797853,-72.7452686458686,-49.7960088439495,45.63460621346,-50.3693843293848,-53.2415432674881,-54.6891175204711,-46.4635164735514,4.49644447816871,3.9-8243750756547147 -65.8379505581324,39.8907136841164,45.2453417297103,-43.4054353275594,5.58370171555427,-82.6419520577671,42.7647608862027,-91.125151907502,-37.9838559192307,62.9924569510685,-69.108888726706,62.7774653919852,60.3873488255592

I tried to read it by read.csv: 我试图通过read.csv阅读它:

test=read.csv('TransMat_H0004.E1.L1.S1.B1.T1.Matrix',sep='' ) test = read.csv('TransMat_H0004.E1.L1.S1.B1.T1.Matrix',sep ='')

str(test) 'data.frame': 33141 obs. str(test)'data.frame':33141 obs。 of 1 variable: $ X.TransMat_H0004.E1.L1.S1.B1.T1: Factor w/ 33141 levels "A1BG,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"| 1个变量中的第一个:$ X.TransMat_H0004.E1.L1.S1.B1.T1:具有33141级的因子“ A1BG,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,“ | truncated ,..: 13453 31099 31100 1 2 3 4 5 6 7 ... 截断 ..:13453 31099 31100 1 2 3 4 5 6 7 ...

how should I read it in a right format, say, first character of 'sequence'(list?I guess?) as rowname. 我应该如何以正确的格式读取它,例如,“ sequence”(列表?我想是?)的第一个字符作为行名。

Thanks in advance! 提前致谢!


sorry, I cannot provide the data link because it is unpublished; 抱歉,我无法提供数据链接,因为它尚未发布; but I can tell you what the data look like: 但我可以告诉您数据是什么样的:

%TransMat_H0004.E1.L1.S1.B1.T1 
cluster,1,2,3,2,3….
tsne-
1,-41,-80…..
tsne-
2,-41,-80…..
tsne-
3,-41,-80…..
(and the rest are all started with gene name and number, such as)
genea, 0,2,1,0…
….
genez,0,2,1,0

my desired output is to remove the first 4 factors(cluster, tsne-1, tsne-2,tsne-3), and extract the gene transcripts matrix,such as: 我想要的输出是删除前四个因素(簇,tsne-1,tsne-2,tsne-3),并提取基因转录矩阵,例如:

V1 V2 V3 V4 V5
1  0  0  0  0  0
2  0  0  0  0  0
3  0  0  0  0  0
4  0  0  0  0  0
5  0  0  0  0  0

I figure this out by this: 我是这样想的:

read.csv("E2.Matrix", skip=1)

since the first row is annotation according to the bioinfor technician who arranged the .Matrix file 因为第一行是根据安排.Matrix文件的bioinfor技术人员的注释

Thanks! 谢谢! @ Stephan @斯蒂芬

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

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