我有一个数据集的基因型大约200个个体基因组(列),近1,000,000位点(行)。由于测序数据差,大多数行包含1-2个缺失基因型。
如果我用
df_new = na.omit(df)我的新数据框架仅包含几千行,导致的数据损失比我估计的每行丢失一个或两个值要大得多。我一直在网上寻找如何与na.option和prcomp()一起使用估算选项,但找不到例子。我想从最简单的方法开始,例如用中值或类似的值替换NA。
有人能告诉我如何在prcomp的上下文中这样做吗?
发布于 2021-12-16 21:14:55
现在我明白你的问题了,见下面的例子:
library(plyr)
ddply(df_new, ~ my_groups, transform,
missing value column = ifelse(is.na(missing value column),
median(missing value column, na.rm = TRUE),
missing value column))
#missing value column is the column that consist the missing value
#my_groups could be the first column of df_new我希望这能行。
https://stackoverflow.com/questions/70384427
复制相似问题