过滤等于或大于特定值的数据的功能 [英] Function to filter data equal to or greater than a certain value
问题描述
我有一个包含数千行和列的数据框.行包含基因名称,列包含样品名称.
I have a dataframe containing thousands of rows and columns. The rows contain the names of genes and the columns the names of samples.
我只想在3个以上的样本中保留包含等于或大于5的值的行.
I only want to keep the rows that contain a value equal to or greater than 5 in more than 3 samples.
到目前为止,我已经尝试过了,但是我不知道如何设置多个条件:
I tried this so far but I can't figure out how to set multiple conditions:
data.frame1 %>% filter_all(all_vars(.>= 5))
我希望我已经正确回答了这个问题.
I hope I have stated this question correctly.
推荐答案
在基因表达过滤前的差异基因表达管道中的处理方式如下:
The way I do it in my gene expression filtering pre-differential gene expression pipeline is as follows:
data.frame1[rowSums(data.frame1 >= 5) > 3, ] -> filtered.counts
如果第一列是您的基因标识符,而其他所有列都是数字,则可以使评估跳过第一列,如下所示:
And if your first column is your gene identifier, with all the other columns being numeric, you can have the evaluation skip the first column as follows:
data.frame1[rowSums(data.frame1[-1] >= 5) > 3, ] -> filtered.counts
这篇关于过滤等于或大于特定值的数据的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!