这是我的
df <- data.frame(SNP = c("rs123","rs567"),
A1 = c("A","C"),
A2 = c("G","T"),
A1A1.x = c(16,52),
A1A2.x = c(104,342),
A2A2.x = c(127,408),
A1A1.y = c(14,80),
A1A2.y = c(122,186),
A2A2.y = c(107,183),
P_HWE = c(0.4293,0.09432),
A1A1_x = c(6.4777328,6.4837905),
A1A2_x = c(42.10526,42.64339),
A2A2_x = c(51.417,50.87282),
A1A1_y = c(5.7613169,17.8173719),
A1A2_y = c(50.20576,41.42539),
A2A2_y = c(44.03292,40.75724))
这就是我需要的
SNP A1 A2 Genotypes n_controls f_controls n_cases f_cases P_HWE
rs123 A G AA 16 6.4777328 14 5.7613169 0.4293
rs123 A G GA 104 42.10526 122 50.20576 0.4293
rs123 A G GG 127 51.417 107 44.03292 0.4293
rs567 C T CC 52 6.4837905 80 17.8173719 0.09432
rs567 C T TC 342 42.64339 186 41.42539 0.09432
rs567 C T TT 408 50.87282 183 40.75724 0.09432
有什么建议吗?提前感谢!
1条答案
按热度按时间xa9qqrwz1#
使用
pivot_longer
,您可以将数据重塑为long,使用expand.grid
,您可以创建基因型。