【发布时间】:2016-06-26 00:25:55
【问题描述】:
我有一个相当大的 data.frame,有 12374 行(基因)和 785 列(细胞)。我想根据rowMeans 将行分组到 20 个箱中。在每个箱内,我想对该箱内所有基因的分散测量(方差/平均值)进行 z 归一化,以便识别其表达值高度可变的异常基因,即使与具有相似平均表达的基因相比也是如此。然后我想提取超过 z 分数阈值 1.7 的基因,以从每个 bin 中识别出显着可变的基因。
我的数据看起来像这样:
> head(temp[,1:5])
Cell1 Cell2 Cell3 Cell4 Cell5
0610007P14RIK 0.1439444 0.0000000 0.000000 0.8759335 0.0000000
0610009B22RIK 0.0000000 0.6776718 0.000000 0.0000000 0.0000000
0610009O20RIK 0.1439444 0.0000000 0.000000 0.2735741 0.0000000
0610010B08RIK 1.4769893 1.1369215 1.124842 0.8759335 1.9544187
0610010F05RIK 0.7944809 0.0000000 0.000000 0.7016789 0.9144108
0610010K14RIK 0.1439444 0.0000000 1.124842 0.7016789 0.0000000
我尝试使用dplyr 来执行此操作,但遇到了与(我认为是)垃圾箱数量相关的错误。这是我的尝试:
library(dplyr)
library(genefilter)
n_bins = 20
temp = data
temp$dispersion = rowMeans(temp)/rowVars(temp)
outscore = temp %>% mutate(bin=ntile(dispersion,n_bins)) %>%
group_by(bin) %>% mutate(zscore=scale(dispersion),outlier=abs(zscore)>1.7)
返回的错误是rror: dims [product 619] do not match the length of object [618]
【问题讨论】:
标签: r