我正在研究R中的代谢组学数据集。
我需要帮助两件事:1)用代谢物的最低测量值替换特定色谱柱(化合物/代谢物)中的每个NA值(在……中)
这会实现你想要的吗?
temp <- DF temp[is.na(temp)] <- 0 newDF <- temp + is.na(DF)*apply(DF,2,min, na.rm=T) apply(newDF,2,function(x) {x/median(x[7:10])})
这是运行此后的输出
(N(1) + N(8))-acetylspermidine 1-carboxyethylisoleucine 1-carboxyethylleucine 1-carboxyethylphenylalanine 1-carboxyethyltyrosine M_1 0.9359195 0.7145459 0.7871485 0.6579746 0.5102093 M_2 0.6729678 0.4590989 0.2343293 0.4377833 0.5883331 M_3 1.4075379 0.2466991 0.2343293 0.2671932 0.3161437 M_4 1.6831733 1.7448039 1.4106177 1.4174585 0.9429587 M_5 0.7915154 0.7969099 0.7699341 0.5255432 0.2927932 M_6 0.8134746 0.7865203 0.7691156 0.7492979 0.4214131 M_7 1.0892263 1.6020550 1.4604685 1.7327533 1.2067333 M_8 0.9107737 0.6284189 0.5395315 0.6229404 0.3221194 M_9 1.4888755 0.5010444 0.3792505 0.4189253 1.4296428 M_10 0.8283128 1.3715811 1.6040065 1.3770596 0.7932667