给定以下数据帧:
| feature | gene | target | pos |
| 1_1_1 | NRAS | AATTGG | 60 |
| 1_1_1 | NRAS | TTGGCC | 6 |
| 1_1_1 | NRAS | AATTGG | 20 |
| 1_1_1 | KRAS | GGGGTT | 0 |
| 1_1_1 | KRAS | GGGGTT | 0 |
| 1_1_1 | KRAS | GGGGTT | 0 |
| 1_1_2 | NRAS | CCTTAA | 2 |
| 1_1_2 | NRAS | GGAATT | 8 |
| 1_1_2 | NRAS | AATTGG | 60 |
对于每一个特征,我想用以下规则计算每个基因中出现了多少个靶点:
这给了我一个数据帧,其中出现在多个位置的目标被标记为true。现在我只需要弄清楚如何使计数正常化。在
| feature | gene | count
| 1_1_1 | NRAS | 2
| 1_1_1 | KRAS | 1
| 1_1_2 | NRAS | 3
所以在上面的例子中,对于1u1nras,AATTGG在位置60和位置20都可以找到,每一个都会得到0.5的计数。因为TTGGCC在一个位置被找到一次,所以它的计数是1。这总共是2。在
如果在同一位置发现了3次NRAS TTGGCC,则每一次的计数为1,总计为3+。5+。5=4。在
解决方案需要检查出现在不同位置的同一目标,然后相应地调整计数,这是我很难处理的部分。我的最终目标是选择每个组中计数最高的基因。在
我不太清楚为什么第一排的计数应该是2。你能试着绕过这个问题吗:
好吧,我想好了。如果有更有效的方法来做这件事,我洗耳恭听!在
相关问题 更多 >
编程相关推荐