我正在使用R中的一些基因組文件。我有一個(gè)像下面的例子那樣格式化的大矩陣,其中列是樣本,行是基因(真實(shí)矩陣有205列,超過(guò)22k行。
GSM1304852 GSM1304853 GSM1304854 GSM1304855
1007_s_at 2.3945368 2.27518369 2.1611630 1.9641833
1053_at 0.1051084 0.06160802 0.3421762 0.3593916
117_at -0.4597124 -0.52310349 -0.4436059 -0.6370277
121_at 0.9333566 1.13180904 0.9975700 1.0079778
我還有一個(gè)像下面的例子那樣格式化的數(shù)據(jù)幀,其中g(shù)eo_accession可以在矩陣的第一行中找到相同的id。
title geo_accession Age Disease_State Gender pH PMI Race RIN tissue
GSM1304852 bipolar_hip_10 GSM1304852 52 bipolar disorder M 6.7 23.5 W 6.3 hippocampus
GSM1304853 bipolar_hip_11 GSM1304853 50 bipolar disorder F 6.4 11.7 W 6.8 hippocampus
GSM1304854 bipolar_hip_12 GSM1304854 28 bipolar disorder F 6.3 22.3 W 7.7 hippocampus
GSM1304855 bipolar_hip_13 GSM1304855 55 bipolar disorder F 6.4 17.5 W 7.6 hippocampus
GSM1304856 bipolar_hip_14 GSM1304856 58 bipolar disorder M 6.8 27.7 W 7.0 hippocampus
GSM1304857 bipolar_hip_15 GSM1304857 28 bipolar disorder M 6.2 27.4 W 7.7 hippocampus
我需要將與特定組織相關(guān)的矩陣中的所有列進(jìn)行子集化(在完整的數(shù)據(jù)幀中有3種組織),因此最后,我需要有3個(gè)矩陣。
例如:從矩陣我想只采取與hippocampus以下相關(guān)的列:
matrix # an R matrix object
DataFrame # an R dataframe
DFhip <- DataFrame[ which(tissue == 'hippocampus',]
GSMlist <- DFhip$geo_accesion
MatrixHip <- matrix[GSMlist,] # I know this is the wrong syntax, it's just to let you understand
我對(duì)R比較新,我不習(xí)慣子集矩陣。
解決辦法:我不確定我是否理解你的問(wèn)題,但如果你想為ine行子集數(shù)據(jù)幀,只需使用:
data1<-data[data[1] %in% c("GSM1304852","GSM1304855")]
on data [1]是數(shù)據(jù)框中需要子集的列數(shù)








暫無(wú)數(shù)據(jù)