【发布时间】:2020-12-08 00:49:23
【问题描述】:
我尝试使用 mutate across 和我的数据跟踪线程 (Divide all columns by a chosen column using mutate_all),为每个除以“PanCK”的列生成一个新列,但是收到 non-numeric argument to binary operator 错误。
>dput(counts)
structure(list(Image = c("38_restained.ome.tif", "58 RESTAIN.ome.tif",
"64_restain.ome.tif", "B06.ome.tif", "B07.ome.tif", "B09.ome.tif",
"B12.ome.tif", "B15.ome.tif", "B16.ome.tif", "B32.ome.tif", "B38-1.ome.tif",
"B39.ome.tif", "B40.ome.tif", "B49.ome.tif", "B60.ome.tif", "B62.ome.tif",
"b64.ome.tif"), PanCk = c(560558, 204008, 317311, 5585, 348636,
582431, 357182, 391404, 323727, 592087, 423694, 177667, 379988,
417760, 107039, 215493, 296013), `PD-L1` = c(910, 89, 121, 91,
37900, 2782, 2495, 115978, 8159, 6705, 10179, 1228, 3781, 26278,
1007, 4265, 1581), CD8 = c(73, 13, 22, 395, 54872, 6631, 10130,
40904, 23442, 8010, 29402, 5122, 19098, 59773, 3207, 16607, 20973
), `PD-1` = c(5816, 1978, 1070, 1053, 43391, 8529, 8887, 40192,
13051, 9749, 13119, 2115, 13067, 26698, 3558, 12530, 2283), FoxP3 = c(395,
162, 100, 806, 14988, 2914, 2164, 18424, 14900, 11419, 4955,
1173, 4271, 4929, 1022, 955, 1396), CD68 = c(6504, 522, 285,
805, 45939, 16150, 10324, 15594, 26188, 15339, 19394, 2874, 26130,
20470, 2631, 2636, 7390)), row.names = c(NA, -17L), groups = structure(list(
Image = c("38_restained.ome.tif", "58 RESTAIN.ome.tif", "64_restain.ome.tif",
"B06.ome.tif", "B07.ome.tif", "B09.ome.tif", "B12.ome.tif",
"B15.ome.tif", "B16.ome.tif", "B32.ome.tif", "B38-1.ome.tif",
"B39.ome.tif", "B40.ome.tif", "B49.ome.tif", "B60.ome.tif",
"B62.ome.tif", "b64.ome.tif"), .rows = structure(list(1L,
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, 17L), class = c("tbl_df",
"tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
尝试使用:
countnorm <- counts %>%
mutate(across(everything()), ./ "PanCk")
【问题讨论】:
-
mutate(across(everything(), ~(./ PanCk))) -
mutate(across(everything(), `/`, PanCk))