【问题标题】:Identifying individuals with observations across two datasets通过两个数据集的观察来识别个人
【发布时间】:2014-05-13 10:52:27
【问题描述】:

我正在使用 R 和 "WGCNA" package。我正在对转录组和代谢组进行综合分析。

我有两个data.frames,一个用于转录组数据:datExprFemale,一个用于代谢组学数据:allTraits,但我无法将这两个data.frames 合并在一起。

> datExprFemale[1:5, 1:5]
ID    gene1         gene2       gene3        gene4
F16 -0.450904880  0.90116800 -2.710879397  0.98942336
F17 -0.304889916  0.70307639 -0.245912838 -0.01089557
F18  0.001696330  0.43059153 -0.177277078 -0.24611398
F19 -0.005428231  0.32838938  0.001070509 -0.31351216
H1   0.183912553 -0.10357460  0.069589703  0.15791036

> allTraits[1:5, 1:5]
IND   met1          met2        met3         met4
F15   6546          68465       56465        6548
F17   89916         7639        2838         9557
F20   6330          53          7078         11398
F1    231           938         509          351216

allTraits 中的个体在datExprFemale 中有测量值,但datExprFemale 中的某些个体在allTraits 中没有出现。

这是我尝试将两个 data.frames 合并在一起的内容:

# First get a vector containing the row names (individual's ID) in datExprFemale
IND=rownames(datExprFemale)
# Get the rows in which two variables have the same individuals
traitRows = match(allTraits$IND, IND)
datTraits = allTraits[traitRows, -1]

这给了我以下信息:

         met1                       met2    met3                      met4
11       0.0009                     0.0559   7.1224                    3.3894
12       0.0006                     0.0370  10.5776                   14.4437
15       0.0011                     0.0295   5.7941                   19.0225
16       0.0010                     0.0531   6.1010                    4.7698
17       0.0016                     0.0462   7.7819                    7.8796
19       0.0011                     0.0192  12.7126                    9.2564
20       0.0007                     0.0502   9.4147                   15.3579
21       0.0025                     0.0455   8.4129                   17.7273
NA           NA                         NA       NA                        NA
NA.1         NA                         NA       NA                        NA
NA.2         NA                         NA       NA                        NA
NA.3         NA                         NA       NA                        NA
NA.4         NA                         NA       NA                        NA
3        0.0017                     0.0375   8.8503                    8.7581
7        0.0006                     0.0156   7.9272                    4.9887
8        0.0011                     0.0154   8.4716                    8.6515
9        0.0010                     0.0306   9.1220                    3.5843

如您所见,有一些 NA 值,但我不确定为什么?

现在,当我想使用以下代码将每个人的 ID 分配给相应的行时:

rownames(datTraits) = allTraits[traitRows, 1]

R 给出这个错误:

Error in `row.names<-.data.frame`(`*tmp*`, value = value) : 
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': 

我不知道我做错了什么,

【问题讨论】:

  • 您是否只需要进行代谢组学和转录组学测量的个体?
  • 另外,WGCNA 并不期望这两个数据集被合并(即您通常在表达式数据上运行 WGCNA,然后寻找与它发现的模块和您的代谢组数据的关系)

标签: r dataframe


【解决方案1】:

你的代码有几个问题:

  1. 在您提供的格式中,您的datExprFemale 没有rownames,因此根本无法匹配。
  2. match 告诉您allTraits 中的个人对应于datExprFemale 中的哪些行,而不是您需要从allTraits 中提取的行。

这是我将采取的方法:

# First make sure `allTraits` and `datExprFemale` actually have the right rownames
rownames(datExprFemale) = datExprFemale$ID
rownames(allTraits) = allTraits$IND
# Now get the individuals who have both transcriptomic and metabolomic 
# measurements
has.both = union(rownames(allTraits), rownames(datExprFemale))
# Now pull out the subset of allTraits you want:
allTraits[has.both,]

【讨论】:

    【解决方案2】:

    感谢您的回复。实际上代码中的“datTraits”必须是这样的: Insulin_ug_l Glucose_Insulin Leptin_pg_ml 脂联素 Aortic.lesions F2_3 944 0.42055085 15148.76 14.339 296250 F2_14 632 0.67088608 6188.74 15.439 486313 F2_15 3326 0.16746843 18400.26 11.124 180750 F2_19 426 0.89671362 8438.70 16.842 113000 F2_20 2906 0.15691672 41801.54 13.498 166750 F2_23 920 0.58804348 24133.54 14.511 234000 F2_24 1895 0.24538259 52360.00 13.813 267500 F2_26 7293 0.09090909 126880.00 14.118 198000 F2_37 653 0.65849923 17100.00 12.470 121000 F2_42 1364 0.35703812 99220.00 14.531 110000

    其中行是个体,列是代谢物。此变量包含转录组学和代谢组学文件中的个体。 但如果是我从 WGCNA 教程中复制的代码。 感谢您的任何建议, 贝扎德

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      • 2020-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多