问题描述
我有一个data.frame,其中包含三个变量(基因,样本,copy_number),我想对按基因名称分组的copy_number进行汇总统计。
我尝试在dplyr中使用summary函数,但一直失败。
我想要一些具有或多或少特定corrected_copy_number
的样本
数据看起来像这样(被截断)
> sub.melt.df.annotations.cna.genes
Gene_Names sample corrected_copy_number
3234 BRCA1 sample1 6
7317 BRCA2 sample1 1
10500 ERBB2 sample1 4
11258 GATA3 sample1 3
3234 GATA3 sample2 2
7317 BRCA2 sample2 1
10500 ERBB2 sample2 3
.
.
11258 GeneX sampleN #
> sub.melt.df.annotations.cna.genes %>% group_by(Gene_Names) %>% dplyr::summarise(count=n(),min(corrected_copy_number),gain=n((corrected_copy_number>2)))
Error: Problem with `summarise()` input `gain`.
x unused argument ((corrected_copy_number > 2))
ℹ Input `gain` is `n((corrected_copy_number > 2))`.
ℹ The error occurred in group 1: Gene_Names = "BRCA1".
Run `rlang::last_error()` to see where the error occurred.
感谢您的帮助
解决方法
将n(corrected_copy_number>2)
替换为sum(corrected_copy_number>2)
。