我有以下数据框:
dat <- structure(list(genes = c("SPATA6", "PRKCA", "IFI44", "CD34",
"STAT5A", "SPP1", "IFI44", "UGCG", "RUNX2", "POLB"), tissue = c("P-MSC",
"fBM-MSC", "vBM-MSC", "A-MSC", "A-MSC", "P-MSC", "fBM-MSC", "P-MSC",
"fBM-MSC", "fBM-MSC"), tpm = c(3.20952419313059, 2.10173208901973,
0.191585903686574, 0.70984187675755, 1.13513749520554, 5.37796566842205,
1.04686030297216, 2.60310788820118, 2.21414404845853, 3.82316169950135
)), .Names = c("genes", "tissue", "tpm"), row.names = c(NA, -10L
), class = c("tbl_df", "tbl", "data.frame"))
dat
#> genes tissue tpm
#> 1 SPATA6 P-MSC 3.2095242
#> 2 PRKCA fBM-MSC 2.1017321
#> 3 IFI44 vBM-MSC 0.1915859
#> 4 CD34 A-MSC 0.7098419
#> 5 STAT5A A-MSC 1.1351375
#> 6 SPP1 P-MSC 5.3779657
#> 7 IFI44 fBM-MSC 1.0468603
#> 8 UGCG P-MSC 2.6031079
#> 9 RUNX2 fBM-MSC 2.2141440
#> 10 POLB fBM-MSC 3.8231617
目前我正在使用此代码对因子进行排序:
dat$tissue <- factor(dat$tissue, levels = c("fBM-MSC", "vBM-MSC", "A-MSC", "P-MSC"))
我的问题是他如何使用初始dat
的dplyr管道执行相同的操作?